Wrong error message when using forall in constraints
I tried this in GHC 7.4.1:
{-# LANGUAGE ConstraintKinds, RankNTypes, UndecidableInstances #-}
newtype Free c a = Free { runFree :: forall r. c r => (a -> r) -> r }
type C c = forall a. c (Free c a)
instance C c => Monad (Free c) where
return a = Free ($ a)
Free f >>= g = f g
Which gives this error:
Could not deduce (c (Free c b)) arising from a use of `f'
from the context (C c)
So apparently the forall is silently dropped.
Without UndecidableInstances the error is:
Illegal irreducible constraint forall a. c (Free c a)
in superclass/instance head context (Use -XUndecidableInstances to permit this)
giving the impression that it is allowed.
Trac metadata
Trac field | Value |
---|---|
Version | 7.4.1 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |