types.mli 4.9 KB
Newer Older
1 2
open Ident

3 4 5
type const = | Integer of Intervals.v
	     | Atom of Atoms.v 
	     | Char of Chars.v
6

7 8
val compare_const: const -> const -> int
val hash_const: const -> int
9
val equal_const: const -> const -> bool
10

11 12
(** Algebra **)

13 14
type node
type descr
15

16 17
val make: unit -> node
val define: node -> descr -> unit
18

19 20
val cons: descr -> node
val internalize: node -> node
21

22 23
val id: node -> int
val descr: node -> descr
24

25 26
val equal_descr: descr -> descr -> bool
val hash_descr: descr -> int
27
val compare_descr: descr -> descr -> int
28

29
module DescrHash: Hashtbl.S with type key = descr
30
module DescrSList: SortedList.S with type 'a elem = descr
31 32
module DescrMap: Map.S with type key = descr

33 34
(** Boolean connectives **)

35 36 37 38 39 40
val cup    : descr -> descr -> descr
val cap    : descr -> descr -> descr
val diff   : descr -> descr -> descr
val neg    : descr -> descr
val empty  : descr
val any    : descr
41

42 43
val any_node : node

44 45
(** Constructors **)

46 47
type pair_kind = [ `Normal | `XML ]

48
val interval : Intervals.t -> descr
49
val atom     : Atoms.t -> descr
50
val times    : node -> node -> descr
51
val xml      : node -> node -> descr
52
val arrow    : node -> node -> descr
53
val record   : label -> node -> descr
54
val record'  : bool * node label_map -> descr
55
val char     : Chars.t -> descr
56
val constant : const -> descr
57

58 59 60 61 62 63 64
(** Positive systems and least solutions **)

module Positive :
sig
  type v
  val forward: unit -> v
  val define: v -> v -> unit
65
  val ty: descr -> v
66 67
  val cup: v list -> v
  val times: v -> v -> v
68
  val xml: v -> v -> v
69

70
  val solve: v -> node
71 72 73 74 75
end

(** Normalization **)

module Product : sig
76
  val any : descr
77 78 79
  val any_xml : descr
  val other : ?kind:pair_kind -> descr -> descr
  val is_product : ?kind:pair_kind -> descr -> bool
80 81 82

  (* List of non-empty rectangles *)
  type t = (descr * descr) list
83
  val is_empty: t -> bool
84
  val get: ?kind:pair_kind -> descr -> t
85 86
  val pi1: t -> descr
  val pi2: t -> descr
87
  val pi2_restricted: descr -> t -> descr
88 89 90 91 92 93 94
    
  (* Intersection with (pi1,Any) *)
  val restrict_1: t -> descr -> t

  (* List of non-empty rectangles whose first projection
     are pair-wise disjunct *)
  type normal = t
95
  val normal: ?kind:pair_kind -> descr -> normal
96

97 98 99 100
  val constraint_on_2: normal -> descr -> descr
    (* constraint_on_2 n t1:  maximal t2 such that (t1,t2) <= n *)
    (* Assumption: t1 <= pi1(n) *)

101 102
  val need_second: t -> bool
    (* Is there more than a single rectangle ? *)
103 104 105
end

module Record : sig
106 107 108 109 110 111 112 113 114 115 116 117 118
  val any : descr
  val or_absent: descr -> descr
  val any_or_absent: descr

  val has_absent: descr -> bool
  val has_record: descr -> bool

  val split : descr -> label -> Product.t
  val split_normal : descr -> label -> Product.normal

  val project : descr -> label -> descr
    (* Raise Not_found if label is not necessarily present *)

119 120 121 122 123 124
  val condition : descr -> label -> descr -> descr
    (* condition t1 l t2 : What must follow if field l hash type t2 *)
  val project_opt : descr -> label -> descr
  val has_empty_record: descr -> bool


125 126 127 128
  val first_label: descr -> label

  val empty_cases: descr -> bool * bool

129 130
  val merge: descr -> descr -> descr
  val remove_field: descr -> label -> descr
131 132
end

133 134
module Arrow : sig
  val any : descr
135

136 137 138 139 140 141 142 143
  val check_strenghten: descr -> descr -> descr
    (* [check_strenghten t s]
       Assume that [t] is an intersection of arrow types
       representing the interface of an abstraction;
       check that this abstraction has type [s] (otherwise raise Not_found)
       and returns a refined type for this abstraction.
    *)

144 145
  val check_iface: (descr * descr) list -> descr -> bool

146
  type t
147
  val is_empty: t -> bool
148 149
  val get: descr -> t
    (* Always succeed; no check <= Arrow.any *)
150

151 152 153
  val domain: t -> descr
  val apply: t -> descr -> descr
    (* Always succeed; no check on the domain *)
154 155 156 157 158 159

  val need_arg : t -> bool
    (* True if the type of the argument is needed to obtain
       the type of the result (must use [apply]; otherwise,
       [apply_noarg] is enough *)
  val apply_noarg : t -> descr
160 161 162
end


163
module Int : sig
164
  val has_int : descr -> Intervals.v -> bool
165

166 167 168 169 170 171 172
  val any : descr

  val is_int : descr -> bool
  val get: descr -> Intervals.t
  val put: Intervals.t -> descr
end

173
module Atom : sig
174
  val has_atom : descr -> Atoms.v -> bool
175
  val get: descr -> Atoms.t
176 177
end

178
module Char : sig
179
  val has_char : descr -> Chars.v -> bool
180
  val any : descr
181
  val get: descr -> Chars.t
182 183
end

184
val normalize : descr -> descr
185

186
(** Subtyping and sample values **)
187

188 189 190
val is_empty : descr -> bool
val non_empty: descr -> bool
val subtype  : descr -> descr -> bool
191

192 193
module Sample :
sig
194
  type t 
195 196 197 198 199 200

  val get : descr -> t
	(** 
	  Extract a sample value from a non empty type;
	  raise Not_found for an empty type
	**)
201 202

  val print : Format.formatter -> t -> unit
203 204
end

205 206
module Print :
sig
207
  val register_global : string -> descr -> unit
208
  val print_const : Format.formatter -> const -> unit
209 210
  val print : Format.formatter -> node -> unit
  val print_descr: Format.formatter -> descr -> unit
211
end
212

213
val print_stat: Format.formatter -> unit