[mercury-users] Typeclass instance variable types question.

Julien Fischer juliensf at csse.unimelb.edu.au
Mon Dec 21 10:34:14 AEDT 2009


On Fri, 18 Dec 2009, Maxime Van Assche wrote:

> Just a (naive?) question...
> Why does the compiler requires a typeclass instance to have all of its types 
> non-variable?
> I understand that the goal is to be able to verify uniqueness.

The stated reason (ref man 10.2) is to ensure that there are no
overlapping instances.  (Which is presumably what you mean by uniqueness
in this context.)

> However, as far as I can tell, requiring all the types non-variable is too 
> conservative?
> Only one of the instance types must be non-variable in order to verify 
> uniqueness.

IIRC, that is the restriction that Haskell now has (although Haskell 98
was similar to Mercury in this respect.)  The current set of
restrictions on instance declarations is very conservative; there are
a number of other restrictions that we would like to remove,
particularly the one on repeated type variables in instance heads.

This has been discussed several times on this list, notably this

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

More information about the users mailing list