GHC accepts invalid Haskell: `class Eq (a Int) => C a where`
From the Haskell 2010 report chapter 4,
- Class and instance declarations:
| class [scontext =>] ...
| instance [scontext =>] ...
- Normal type signatures:
vars :: [context =>] ...
Notice the difference between scontext
(//with// s
) and context
(without s
).
scontext → simpleclass
| ( simpleclass1 , … , simpleclassn ) (n ≥ 0)
simpleclass → qtycls tyvar
context → class
| ( class1 , … , classn ) (n ≥ 0)
class → qtycls tyvar
| qtycls ( tyvar atype1 … atypen ) (n ≥ 1)
GHC seems to ignore this difference, and happily accepts class Eq (a Int) => C a where
. Hugs (Version: September 2006) reports for that same example:
Illegal Haskell 98 class constraint in class declaration
*** Constraint : Eq (a Int)
Trac metadata
Trac field | Value |
---|---|
Version | 8.0.1 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | lowest |
Resolution | Unresolved |
Component | Compiler |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |