instance inference

Ross Paterson ross at soi.city.ac.uk
Mon Feb 6 07:07:54 EST 2006


On Mon, Feb 06, 2006 at 11:53:17AM -0000, Simon Peyton-Jones wrote:
> Thanks!  But I'm not certain that your fix is correct.  Let's ask
> Martin.  I've added comments below.
> 
> [...]
> 
> Yes, (1-GHC) certainly contradicts the FD paper that Martin and I wrote.
> I think (1) should be:
> 
>    (1-fixed) Each assertion in the context must constrain type
> variables, and 
>    those type variables must all be mentioned in the head.
> 
> That is, there is no requirement that the type variables should be
> distinct (they can be repeated).  But they must all appear in the HEAD.

Ah, but you added the no-repetition requirement a few weeks ago in
response to the example

	class C a b
	instance C b b => C (Maybe a) b

> Your (1-Ross) ensures that every variable in the assertion does occur in
> the head.  But I'm not sure that the size-reduction argument is
> watertight in the presence of fundeps.  (E.g. in example 15 it *looks*
> as if the size goes down, but it doesn't.) 

Hmm, "improvement".  But this is a problem for the GHC rules too, isn't
it?

> It certainly looks useful. However, notice that (1-Ross) is more also
> more restrictive than (1-fixed), because it rules out the C/D example I
> give above.  So is it a win?  

It might be possible to do slightly better, but only if the assertion
with repeated variables is for the same class as in the head.  Otherwise
we'd need to consider several instances together.



More information about the Glasgow-haskell-users mailing list