[m-dev.] Type class instance constraints

Julien Fischer juliensf at csse.unimelb.edu.au
Tue May 22 14:46:43 AEST 2007

On Tue, 22 May 2007, Ralph Becket wrote:

> We currently have a number of restrictions on what can appear in an
> instance declaration, namely that
> - each parameter takes the form type_name(TypeVar1, TypeVar2, ...)
> - all TypeVars are distinct.
> These restrictions are there to prevent ambiguity with overlapping
> instance declarations.

They are also there to ensure that typechecking terminates.

> Given that is the case, why can't we lift both restrictions and simply check
> for ambiguity at link time?  It would make the type class system much more
> useful.  Currently the first restriction means you have to define no-tag
> types all over the place and the second restriction prevents much useful
> polymorphism.

Mark, is lifting these restrictions primarily a typechecking issue or
an RTTI issue?  (I don't know that much about the former, but the latter,
particulary for the second restriction, shouldn't be too much of a

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

More information about the developers mailing list