[m-dev.] Types with user defined equality.

Peter Schachte schachte at cs.mu.OZ.AU
Tue May 15 15:55:19 AEST 2001


> In the fast string module I just posted, it would have been nice
> to be able to declare the (structured) str type as having an
> equality pred, but have this notion of equality visible only
> *outside* the defining module.

I think the easiest way to deal with user-defined equality is to have a
one-alternative one-argument wrapper type with user-defined equality, and
then write your module using the inner, wrapped type throughout.  This
basically gives you what you're asking for:  inside the module, you use the
inner type with no fancy equality, but outside, you use the wrapped type
that implements the proper equality.  So all your exported predicates wrap
or unwrap the arguments as needed and call internal predicates that do the
real work.


-- 
Peter Schachte <schachte at cs.mu.OZ.AU>  The greatest dangers to liberty lurk
http://www.cs.mu.oz.au/~schachte/      in insidious encroachment by men of
Phone:  +61 3 8344 9166                zeal, well-meaning but without
Fax:    +61 3 9348 1184                understanding. -- Justice Louis D.
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list