Skip to content

Commit 5162b30

Browse files
committed
add comments in Syntactic.mli
1 parent 2356cad commit 5162b30

File tree

1 file changed

+44
-1
lines changed

1 file changed

+44
-1
lines changed

lib/unification/Syntactic.mli

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,75 @@
11
module Stack : sig
2+
(** Stack of unification equations. *)
3+
24
type elt = Type.t * Type.t
5+
(** Unification equations are pairs of types. *)
6+
37
type t
8+
(** The type of stack. *)
49

510
val empty : t
11+
(** An empty stack. *)
12+
613
val is_empty : t -> bool
14+
(** [is_empty s] returns true if [s] is empty. *)
15+
716
val pop : t -> (elt * t) option
17+
(** [pop s] returns [None] if [s] is empty and [Some (eq, tl)] where [eq] is
18+
the last pushed equation on the stack and [tl] is the rest of the stack.
19+
*)
20+
821
val push : t -> Type.t -> Type.t -> t
22+
(** [push s t1 t2] returns a stack where the equation [(t1, t2)] is added at the
23+
top of [s].
24+
*)
25+
926
val push_array2 : t -> Type.t array -> Type.t array -> t
27+
(** [push_array2 s a1 a2] zip [a1] and [a2] to make equatins and push them on
28+
top of [s].
29+
@raise Invalid_argument if [a1] and [a2] do not have the same length.
30+
*)
31+
1032
val of_list : elt list -> t
33+
(** Convert a list of equation into a stack. *)
34+
1135
val pp : t Fmt.t [@@warning "-32"] [@@ocaml.toplevel_printer]
36+
(** Pretty printer *)
1237
end
1338

1439
type return = Done | FailUnif of Type.t * Type.t | FailedOccurCheck of Env.t
40+
(** The type representing the result of the unification procedure.
41+
[Done] means that the unification succed
42+
[FailUnif (t1, t2)] means that the unification failed because of the equality [(t1, t2)]
43+
[FailedOccurCheck] means that the unification failed because there is a non
44+
solvable cycle in the environnement.
45+
*)
1546

1647
module Infix : sig
1748
val ( let* ) : return -> ( unit -> return ) -> return
1849
end
1950

20-
val ( let* ) : return -> ( unit -> return ) -> return
51+
include module type of Infix
2152

2253
val occur_check : Env.t -> return
54+
(** [occur_check env] checks if the substitution defined by [env] contains cycle.
55+
Because of collapses, if [env] contains cycles, [occur_check] tries to collapse them
56+
to make [env] cycle free.
57+
*)
2358

2459
val process_stack : Env.t -> Stack.t -> return
60+
(** [process_stack env s] given an unification environment [env] and a stack [s]
61+
of unification equations, processes each equations.
62+
*)
2563

2664
val insert : Env.t -> Type.t -> Type.t -> return
65+
(** [insert env t1 t2] process the unification equation [t1 ≡ t2]. *)
2766

2867
val insert_var : Env.t -> Variable.t -> Type.t -> return
68+
(** [insert_var env v t] process the unification equation [v ≡ t]. *)
2969

3070
val attach : Env.t -> Variable.t -> Type.t -> return
71+
(** [attach env v t] modify the substitution represented by [env] by associating
72+
[t] to [v].
73+
*)
3174

3275
val debug : ((('a, Format.formatter, unit, string) format4 -> 'a) -> string) -> unit

0 commit comments

Comments
 (0)