>  |    5. In the signature of a class operation, every constraint must
>  |       mention at least one type variable that is not a class type
>  |       variable. Thus:
>  ...
>  |       > class C a where
>  |       >    op :: Eq a => (a,b) -> (a,b)
>  |
>  |       is not OK because the constraint (Eq a) mentions on the class type
>  |       variable a, and no others.
> 
> What's the rationale for this rule?

It's hard to explain (which may well mean my head is on backwards).
In the 5 mins I have today here's what I added to the document


The reason it's awkward to implement is this. Supose you
are type checking the RHS of <tt>op</tt> in an instance declaration for <tt>C 
[c]</tt>,
and suppose you have found that you need the constraint <tt>(C (S c))</tt>.
Should we reduce the constraint, in the hope being able to
"use" the <tt>Eq [c]</tt> we have available?  Or should we just
postpone this reduction for the top level of the class decl. 
Usually I make this decision based on whether the constraint mentions any
of the universally quantified type variables (<tt>b</tt> in this case),
which it doesn't.  Without this convenient test I have to either
to eager context reduction (which I don't want to do), or some sort
of search strategy.

Simon


Reply via email to