<div dir="ltr">Ah, I see. I wasn't aware that constraints had to be over monotypes. I figured that since you could write a function <div><br></div><div>f :: (forall a. a -> a) -> Bool</div><div><br></div><div>Then you could also do similar things with a class.</div>

<div><br></div><div>(The reason I was doing this was that I wanted a typeclass to match something like "return 'a'" without using IncoherentInstances or other sketchiness, and found that trying to have a typeclass with an instance for 'forall m. Monad m => m Char` gave me this error.)</div>

<div><br></div><div>Thanks!</div><div>Andrew</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Jan 7, 2014 at 5:18 AM, Roman Cheplyaka <span dir="ltr"><<a href="mailto:roma@ro-che.info" target="_blank">roma@ro-che.info</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">* Andrew Gibiansky <<a href="mailto:andrew.gibiansky@gmail.com">andrew.gibiansky@gmail.com</a>> [2014-01-06 22:17:21-0500]<br>


<div><div class="h5">> Why is the following not allowed?<br>
><br>
> {-# LANGUAGE ExistentialQuantification, ExplicitForAll, RankNTypes,<br>
> FlexibleInstances #-}<br>
><br>
> class Class a where<br>
>   test :: a -> Bool<br>
><br>
> instance Class (forall m. m -> m) where<br>
>   test _ = True<br>
><br>
> main = do<br>
>   putStrLn $ test id<br>
><br>
> Is there a reason that this is forbidden? Just curious.<br>
<br>
</div></div>I believe the rule is that all constraints (including class constraints)<br>
range over monotypes.<br>
<br>
What are you trying to achieve?<br>
<br>
You can do this, for example:<br>
<br>
  newtype Poly = Poly (forall a . a -> a)<br>
  instance Class Poly where test = const True<br>
<br>
  main = print $ test $ Poly id<br>
<br>
BTW, this has nothing to do with ExistentialQuantification.<br>
<span class="HOEnZb"><font color="#888888"><br>
Roman<br>
</font></span></blockquote></div><br></div>