[m-dev.] Type class instance constraints

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


On Tue, 22 May 2007, Simon Taylor wrote:

> On 22-May-2007, Ralph Becket <rafe at csse.unimelb.edu.au> 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.  In practice we can only check for overlapping
>> instance declarations in different modules at link-time.  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.
>
> I think the problem is the amount of work needed to alter the RTTI system
> throughout the compiler and runtime.  Removing the restrictions will cause
> big changes in the way we extract type-infos from typeclass-infos at runtime,
> although that doesn't always work properly now even with the restrictions.

That's one of the reasons we're getting rid of the packing type_infos
into typeclass_infos thing.

Julien.
--------------------------------------------------------------------------
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