QuantifiedConstraints: Problems with Typeable
This compiles
{-# Language GADTs, ConstraintKinds, ScopedTypeVariables, QuantifiedConstraints #-}
import Data.Typeable
data Ex cls where
MkEx :: cls xx => xx -> Ex cls
a :: Ex Typeable -> TypeRep
a (MkEx (_::xx)) = typeRep @_ @xx Proxy
-- b :: (forall xx. cls xx => Typeable xx) => Ex cls -> TypeRep
-- b (MkEx (_::xx)) = typeRep @_ @xx Proxy
c :: (forall xx. cls xx => Show xx) => Ex cls -> String
c (MkEx xx) = show xx
but uncommenting b
is too much:
$ qc hs/189-bug.hs
GHCi, version 8.5.20180128: http://www.haskell.org/ghc/ :? for help
[1 of 1] Compiling Main ( hs/189-bug.hs, interpreted )
hs/189-bug.hs:12:20: error:
• Could not deduce (Typeable xx) arising from a use of ‘typeRep’
from the context: forall xx. cls xx => Typeable xx
bound by the type signature for:
b :: forall (cls :: * -> Constraint).
(forall xx. cls xx => Typeable xx) =>
Ex cls -> TypeRep
at hs/189-bug.hs:11:1-60
or from: cls xx
bound by a pattern with constructor:
MkEx :: forall xx (cls :: * -> Constraint). cls xx => xx -> Ex cls,
in an equation for ‘b’
at hs/189-bug.hs:12:4-15
• In the expression: typeRep @_ @xx Proxy
In an equation for ‘b’: b (MkEx (_ :: xx)) = typeRep @_ @xx Proxy
|
12 | b (MkEx (_::xx)) = typeRep @_ @xx Proxy
| ^^^^^^^^^^^^^^^^^^^^
Failed, no modules loaded.
Prelude>
This is maybe because of the Typeable
solver.
Trac metadata
Trac field | Value |
---|---|
Version | 8.5 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |