Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 77 lines (54 sloc) 1.946 kb
fccc685 Initial open-source release
MLstate authored
1 (*
2 Copyright © 2011 MLstate
3
4 This file is part of OPA.
5
6 OPA is free software: you can redistribute it and/or modify it under the
7 terms of the GNU Affero General Public License, version 3, as published by
8 the Free Software Foundation.
9
10 OPA is distributed in the hope that it will be useful, but WITHOUT ANY
11 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
13 more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with OPA. If not, see <http://www.gnu.org/licenses/>.
17 *)
18 (**
19 Management of imperative scope
20 @author Mathieu Barbin
21 @author Vincent Benayoun
22 *)
23
24
25 module type IMPERATIVE_SCOPE =
26 sig
27 (**
28 The mutable type of the instance
29 *)
30 type 'a t
31
32 type elt
33
34 (** create a new structure given a size for blocks *)
35 val create : int -> 'a t
36
37 (** reset the structure to its initial state *)
38 val reset : 'a t -> unit
39
40 (** push a new block *)
41 val push : 'a t -> unit
42
43 (** pop the top block *)
44 val pop : 'a t -> unit
45
46 (** fold the top block *)
47 val fold : (elt -> 'a -> 'acc -> 'acc) -> 'a t -> 'acc -> 'acc
48
49 (** bind the elt to 'a in the top block *)
50 val bind : 'a t -> elt -> 'a -> unit
51
52 (** unbind the elt from the top block *)
53 val unbind : 'a t -> elt -> unit
54
55 (** find the first binded data to the elt (top down) *)
56 val find_opt : 'a t -> elt -> 'a option
57
58 end
59
60
61 module type ARG =
62 sig
63 type elt
64 type 'a block
65
66 val create : int -> 'a block
67 val fold : (elt -> 'a -> 'acc -> 'acc) -> 'a block -> 'acc -> 'acc
68 val bind : 'a block -> elt -> 'a -> unit
69 val unbind : 'a block -> elt -> unit
70 val find_opt : 'a block -> elt -> 'a option
71 end
72
73
74 module Make ( Arg : ARG ) : IMPERATIVE_SCOPE with type elt = Arg.elt
75
76 module Default (Arg : sig type elt end) : IMPERATIVE_SCOPE with type elt = Arg.elt
Something went wrong with that request. Please try again.