instance inference

Doaitse Swierstra doaitse at
Mon Feb 6 07:53:17 EST 2006

I have not followed this completely, but do these new rules now allow:

class F a b c where
   f: a -> b -> c

and then

instance F a a a where

which gives currenly gives (using -fglasgow-exts):

     Illegal instance declaration for `F a a a'
         (There must be at least one non-type-variable in the  
instance head
          Use -fallow-undecidable-instances to permit this)
     In the instance declaration for `F a a a'

I recently ran into this, and I thought it to be perfectly  
reasonable, but GHC complained.

On the other hand:

instance F [a] [a] [a] where
posed no problem, although I still see no non-type-variable in the  
head, or is [] a non-type-variable? I assumed the complaint was a  
left-over from the single parameter classes, where indeed having a  
single variable in an instance declaration does not make much sense.  
The second example does not follow the old rule (2) below!

So rule (2) below is either not correctly implemented or not  
correctly stated or the error message is confusing, or I am missing  
something completely. Who can enlighten me?


because of the old rule (2) below. When I
On 2006 feb 06, at 12:35, Ross Paterson wrote:
> A patch implementing a relaxed termination constraint is at
> Here is the description:
>  With -fglasgow-exts but not -fallow-undecidable-instances, GHC 6.4
>  requires that instances be of the following form:
>   (1) each assertion in the context must constrain distinct variables
>       mentioned in the head, and
>   (2) at least one argument of the head must be a non-variable type.

More information about the Glasgow-haskell-users mailing list