Implement set-theoretic operation on 2WSATA (union, intersection,
[tatoo.git] / src / hcons_sig.ml
1 (***********************************************************************)
2 (*                                                                     *)
3 (*                               TAToo                                 *)
4 (*                                                                     *)
5 (*                     Kim Nguyen, LRI UMR8623                         *)
6 (*                   Université Paris-Sud & CNRS                       *)
7 (*                                                                     *)
8 (*  Copyright 2010-2012 Université Paris-Sud and Centre National de la *)
9 (*  Recherche Scientifique. All rights reserved.  This file is         *)
10 (*  distributed under the terms of the GNU Lesser General Public       *)
11 (*  License, with the special exception on linking described in file   *)
12 (*  ../LICENSE.                                                        *)
13 (*                                                                     *)
14 (***********************************************************************)
15
16   (** Abstract signature of a module implementing an hashconsed datatype *)
17 module type Abstract =
18 sig
19
20     (** The type of the data to be hash-consed *)
21   type data
22
23     (** The type of hashconsed data *)
24   type t
25
26     (** [make v] internalizes the value [v], making it an hashconsed
27         value.
28     *)
29   val make : data -> t
30
31     (** [node h] extract the original data from its hashconsed value
32     *)
33   val node : t -> data
34
35     (** [hash h] returns a hash of [h], such that for every [h1] and
36         [h2], [equal h1 h2] implies [hash h1 = hash h2].
37     *)
38   val hash : t -> int
39
40     (** [uid h] returns a unique identifier *)
41   val uid : t -> Uid.t
42
43     (** Equality between hashconsed values. Equivalent to [==] *)
44   val equal : t -> t -> bool
45
46     (** Initializes the internal storage. Any previously hashconsed
47         element is discarded. *)
48   val init : unit -> unit
49
50     (** Create a dummy (non-hashconsed) node with a boggus identifer
51         and hash *)
52   val dummy : data -> t
53 end
54
55
56   (** Concrete signature of a module implementing an hashconsed datatype *)
57 module type S =
58 sig
59   type data
60   type t = private { id   : Uid.t;
61                      hash : int;
62                      node : data }
63   include Abstract with type data := data and type t := t
64 end