Date: Wed, 5 May 93 11:53:31 +0200
From: Damien.Doligez@inria.fr (Damien Doligez)
Message-Id: <9305050953.AA04243@couchey.inria.fr>
To: caml-list@margaux
Subject: Re: new library modules
Xavier Leroy writes :
>I guess you mean (in the case of "set"):
[...]
> type 'a ordering == 'a -> 'a -> int;;
>
> type ('a, 'b) set_operations =
> { empty: 'a t;
> is_empty: 'a t -> bool;
> mem: 'a -> 'a t -> bool;
> add: 'a -> 'a t -> 'a t;
> iter: ('a -> 'b) -> 'a t -> unit;
> (* and so on *) };;
>
> value make: 'a ordering -> ('a, 'b) set_operations;;
This is not what I meant. What I meant was :
type 'a t;;
type 'a ordering == 'a -> 'a -> int;;
value make : 'a ordering -> 'a t
and is_empty : 'a t -> bool
and so on ...
and in the implementation :
type 'a t = { my_order: 'a ordering; data: (* internal representation *) };;
This has the advantage that you cannot use the wrong ordering when working
with a given set, and that you do not have to use a type annotation when
creating the set (with the "make" function).
Damien Doligez