[mercury-users] variable parameters in typeclass instances

Fergus Henderson fjh at cs.mu.OZ.AU
Mon Nov 15 09:01:16 AEDT 1999


On 13-Nov-1999, Peter Schachte <schachte at cs.mu.OZ.AU> wrote:
> On Fri, Nov 12, 1999 at 07:05:36PM +1100, Fergus Henderson wrote:
> > Peter Schachte <schachte at cs.mu.OZ.AU> wrote:
> > > There's nothing unprecedented about this:  Mercury already handles this
> > > for the implicit universal "unifiable" type class, where users can
> > > define their own equality predicate which overrides the default one.
> > 
> > There are several significant differences between that and allowing
> > overlapping instances in general.
> > 
> > With what we currently have
> > 
> > 	(1) there's a fixed set of type classes and methods
> > 	    that can be overridden
> > 
> > 	(2) the declaration saying that they are overridden
> > 	    is part of the type, not in a separate instance declaration
> > 	    (that might occur in a different module)
> 
> You were worried about semantics; I was just arguing that a reasonably
> clean semantics is not only possible, but already in use elsewhere in
> Mercury.

Now that I think about it, there is a semantic difference as well.
With user-defined equality, the program's semantics are determined by
just _adding_ the axioms for the user-defined equality predicate.
But with overlapping instances, if there is a specific instance declaration
then the rules for the general case don't apply; the axioms for a particular
instance must _override_ those for the general case.

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>  |  of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3        |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-users mailing list
post:  mercury-users at cs.mu.oz.au
administrative address: owner-mercury-users at cs.mu.oz.au
unsubscribe: Address: mercury-users-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-users-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the users mailing list