haskell 98 program does not typecheck when compiled with -XTypeFamilies
Consider the following valid Haskell 98 function:
f x =
do let apply p r = mapM p (r x)
a <- apply id fst
b <- apply return snd
return (a ++ b)
It compiles fine with both ghc 6.12.x and ghc 7. However, if I add the -XTypeFamilies flag to ghc 7 it is rejected with:
mono.hs:5:17:
Occurs check: cannot construct the infinite type: a0 = m0 a0
Expected type: m0 a0 -> m0 a0
Actual type: m0 a0 -> m0 (m0 a0)
In the first argument of `apply', namely `return'
In a stmt of a 'do' expression: b <- apply return snd
If one adds a type signature, the error message gets more intimidating.
A project of mine uses Type Families in some modules so TypeFamilies is listed as an extension in cabal's configuration file; therefore, it is being passed to every module. That is how I stumbled upon this problem.
Trac metadata
Trac field | Value |
---|---|
Version | 7.0.2 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler (Type checker) |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |