[m-dev.] Type class instance constraints

Mark Brown mark at csse.unimelb.edu.au
Wed May 23 18:32:30 AEST 2007


On 23-May-2007, Ian MacLarty <maclarty at csse.unimelb.edu.au> wrote:
> What are the issues with lifting the restrictions for arguments that are in
> the range of a functional dependency?

Much the same.

> So for example we could write
> instance declarations like:
> 
> :- instance stream.writer(gzip_writer(Stream), string, State)
> 	<= stream.writer(Stream, string, State).
> 
> Where stream.write(Stream, Unit, State) has functional dependency
> Stream -> State.
> 
> Won't the functional dependency guarantee that there are no overlapping
> instances?

Yes, but checking for overlapping instances is the easy part once the other
issues are dealt with.

> 
> Also won't the dictionary translation code work as is, since it must be
> able to lookup the typeclass without knowing the State type?

It doesn't work that way.  Typechecking uses the functional dependencies
to "improve" the types; the dictionary translation already has access to the
improved types.

Cheers,
Mark.

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