Are anonymous type classes the right model at all? (replying to Re: Are fundeps the right model at all?)

Fergus Henderson fjh@cs.mu.oz.au
Tue, 26 Dec 2000 12:10:55 +1100


On 21-Dec-2000, George Russell <ger@tzi.de> wrote:
> (3) Finally it would be nice to extend the module syntax to allow named
>     instances to be selectively exported and imported, just like variables.  

Mercury's module system allows instance declarations (which, as in
Haskell 98, are unnamed) to be selectively exported.

	:- module foo.
	:- interface.

	    :- import_module enum.

	    :- type t.
	    :- instance enum(t).

	:- implementation.

	    :- instance enum(t) where [ ... ].

Mercury doesn't directly support selective import -- you can only
import a whole module, not part of it.  But if you really want that
you can achieve it by putting each instance declaration in its own
nested module.

	:- module foo.
	:- interface.
	:- import_module enum.

	   :- type t.

	   :- module enum_t.
	   :- interface.
	   :- instance enum(t).
	   :- end_module enum_t.

	:- implementation.

	   :- module enum_t.
	   :- implementation.
	   :- instance enum(t) where [ ... ].
	   :- end_module enum_t.

-- 
Fergus Henderson <fjh@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.