[m-dev.] proposal: user-defined equality predicates
Tyson Richard DOWD
trd at cs.mu.oz.au
Fri Jun 27 12:43:46 AEST 1997
> Hi,
>
> I propose to extend Mercury to support user-defined equality predicates
> for user-defined types. The following is a proposed new chapter for the
> Mercury Language Reference Manual describing this feature. It is probably
> a bit short on rationale and examples, but please let me know what you think.
I'm concerned that it might not smoothly merge in with typeclasses.
Does it?
>
> -----------------------------------------------------------------------------
>
> User-defined equality predicates
> ********************************
>
> When defining abstract data types, often it is convenient to use a
> non-canonical representation -- that is, one for which a single
> abstract value may have more than one different possible concrete
> representations. For example, you may wish to implement an abstract
> type `set' by representing a set as an (unsorted) list.
>
> :- module set_as_unsorted_list.
> :- interface.
> :- type set(T).
>
> :- implementation.
> :- import_module list.
> :- type set(T) ---> set(list(T)).
>
> In this example, the concrete representations `set([1,2])' and
> `set([2,1])' would both represent the same abstract value, namely the
> set containing the elements 1 and 2.
The `type(representation)' notation isn't really introduced clearly.
>
> For types such as this, which do not have a canonical representation,
> the standard definition of equality is the desired one; we want
I thought standard equality was syntactic? Why is this desired?
--
Tyson Dowd #
# Surreal humour isn't eveyone's cup of
trd at cs.mu.oz.au # fur.
http://www.cs.mu.oz.au/~trd #
More information about the developers
mailing list