[mercury-users] variable parameters in typeclass instances

Peter Schachte schachte at cs.mu.OZ.AU
Fri Nov 12 18:48:40 AEDT 1999


On Fri, Nov 12, 1999 at 03:16:57PM +1100, David Glen JEFFERY wrote:
> ... there are plenty of examples where it would be nice
> to be able to provide a `universal' instance as well as more specific 
> instances. The problem here is that it does make the semantics (and probably
> the implementation) rather more complicated because in these cases there may
> be more than one instance declaration that could be applied (`overlapping'
> instances). 

I think you need a "explicit instance declarations always override
implicit ones" kind of semantics.  For example, suppose every
discriminated union type is `printable', using functor and arg to
print them.  You'd want to be able to specify that your new foo type
is `printable', but supplies its own print method.

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.

-- 
Peter Schachte                     All truth goes through three stages.
mailto:schachte at cs.mu.OZ.AU        First it is ridiculed. Then it is
http://www.cs.mu.oz.au/~schachte/  violently opposed. Finally, it is
PGP: finger schachte at 128.250.37.3  accepted as self-evident.
--------------------------------------------------------------------------
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