[m-rev.] diff: fundeps, polymorphic instances

Mark Brown mark at csse.unimelb.edu.au
Mon Oct 30 12:04:03 AEDT 2006


On 30-Oct-2006, Ralph Becket <rafe at csse.unimelb.edu.au> wrote:
> Mark Brown, Sunday, 29 October 2006:
> > Estimated hours taken: 16
> > Branches: main
> > 
> > Support polymorphic instances of typeclasses with functional dependencies.
> > We do this by allowing type variables in the range arguments, which must be
> > distinct according to existing typeclass restrictions, to be determined
> > from type variables in the domain arguments by the functional dependencies
> > on the instance constraints.
> 
> This suggests to me that you are allowing 
> 
> :- instance foo(list(T), T) where ...
> 
> given that
> 
> :- typeclass foo(T1, T2) <= (T1 -> T2), ...
> 
> Which would be wonderful.

It would be good, but it isn't supported.  The existing restrictions on
typeclass instances are still in force (namely, that arguments must be
type constructors with distinct variables as arguments).

Previously, this implied that the second argument of foo instances must
contain no type variables at all, which is pretty harsh.  We now at least
allow some cases -- just not ones where there are duplicate variables in
the instnace arguments, or arguments that are otherwise not of the correct
form.

The part of the reference manual that documents the existing restriction has
not changed, and therefore did not appear in the diff.

Cheers,
Mark.

--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to:       mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions:          mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the reviews mailing list