Deriving for H98 types using GADT syntax fails
This example from the GADT section of the user manual:
data Maybe1 a where {
Nothing1 :: Maybe1 a ;
Just1 :: a -> Maybe1 a
} deriving (Eq,Ord)
Fails with:
Test_show.hs:28:5:
Can't derive instances where the instance context mentions
type variables that are not data type parameters
Offending constraint: Eq a
When deriving the instance for `Eq (Maybe1 a)'
Test_show.hs:28:5:
Variable occurs more often in a constraint than in the instance head
in the constraint: Eq a
(Use -fallow-undecidable-instances to permit this)
In the derived instance declaration
instance (Eq a) => Eq (Maybe1 a)
-dppr-debug gives this:
Test_show.hs:28:5:
Can't derive instances where the instance context mentions
type variables that are not data type parameters
Offending constraint: base:GHC.Base.Eq{tc 23} a{tv adf} [tv]
When deriving the instance for `base:GHC.Base.Eq{tc 23} (main:Test_show.Maybe1{tc ray} a{tv adg} [tv])'
Test_show.hs:28:5:
Variable occurs more often in a constraint than in the instance head
in the constraint: base:GHC.Base.Eq{tc 23} a{tv adf} [tv]
(Use -fallow-undecidable-instances to permit this)
In the derived instance declaration
instance (base:GHC.Base.Eq{tc 23} a{tv adf} [tv]) =>
base:GHC.Base.Eq{tc 23} (main:Test_show.Maybe1{tc ray} a{tv adg} [tv])
The two "a":s appear to be different, "a{tv adf}" and "a{tv adg}".
Trac metadata
Trac field | Value |
---|---|
Version | 6.5 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | Unknown |
Architecture | Unknown |