Evaluate `val' and `var' bindings in the environment in which they were defined
[hcoop/domtool2.git] / src / env.sig
CommitLineData
492c1cff
AC
1(* HCoop Domtool (http://hcoop.sourceforge.net/)
2 * Copyright (c) 2006, Adam Chlipala
e140629f 3 * Copyright (c) 2014 Clinton Ebadi <clinton@unknownlamer.org>
492c1cff
AC
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
dac62e84 18 *)
492c1cff
AC
19
20(* Domtool type-checking and reduction environments *)
21
22signature ENV = sig
23
a3698041
AC
24 type typeRule = Ast.exp -> bool
25 val registerType : string * typeRule -> unit
26 val typeRule : string -> typeRule option
27
28 type env_vars = Ast.exp Ast.StringMap.map
29 type action = env_vars * Ast.exp list -> env_vars
30 val registerAction : string * action -> unit
31 val action : string -> action option
32
33 val registerContainer : string * action * (unit -> unit) -> unit
34 val container : string -> (action * (unit -> unit)) option
35
e0b0abd2
AC
36 (* Actions to take before and after evaluating a file *)
37 val registerPre : (unit -> unit) -> unit
38 val pre : unit -> unit
39 val registerPost : (unit -> unit) -> unit
40 val post : unit -> unit
41
12adf55a
AC
42 (* ...and before type-checking *)
43 val registerPreTycheck : (unit -> unit) -> unit
44 val preTycheck : unit -> unit
45
629a34f6
AC
46 val badArgs : string * Ast.exp list -> 'a
47 val badArg : string * string * Ast.exp -> 'a
48
49 type 'a arg = Ast.exp -> 'a option
50
51 val int : int arg
52 val string : string arg
8a7c40fa 53 val bool : bool arg
629a34f6
AC
54 val list : 'a arg -> 'a list arg
55
ed9fda3a 56 val none : string -> (unit -> unit) -> action
629a34f6
AC
57 val one : string -> string * 'a arg -> ('a -> unit) -> action
58 val two : string -> string * 'a arg * string * 'b arg -> ('a * 'b -> unit) -> action
f8dfbbcc
AC
59 val three : string
60 -> string * 'a arg * string * 'b arg * string * 'c arg
61 -> ('a * 'b * 'c -> unit) -> action
629a34f6 62
57e066bb 63 val noneV : string -> (env_vars -> unit) -> action
6ae327f8 64 val oneV : string -> string * 'a arg -> (env_vars * 'a -> unit) -> action
e0b0abd2 65 val twoV : string -> string * 'a arg * string * 'b arg -> (env_vars * 'a * 'b -> unit) -> action
6ae327f8
AC
66
67 val env : 'a arg -> env_vars * string -> 'a
68
629a34f6
AC
69 val type_one : string -> 'a arg -> ('a -> bool) -> unit
70
ed9fda3a 71 val action_none : string -> (unit -> unit) -> unit
629a34f6
AC
72 val action_one : string -> string * 'a arg -> ('a -> unit) -> unit
73 val action_two : string -> string * 'a arg * string * 'b arg -> ('a * 'b -> unit) -> unit
f8dfbbcc
AC
74 val action_three : string
75 -> string * 'a arg * string * 'b arg * string * 'c arg
76 -> ('a * 'b * 'c -> unit) -> unit
fb09779a
AC
77 val action_four : string
78 -> string * 'a arg * string * 'b arg * string * 'c arg * string * 'd arg
79 -> ('a * 'b * 'c * 'd -> unit) -> unit
629a34f6 80
e0b0abd2 81 val actionV_none : string -> (env_vars -> unit) -> unit
6ae327f8 82 val actionV_one : string -> string * 'a arg -> (env_vars * 'a -> unit) -> unit
e0b0abd2 83 val actionV_two : string -> string * 'a arg * string * 'b arg -> (env_vars * 'a * 'b -> unit) -> unit
6ae327f8
AC
84
85 val container_none : string -> (unit -> unit) * (unit -> unit) -> unit
629a34f6 86 val container_one : string -> string * 'a arg -> ('a -> unit) * (unit -> unit) -> unit
6be996d4 87
57e066bb 88 val containerV_none : string -> (env_vars -> unit) * (unit -> unit) -> unit
6ae327f8
AC
89 val containerV_one : string -> string * 'a arg -> (env_vars * 'a -> unit) * (unit -> unit) -> unit
90
cf879b4f
AC
91 val registerFunction : string * (Ast.exp list -> Ast.exp option) -> unit
92 val function : string -> (Ast.exp list -> Ast.exp option) option
93
492c1cff
AC
94 type env
95 val empty : env
96
e140629f 97 val initialDynEnvTypes : env -> Ast.typ Ast.StringMap.map
254d5faa 98 val initialDynEnvVals : (env -> Ast.exp -> Ast.exp) -> env -> env_vars
e140629f 99
492c1cff
AC
100 val bindType : env -> string -> env
101 val bindVal : env -> string * Ast.typ * Ast.exp option -> env
095de39e 102 val bindContext : env -> string -> env
e140629f 103 val bindInitialDynEnvVal : env -> string * Ast.typ * Ast.exp -> env
492c1cff
AC
104
105 val lookupType : env -> string -> bool
106 val lookupVal : env -> string -> Ast.typ option
8061fadf 107 val lookupEquation : env -> string -> (Ast.exp * env) option
095de39e 108 val lookupContext : env -> string -> bool
e140629f 109 val lookupInitialDynEnvVal : env -> string -> Ast.typ option
492c1cff 110
095de39e
AC
111 val types : env -> Ast.StringSet.set
112 val vals : env -> Ast.StringSet.set
113 val contexts : env -> Ast.StringSet.set
e140629f 114 val dynamics : env -> Ast.StringSet.set
492c1cff 115end