Fix the build script.
[tatoo.git] / src / utils / common_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 23:01:55 CET by Kim Nguyen>
18 *)
19
20 (** Type equipped with an equality and hash function.
21     If [equal a b] then [(hash a) = (hash b)]
22 *)
23 module type HashedType =
24 sig
25   type t
26
27     (** [hash v] returns an integer in the range [ 0 - 2^30-1 ]
28     *)
29   val hash : t -> int
30
31     (** Equality *)
32   val equal : t -> t -> bool
33
34 end
35
36 (** Type equiped with a total ordering *)
37 module type OrderedType =
38 sig
39   type t
40
41     (** Total ordering on values of type [t].  [compare a b] returns a
42         negative number if [a] is strictly smaller than [b], a positive
43         number if [a] is strictly greater than [b] and 0 if [a] is equal
44         to [b].  *)
45   val compare : t -> t -> int
46 end
47
48 module type Type =
49 sig
50   type t
51   include HashedType with type t := t
52   include OrderedType with type t := t
53 end
54
55 (** Type equiped with a pretty-printer *)
56 module type Printable =
57 sig
58   type t
59   val print : Format.formatter -> t -> unit
60 end
61
62 (** Signature of a simple HashSet module *)
63 module type HashSet =
64 sig
65   type data
66   type t
67   val create : int -> t
68   val add : t -> data -> unit
69   val remove : t -> data -> unit
70   val find : t -> data -> data
71   val find_all : t -> data -> data list
72   val clear : t -> unit
73   val mem : t -> data -> bool
74 end
75
76   (** Signature of simple Set module *)
77 module type Set =
78 sig
79   type elt
80   type t
81   val empty : t
82   val is_empty : t -> bool
83   val mem : elt -> t -> bool
84   val add : elt -> t -> t
85   val singleton : elt -> t
86   val remove : elt -> t -> t
87   val union : t -> t -> t
88   val inter : t -> t -> t
89   val diff : t -> t -> t
90   val compare : t -> t -> int
91   val equal : t -> t -> bool
92   val subset : t -> t -> bool
93   val iter : (elt -> unit) -> t -> unit
94   val fold : (elt -> 'a -> 'a) -> t -> 'a -> 'a
95   val for_all : (elt -> bool) -> t -> bool
96   val exists : (elt -> bool) -> t -> bool
97   val filter : (elt -> bool) -> t -> t
98   val partition : (elt -> bool) -> t -> t * t
99   val cardinal : t -> int
100   val elements : t -> elt list
101   val min_elt : t -> elt
102   val max_elt : t -> elt
103   val choose : t -> elt
104   val split : elt -> t -> t * bool * t
105   val intersect : t -> t -> bool
106   val is_singleton : t -> bool
107   val from_list : elt list -> t
108 end