[mercury-users] Library v2 and Typeclasses'n'Stuff
Juergen Stuber
juergen at mpi-sb.mpg.de
Sun Nov 7 02:45:23 AEDT 1999
David Glen JEFFERY <dgj at cs.mu.OZ.AU> writes:
>
> On 06-Nov-1999, Peter Schachte <schachte at cs.mu.OZ.AU> wrote:
> >
> > Here's an addition to your suggested set of type classes:
> >
> > :- sequence(S, T) where [
> > func [] = S(T),
> > func [T|S(T)] = S(T),
> > mode [] = out is det,
> > mode [out, out] = in is det
> > ].
>
> I think that last mode should be:
> mode [out|out] = in is semidet
>
> (or probably mode .(out, out) is semidet).
>
> > Using this type class, one can traverse any sort of sequence as if it
> > were a list. Seems like a pleasant way to do this.
>
> It would be nice to be able to include some kind of mutual exclusion
> declaration between `[]/0' and `./2'.
Not to forget exhaustiveness. How about a mode declaration
for the corresponding disjunction, like this:
:- mode ([] = in ; [out,out] = in) is det.
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.
Jürgen
--
Jürgen Stuber <juergen at mpi-sb.mpg.de>
http://www.mpi-sb.mpg.de/~juergen/
--------------------------------------------------------------------------
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