[mercury-users] Library v2 and Typeclasses'n'Stuff
Ralph Becket
rbeck at microsoft.com
Mon Nov 8 01:22:03 AEDT 1999
> [...]
> Not to forget exhaustiveness. How about a mode declaration
> for the corresponding disjunction, like this:
>
> :- mode ([] = in ; [out,out] = in) is det.
Unfortunately for this case, disjunction isn't exclusive, although the
`is det' declaration probably helps to disambiguate.
However, what I think is needed is not a change to the mode system, but
simply the adoption of the forthcoming promise mechanism with type
qualification, e.g.
:- promise all [X:sequence(S, T)] (X = []) <=> \+ (X = [H | T]).
>
> I think it is really important to be able to use pattern matching
> regardless of the actual data structure. Otherwise people start
> with the convenience of pattern matching on lists and cannot change
> to other datatypes later.
We have to be careful not to confuse type constructors with typeclass
functions. For example, I may have a sequence type with several different
`null's and several different `cons'es, yet still want basic sequencing
operations to work.
Ralph
--------------------------------------------------------------------------
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