Type casts cause confusing error
Try this
instance Eq (Either a)
GHC HEAD gives
Foo.hs:9:10: error:
• Illegal instance declaration for ‘Eq (Either a)’
(All instance types must be of the form (T a1 ... an)
where a1 ... an are *distinct type variables*,
and each type variable appears at most once in the instance head.
Use FlexibleInstances if you want to disable this.)
• In the instance declaration for ‘Eq (Either a)’
Foo.hs:9:14: error:
• Expecting one more argument to ‘Either a’
Expected a type, but ‘Either a’ has kind ‘* -> *’
• In the first argument of ‘Eq’, namely ‘Either a’
In the instance declaration for ‘Eq (Either a)’
The second is right but the first is outright misleading.
Reason: we elaborate to
Eq (Either a |> g)
where g
is a type-level kind cast; it's insoluble and gives rise to the second error. But the elaborated type confuses checkValidInstHead
.
Trac metadata
Trac field | Value |
---|---|
Version | 7.10.3 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |