
4 Nov
2011
4 Nov
'11
7:33 p.m.
Quoting Wolfgang Jeltsch
this code is accepted by GHC 7.0.4: <snip> However, this one isn?t:
{-# LANGUAGE ImpredicativeTypes #-}
polyId :: (forall a. Maybe a) -> Maybe a polyId x = x
polyIdMap :: [forall a. Maybe a] -> [forall a. Maybe a] polyIdMap xs = fmap polyId xs
Is there a way to make it accepted?
Yep, fix the type signature. There is no type you can substitute for "a" in "Maybe a" that results in "forall a. Maybe a". But GHC accepts the same code with the following type signature, which should make clear what I mean: polyIdMap :: [forall a. Maybe a] -> [Maybe (forall a. a)] ~d