[m-dev.] manifest sets

Peter Schachte schachte at cs.mu.OZ.AU
Wed Aug 16 15:10:45 AEST 2000


Here's a solution to allow reasonable-looking manifest set constants.

I'm sure someone can tell me how to avoid the need to split this into to
modules by using submodules or something like that.  Is there some reason some
adaptation of this code shouldn't be put in set.m?

The other question is:  will this still work with the proposed new tuple
syntax?


================================================================
:- module setnotation.
:- interface.
:- import_module set.

:- type internal_set(T) ---> internal_set(set(T)).

:- func (T,internal_set(T)) = internal_set(T).
:- func {internal_set(T)} = set(T).

:- implementation.

(X,internal_set(Y)) = internal_set(insert(Y, X)).

{internal_set(X)} = X.
================================================================
:- module setnotation2.
:- interface.
:- import_module setnotation.

:- func (T,T) = internal_set(T).

:- implementation.
:- import_module set.

(X,Y) = internal_set(insert(insert(init, Y), X)).
================================================================

Then you can write code like:

main -->
	write( {8, 6, 4, 2} ),
	nl.


-- 
Peter Schachte <schachte at cs.mu.OZ.AU>  Many men stumble across the truth,
http://www.cs.mu.oz.au/~schachte/      but most manage to pick themselves up
Phone:  +61 3 8344 9166                and continue as if nothing had
Fax:    +61 3 9348 1184                happened. -- Winston Churchill 
--------------------------------------------------------------------------
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