[m-dev.] Typeclasses and constructor classes.

Fergus Henderson fjh at cs.mu.OZ.AU
Wed Sep 20 23:22:35 AEDT 2000


On 20-Sep-2000, David Glen JEFFERY <dgj at cs.mu.OZ.AU> wrote:
> FYI, there is one situation where you might want an explicit
> annotation, though: a class with no methods. eg. 
> 
> :- typeclass c(A,B) where [].

Another situation where you want explicit annotations
is when you're using an abstract typeclass:

	:- module m.
	:- interface.

	:- typeclass foo(T).
	:- type bar.
	:- instance foo(int).
	:- instance foo(string).
	:- instance foo(bar).

	:- func f(T) = string <= foo(T).

	:- implementation.

	:- typeclass foo(T) where [...].
	...

Here the interface does not give any clue as to the kind of `T'.
To make the interface self-contained, in such situations we should
require an explicit kind annotation.

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>  |  of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3        |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list