599819c60827fa3665c9921ff552b7420c2fd62c
[tatoo.git] / src / utils / 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 (*
17   Time-stamp: <Last modified on 2013-03-04 22:36:31 CET by Kim Nguyen>
18 *)
19
20   (** Abstract signature of a module implementing an hashconsed datatype *)
21 module type Abstract =
22 sig
23
24     (** The type of the data to be hash-consed *)
25   type data
26
27     (** The type of hashconsed data *)
28   type t
29
30     (** [make v] internalizes the value [v], making it an hashconsed
31         value.
32     *)
33   val make : data -> t
34
35     (** [node h] extract the original data from its hashconsed value
36     *)
37   val node : t -> data
38
39     (** [hash h] returns a hash of [h], such that for every [h1] and
40         [h2], [equal h1 h2] implies [hash h1 = hash h2].
41     *)
42   val hash : t -> int
43
44     (** [uid h] returns a unique identifier *)
45   val uid : t -> Uid.t
46
47     (** Equality between hashconsed values. Equivalent to [==] *)
48   val equal : t -> t -> bool
49
50     (** Initializes the internal storage. Any previously hashconsed
51         element is discarded. *)
52   val init : unit -> unit
53
54     (** Create a dummy (non-hashconsed) node with a boggus identifer
55         and hash *)
56   val dummy : data -> t
57 end
58
59
60   (** Concrete signature of a module implementing an hashconsed datatype *)
61 module type S =
62 sig
63   type data
64   type t = private { id   : Uid.t;
65                      hash : int;
66                      node : data }
67   include Abstract with type data := data and type t := t
68 end