[mercury-users] Library v2 and Typeclasses'n'Stuff

Peter Schachte schachte at cs.mu.OZ.AU
Sat Nov 6 01:08:22 AEDT 1999


> Stdlib v2 should have the following features, IMHO (Fergus et al. have
> already mentioned most/all of these):
...
> - be carefully constructed so as to make it easy to exploit in higher order
> code;
> - use DCG friendly argument ordering conventions in `stateful' ADTs (e.g.
> arrays);

But please don't make predicates use weird argument orderings just to
achieve this.  Eg,

:- pred array_update(int, T, array(T), array(T))

would be pretty weird.  Maybe have a second, DCG-ready. version of
a predicate where appropriate....


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
].

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.


-- 
Peter Schachte                     Remember, "Euphemisms are for the
mailto:schachte at cs.mu.OZ.AU        differently brained."
http://www.cs.mu.oz.au/~schachte/  -- jamie at cdevil.unx.sas.com (James
PGP: finger schachte at 128.250.37.3  Cooper) 
--------------------------------------------------------------------------
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