
7 Jan
2014
7 Jan
'14
10:18 a.m.
* Andrew Gibiansky
Why is the following not allowed?
{-# LANGUAGE ExistentialQuantification, ExplicitForAll, RankNTypes, FlexibleInstances #-}
class Class a where test :: a -> Bool
instance Class (forall m. m -> m) where test _ = True
main = do putStrLn $ test id
Is there a reason that this is forbidden? Just curious.
I believe the rule is that all constraints (including class constraints) range over monotypes. What are you trying to achieve? You can do this, for example: newtype Poly = Poly (forall a . a -> a) instance Class Poly where test = const True main = print $ test $ Poly id BTW, this has nothing to do with ExistentialQuantification. Roman