/[svn]/types/types.mli
ViewVC logotype

Contents of /types/types.mli

Parent Directory Parent Directory | Revision Log Revision Log


Revision 71 - (show annotations)
Tue Jul 10 17:03:32 2007 UTC (5 years, 10 months ago) by abate
File size: 4625 byte(s)
[r2002-11-01 20:09:48 by cvscast] Empty log message

Original author: cvscast
Date: 2002-11-01 20:09:49+00:00
1 type label = int
2 type atom = int
3 type const = Integer of Big_int.big_int | Atom of atom | Char of Chars.Unichar.t
4
5 (** Algebra **)
6
7 type node
8 type descr
9
10 val make: unit -> node
11 val define: node -> descr -> unit
12
13 val cons: descr -> node
14 val internalize: node -> node
15
16 val id: node -> int
17 val descr: node -> descr
18
19 val equal_descr: descr -> descr -> bool
20 val hash_descr: descr -> int
21
22
23 module DescrHash: Hashtbl.S with type key = descr
24 module DescrMap: Map.S with type key = descr
25
26 (* Note: it seems that even for non-functional data, DescrMap
27 is more efficient than DescrHash ... *)
28
29 (** Boolean connectives **)
30
31 val cup : descr -> descr -> descr
32 val cap : descr -> descr -> descr
33 val diff : descr -> descr -> descr
34 val neg : descr -> descr
35 val empty : descr
36 val any : descr
37
38 (** Constructors **)
39
40 val interval : Intervals.t -> descr
41 val atom : atom Atoms.t -> descr
42 val times : node -> node -> descr
43 val arrow : node -> node -> descr
44 val record : label -> bool -> node -> descr
45 val char : Chars.t -> descr
46 val constant : const -> descr
47
48 (** Positive systems and least solutions **)
49
50 module Positive :
51 sig
52 type v
53 val forward: unit -> v
54 val define: v -> v -> unit
55 val ty: descr -> v
56 val cup: v list -> v
57 val times: v -> v -> v
58
59 val solve: v -> node
60 end
61
62 (** Labels and atom names **)
63
64 val mk_atom : string -> atom
65 val atom_name : atom -> string
66
67 val label : string -> label
68 val label_name : label -> string
69
70 (** Normalization **)
71
72 module Product : sig
73 val any : descr
74 val other : descr -> descr
75 val is_product : descr -> bool
76
77 (* List of non-empty rectangles *)
78 type t = (descr * descr) list
79 val is_empty: t -> bool
80 val get: descr -> t
81 val pi1: t -> descr
82 val pi2: t -> descr
83
84 (* Intersection with (pi1,Any) *)
85 val restrict_1: t -> descr -> t
86
87 (* List of non-empty rectangles whose first projection
88 are pair-wise disjunct *)
89 type normal = t
90 val normal: descr -> normal
91
92 val need_second: t -> bool
93 (* Is there more than a single rectangle ? *)
94 end
95
96 module Record : sig
97 val any : descr
98
99 (* List of maps label -> (optional, content) *)
100 type t = (label, (bool * descr)) SortedMap.t list
101 val get: descr -> t
102 val is_empty: t -> bool
103 val restrict_label_present: t -> label -> t
104 val restrict_field: t -> label -> descr -> t
105 val restrict_label_absent: t -> label -> t
106 val project_field: t -> label -> descr
107
108 type normal =
109 [ `Success
110 | `Fail
111 | `Label of label * (descr * normal) list * normal ]
112 val normal: descr -> normal
113
114 val project : descr -> label -> descr
115 (* Raise Not_found if label is not necessarily present *)
116 end
117
118 module Arrow : sig
119 val any : descr
120
121 val check_strenghten: descr -> descr -> descr
122 (* [check_strenghten t s]
123 Assume that [t] is an intersection of arrow types
124 representing the interface of an abstraction;
125 check that this abstraction has type [s] (otherwise raise Not_found)
126 and returns a refined type for this abstraction.
127 *)
128
129 val check_iface: (descr * descr) list -> descr -> bool
130
131 type t
132 val is_empty: t -> bool
133 val get: descr -> t
134 (* Always succeed; no check <= Arrow.any *)
135
136 val domain: t -> descr
137 val apply: t -> descr -> descr
138 (* Always succeed; no check on the domain *)
139
140 val need_arg : t -> bool
141 (* True if the type of the argument is needed to obtain
142 the type of the result (must use [apply]; otherwise,
143 [apply_noarg] is enough *)
144 val apply_noarg : t -> descr
145 end
146
147
148 module Int : sig
149 val has_int : descr -> Big_int.big_int -> bool
150
151 val any : descr
152
153 val is_int : descr -> bool
154 val get: descr -> Intervals.t
155 val put: Intervals.t -> descr
156 end
157
158 module Atom : sig
159 val has_atom : descr -> atom -> bool
160 end
161
162 module Char : sig
163 val has_char : descr -> Chars.Unichar.t -> bool
164 val any : descr
165 end
166
167 val normalize : descr -> descr
168
169 (** Subtyping and sample values **)
170
171 val is_empty : descr -> bool
172 val non_empty: descr -> bool
173 val subtype : descr -> descr -> bool
174
175 module Sample :
176 sig
177 type t =
178 | Int of Big_int.big_int
179 | Atom of atom
180 | Char of Chars.Unichar.t
181 | Pair of t * t
182 | Record of (label * t) list
183 | Fun of (node * node) list
184
185 val get : descr -> t
186 (**
187 Extract a sample value from a non empty type;
188 raise Not_found for an empty type
189 **)
190
191 val print : Format.formatter -> t -> unit
192 end
193
194 module Print :
195 sig
196 val register_global : string -> descr -> unit
197 val print_const : Format.formatter -> const -> unit
198 val print : Format.formatter -> node -> unit
199 val print_descr: Format.formatter -> descr -> unit
200 end
201
202 val check: descr -> unit

CVS Admin">CVS Admin
ViewVC Help
Powered by ViewVC 1.1.5