Ticket #7019 (closed bug: fixed)
Wrong error message when using forall in constraints
Description
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.
Change History
Note: See
TracTickets for help on using
tickets.
