adamc@2
|
1 (* Copyright (c) 2008, Adam Chlipala
|
adamc@2
|
2 * All rights reserved.
|
adamc@2
|
3 *
|
adamc@2
|
4 * Redistribution and use in source and binary forms, with or without
|
adamc@2
|
5 * modification, are permitted provided that the following conditions are met:
|
adamc@2
|
6 *
|
adamc@2
|
7 * - Redistributions of source code must retain the above copyright notice,
|
adamc@2
|
8 * this list of conditions and the following disclaimer.
|
adamc@2
|
9 * - Redistributions in binary form must reproduce the above copyright notice,
|
adamc@2
|
10 * this list of conditions and the following disclaimer in the documentation
|
adamc@2
|
11 * and/or other materials provided with the distribution.
|
adamc@2
|
12 * - The names of contributors may not be used to endorse or promote products
|
adamc@2
|
13 * derived from this software without specific prior written permission.
|
adamc@2
|
14 *
|
adamc@2
|
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
adamc@2
|
16 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
adamc@2
|
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
adamc@2
|
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
adamc@2
|
19 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
adamc@2
|
20 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
adamc@2
|
21 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
adamc@2
|
22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
adamc@2
|
23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
adamc@2
|
24 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
adamc@2
|
25 * POSSIBILITY OF SUCH DAMAGE.
|
adamc@2
|
26 *)
|
adamc@2
|
27
|
adamc@2
|
28 signature ELAB_UTIL = sig
|
adamc@2
|
29
|
adamc@198
|
30 val classifyDatatype : (string * int * 'a option) list -> Elab.datatype_kind
|
adamc@188
|
31
|
adamc@2
|
32 structure Kind : sig
|
adamc@623
|
33 val mapfoldB : {kind : ('context, Elab.kind', 'state, 'abort) Search.mapfolderB,
|
adamc@623
|
34 bind : 'context * string -> 'context}
|
adamc@623
|
35 -> ('context, Elab.kind, 'state, 'abort) Search.mapfolderB
|
adamc@6
|
36 val mapfold : (Elab.kind', 'state, 'abort) Search.mapfolder
|
adamc@2
|
37 -> (Elab.kind, 'state, 'abort) Search.mapfolder
|
adamc@2
|
38 val exists : (Elab.kind' -> bool) -> Elab.kind -> bool
|
adamc@623
|
39 val mapB : {kind : 'context -> Elab.kind' -> Elab.kind',
|
adamc@623
|
40 bind : 'context * string -> 'context}
|
adamc@623
|
41 -> 'context -> (Elab.kind -> Elab.kind)
|
adamc@2
|
42 end
|
adamc@2
|
43
|
adamc@6
|
44 structure Con : sig
|
adamc@11
|
45 datatype binder =
|
adamc@623
|
46 RelK of string
|
adamc@623
|
47 | RelC of string * Elab.kind
|
adamc@792
|
48 | NamedC of string * int * Elab.kind * Elab.con option
|
adamc@11
|
49
|
adamc@623
|
50 val mapfoldB : {kind : ('context, Elab.kind', 'state, 'abort) Search.mapfolderB,
|
adamc@11
|
51 con : ('context, Elab.con', 'state, 'abort) Search.mapfolderB,
|
adamc@11
|
52 bind : 'context * binder -> 'context}
|
adamc@11
|
53 -> ('context, Elab.con, 'state, 'abort) Search.mapfolderB
|
adamc@6
|
54 val mapfold : {kind : (Elab.kind', 'state, 'abort) Search.mapfolder,
|
adamc@10
|
55 con : (Elab.con', 'state, 'abort) Search.mapfolder}
|
adamc@6
|
56 -> (Elab.con, 'state, 'abort) Search.mapfolder
|
adamc@11
|
57
|
adamc@623
|
58 val mapB : {kind : 'context -> Elab.kind' -> Elab.kind',
|
adamc@11
|
59 con : 'context -> Elab.con' -> Elab.con',
|
adamc@11
|
60 bind : 'context * binder -> 'context}
|
adamc@11
|
61 -> 'context -> (Elab.con -> Elab.con)
|
adamc@34
|
62 val map : {kind : Elab.kind' -> Elab.kind',
|
adamc@34
|
63 con : Elab.con' -> Elab.con'}
|
adamc@34
|
64 -> Elab.con -> Elab.con
|
adamc@711
|
65 val existsB : {kind : 'context * Elab.kind' -> bool,
|
adamc@711
|
66 con : 'context * Elab.con' -> bool,
|
adamc@711
|
67 bind : 'context * binder -> 'context}
|
adamc@711
|
68 -> 'context -> Elab.con -> bool
|
adamc@6
|
69 val exists : {kind : Elab.kind' -> bool,
|
adamc@6
|
70 con : Elab.con' -> bool} -> Elab.con -> bool
|
adamc@448
|
71
|
adamc@623
|
72 val foldB : {kind : 'context * Elab.kind' * 'state -> 'state,
|
adamc@448
|
73 con : 'context * Elab.con' * 'state -> 'state,
|
adamc@448
|
74 bind : 'context * binder -> 'context}
|
adamc@448
|
75 -> 'context -> 'state -> Elab.con -> 'state
|
adamc@839
|
76 val fold : {kind : Elab.kind' * 'state -> 'state,
|
adamc@839
|
77 con : Elab.con' * 'state -> 'state}
|
adamc@839
|
78 -> 'state -> Elab.con -> 'state
|
adamc@6
|
79 end
|
adamc@6
|
80
|
adamc@10
|
81 structure Exp : sig
|
adamc@11
|
82 datatype binder =
|
adamc@623
|
83 RelK of string
|
adamc@623
|
84 | RelC of string * Elab.kind
|
adamc@792
|
85 | NamedC of string * int * Elab.kind * Elab.con option
|
adamc@11
|
86 | RelE of string * Elab.con
|
adamc@11
|
87 | NamedE of string * Elab.con
|
adamc@11
|
88
|
adamc@623
|
89 val mapfoldB : {kind : ('context, Elab.kind', 'state, 'abort) Search.mapfolderB,
|
adamc@11
|
90 con : ('context, Elab.con', 'state, 'abort) Search.mapfolderB,
|
adamc@11
|
91 exp : ('context, Elab.exp', 'state, 'abort) Search.mapfolderB,
|
adamc@11
|
92 bind : 'context * binder -> 'context}
|
adamc@11
|
93 -> ('context, Elab.exp, 'state, 'abort) Search.mapfolderB
|
adamc@10
|
94 val mapfold : {kind : (Elab.kind', 'state, 'abort) Search.mapfolder,
|
adamc@10
|
95 con : (Elab.con', 'state, 'abort) Search.mapfolder,
|
adamc@10
|
96 exp : (Elab.exp', 'state, 'abort) Search.mapfolder}
|
adamc@10
|
97 -> (Elab.exp, 'state, 'abort) Search.mapfolder
|
adamc@623
|
98 val mapB : {kind : 'context -> Elab.kind' -> Elab.kind',
|
adamc@211
|
99 con : 'context -> Elab.con' -> Elab.con',
|
adamc@211
|
100 exp : 'context -> Elab.exp' -> Elab.exp',
|
adamc@211
|
101 bind : 'context * binder -> 'context}
|
adamc@211
|
102 -> 'context -> (Elab.exp -> Elab.exp)
|
adamc@10
|
103 val exists : {kind : Elab.kind' -> bool,
|
adamc@10
|
104 con : Elab.con' -> bool,
|
adamc@10
|
105 exp : Elab.exp' -> bool} -> Elab.exp -> bool
|
adamc@448
|
106
|
adamc@623
|
107 val foldB : {kind : 'context * Elab.kind' * 'state -> 'state,
|
adamc@448
|
108 con : 'context * Elab.con' * 'state -> 'state,
|
adamc@448
|
109 exp : 'context * Elab.exp' * 'state -> 'state,
|
adamc@448
|
110 bind : 'context * binder -> 'context}
|
adamc@448
|
111 -> 'context -> 'state -> Elab.exp -> 'state
|
adamc@10
|
112 end
|
adamc@10
|
113
|
adamc@34
|
114 structure Sgn : sig
|
adamc@34
|
115 datatype binder =
|
adamc@623
|
116 RelK of string
|
adamc@623
|
117 | RelC of string * Elab.kind
|
adamc@792
|
118 | NamedC of string * int * Elab.kind * Elab.con option
|
adamc@792
|
119 | Str of string * int * Elab.sgn
|
adamc@792
|
120 | Sgn of string * int * Elab.sgn
|
adamc@34
|
121
|
adamc@623
|
122 val mapfoldB : {kind : ('context, Elab.kind', 'state, 'abort) Search.mapfolderB,
|
adamc@34
|
123 con : ('context, Elab.con', 'state, 'abort) Search.mapfolderB,
|
adamc@34
|
124 sgn_item : ('context, Elab.sgn_item', 'state, 'abort) Search.mapfolderB,
|
adamc@34
|
125 sgn : ('context, Elab.sgn', 'state, 'abort) Search.mapfolderB,
|
adamc@34
|
126 bind : 'context * binder -> 'context}
|
adamc@34
|
127 -> ('context, Elab.sgn, 'state, 'abort) Search.mapfolderB
|
adamc@34
|
128
|
adamc@34
|
129
|
adamc@34
|
130 val mapfold : {kind : (Elab.kind', 'state, 'abort) Search.mapfolder,
|
adamc@34
|
131 con : (Elab.con', 'state, 'abort) Search.mapfolder,
|
adamc@34
|
132 sgn_item : (Elab.sgn_item', 'state, 'abort) Search.mapfolder,
|
adamc@34
|
133 sgn : (Elab.sgn', 'state, 'abort) Search.mapfolder}
|
adamc@34
|
134 -> (Elab.sgn, 'state, 'abort) Search.mapfolder
|
adamc@34
|
135
|
adamc@34
|
136 val map : {kind : Elab.kind' -> Elab.kind',
|
adamc@34
|
137 con : Elab.con' -> Elab.con',
|
adamc@34
|
138 sgn_item : Elab.sgn_item' -> Elab.sgn_item',
|
adamc@34
|
139 sgn : Elab.sgn' -> Elab.sgn'}
|
adamc@34
|
140 -> Elab.sgn -> Elab.sgn
|
adamc@34
|
141
|
adamc@792
|
142 val mapB : {kind : 'context -> Elab.kind' -> Elab.kind',
|
adamc@792
|
143 con : 'context -> Elab.con' -> Elab.con',
|
adamc@792
|
144 sgn_item : 'context -> Elab.sgn_item' -> Elab.sgn_item',
|
adamc@792
|
145 sgn : 'context -> Elab.sgn' -> Elab.sgn',
|
adamc@792
|
146 bind : 'context * binder -> 'context}
|
adamc@792
|
147 -> 'context -> Elab.sgn -> Elab.sgn
|
adamc@792
|
148
|
adamc@2
|
149 end
|
adamc@34
|
150
|
adamc@76
|
151 structure Decl : sig
|
adamc@76
|
152 datatype binder =
|
adamc@623
|
153 RelK of string
|
adamc@623
|
154 | RelC of string * Elab.kind
|
adamc@792
|
155 | NamedC of string * int * Elab.kind * Elab.con option
|
adamc@76
|
156 | RelE of string * Elab.con
|
adamc@76
|
157 | NamedE of string * Elab.con
|
adamc@76
|
158 | Str of string * Elab.sgn
|
adamc@76
|
159 | Sgn of string * Elab.sgn
|
adamc@76
|
160
|
adamc@623
|
161 val mapfoldB : {kind : ('context, Elab.kind', 'state, 'abort) Search.mapfolderB,
|
adamc@76
|
162 con : ('context, Elab.con', 'state, 'abort) Search.mapfolderB,
|
adamc@76
|
163 exp : ('context, Elab.exp', 'state, 'abort) Search.mapfolderB,
|
adamc@76
|
164 sgn_item : ('context, Elab.sgn_item', 'state, 'abort) Search.mapfolderB,
|
adamc@76
|
165 sgn : ('context, Elab.sgn', 'state, 'abort) Search.mapfolderB,
|
adamc@76
|
166 str : ('context, Elab.str', 'state, 'abort) Search.mapfolderB,
|
adamc@76
|
167 decl : ('context, Elab.decl', 'state, 'abort) Search.mapfolderB,
|
adamc@76
|
168 bind : 'context * binder -> 'context}
|
adamc@76
|
169 -> ('context, Elab.decl, 'state, 'abort) Search.mapfolderB
|
adamc@76
|
170 val mapfold : {kind : (Elab.kind', 'state, 'abort) Search.mapfolder,
|
adamc@76
|
171 con : (Elab.con', 'state, 'abort) Search.mapfolder,
|
adamc@76
|
172 exp : (Elab.exp', 'state, 'abort) Search.mapfolder,
|
adamc@76
|
173 sgn_item : (Elab.sgn_item', 'state, 'abort) Search.mapfolder,
|
adamc@76
|
174 sgn : (Elab.sgn', 'state, 'abort) Search.mapfolder,
|
adamc@76
|
175 str : (Elab.str', 'state, 'abort) Search.mapfolder,
|
adamc@76
|
176 decl : (Elab.decl', 'state, 'abort) Search.mapfolder}
|
adamc@76
|
177 -> (Elab.decl, 'state, 'abort) Search.mapfolder
|
adamc@76
|
178 val exists : {kind : Elab.kind' -> bool,
|
adamc@76
|
179 con : Elab.con' -> bool,
|
adamc@76
|
180 exp : Elab.exp' -> bool,
|
adamc@76
|
181 sgn_item : Elab.sgn_item' -> bool,
|
adamc@76
|
182 sgn : Elab.sgn' -> bool,
|
adamc@76
|
183 str : Elab.str' -> bool,
|
adamc@76
|
184 decl : Elab.decl' -> bool}
|
adamc@76
|
185 -> Elab.decl -> bool
|
adamc@76
|
186 val search : {kind : Elab.kind' -> 'a option,
|
adamc@76
|
187 con : Elab.con' -> 'a option,
|
adamc@76
|
188 exp : Elab.exp' -> 'a option,
|
adamc@76
|
189 sgn_item : Elab.sgn_item' -> 'a option,
|
adamc@76
|
190 sgn : Elab.sgn' -> 'a option,
|
adamc@76
|
191 str : Elab.str' -> 'a option,
|
adamc@76
|
192 decl : Elab.decl' -> 'a option}
|
adamc@76
|
193 -> Elab.decl -> 'a option
|
adamc@448
|
194
|
adamc@623
|
195 val foldMapB : {kind : 'context * Elab.kind' * 'state -> Elab.kind' * 'state,
|
adamc@448
|
196 con : 'context * Elab.con' * 'state -> Elab.con' * 'state,
|
adamc@448
|
197 exp : 'context * Elab.exp' * 'state -> Elab.exp' * 'state,
|
adamc@448
|
198 sgn_item : 'context * Elab.sgn_item' * 'state -> Elab.sgn_item' * 'state,
|
adamc@448
|
199 sgn : 'context * Elab.sgn' * 'state -> Elab.sgn' * 'state,
|
adamc@448
|
200 str : 'context * Elab.str' * 'state -> Elab.str' * 'state,
|
adamc@448
|
201 decl : 'context * Elab.decl' * 'state -> Elab.decl' * 'state,
|
adamc@448
|
202 bind : 'context * binder -> 'context}
|
adamc@448
|
203 -> 'context -> 'state -> Elab.decl -> Elab.decl * 'state
|
adamc@448
|
204 end
|
adamc@448
|
205
|
adamc@448
|
206 structure File : sig
|
adamc@448
|
207 val maxName : Elab.file -> int
|
adamc@34
|
208 end
|
adamc@76
|
209
|
adamc@76
|
210 end
|