Improve error message for GADT failures
If you write
type family Fam a :: *
data GADT :: * -> * where
GADT :: a -> Fam a -> GADT (Fam a)
unwrap :: GADT (Fam a) -> (a, Fam a)
unwrap (GADT x y) = (x, y)
then typechecking unwrap should certainly fail. And it does, but with a horrible message:
Main.hs:9:21:
Couldn't match expected type `a' against inferred type `a1'
`a' is a rigid type variable bound by
the type signature for `unwrap' at Main.hs:8:20
`a1' is a rigid type variable bound by
the constructor `GADT' at Main.hs:9:8
In the expression: x
In the expression: (x, y)
In the definition of `unwrap': unwrap (GADT x y) = (x, y)
It would be better to say something more like:
Cannot deduce (a ~ a1) from (Fam a ~ Fam a1)
See the thread at http://thread.gmane.org/gmane.comp.lang.haskell.cafe/62322
Trac metadata
| Trac field | Value |
|---|---|
| Version | 6.10.4 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture |