Order is relevant when matching signature contexts of a mutually recursive group
The Following code
f :: (Show a, Eq a) => a -> String
f x = show x `const` g x
g :: (Eq a,Show a) => a -> Bool
g x = x==x `const` f x
gives this error:
Couldn't match expected type `Eq a' against inferred type `Show a1'
When matching the contexts of the signatures for
f :: forall a. (Show a, Eq a) => a -> String
g :: forall a. (Eq a, Show a) => a -> Bool
The signature contexts in a mutually recursive group should all be identical
When generalising the type(s) for f, g
Failed, modules loaded: none.
but it compiles fine if i swap Show and Eq in the context of either f or g. The order of typeclass constraints usually doesn't matter so it's very surprising that it does here.
Trac metadata
Trac field | Value |
---|---|
Version | 6.8.3 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler (Type checker) |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | sanzhiyan@gmail.com |
Operating system | Unknown |
Architecture | Unknown |