[mercury-users] typeclass question #2
Fergus Henderson
fjh at cs.mu.OZ.AU
Thu May 3 14:24:01 AEST 2001
On 02-May-2001, Terrence Brannon <princepawn at earthlink.net> wrote:
>
> :- type rgb
> ---> rgb(
> int,
> int,
> int
> ).
>
> :- type coloured_coordinate
> ---> coloured_coordinate(
> float,
> float,
> rgb
> ).
>
> .... I would have done this a different way:
>
> :- type coordinate --->
> coordinate (float,float).
>
> type colored_coordinate %correct spelling :-)
> ---> colored_coordinate(
> coordinate,
> rgb
> ).
Yes, that is probably better design, in fact.
> ... then I tried to figure out how to write methods to do the two
> levels of indirection but
> a - the samples directory has no typeclasses
> b - the library directory has one: enum, but only an interface and
> no implementation.
There are instances of enum in the other library modules:
bool.m, char.m, int.m, term.m.
There are also some examples in the "tests" distribution,
in the directory tests/hard_coded/typeclasses.
(However, these examples where not specifically designed for pedagogical
purposes.)
--
Fergus Henderson <fjh at cs.mu.oz.au> | "I have always known that the pursuit
| of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh> | -- the last words of T. S. Garp.
--------------------------------------------------------------------------
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