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@6
|
33 val mapfold : (Elab.kind', 'state, 'abort) Search.mapfolder
|
adamc@2
|
34 -> (Elab.kind, 'state, 'abort) Search.mapfolder
|
adamc@2
|
35 val exists : (Elab.kind' -> bool) -> Elab.kind -> bool
|
adamc@2
|
36 end
|
adamc@2
|
37
|
adamc@6
|
38 structure Con : sig
|
adamc@11
|
39 datatype binder =
|
adamc@11
|
40 Rel of string * Elab.kind
|
adamc@329
|
41 | Named of string * int * Elab.kind
|
adamc@11
|
42
|
adamc@11
|
43 val mapfoldB : {kind : (Elab.kind', 'state, 'abort) Search.mapfolder,
|
adamc@11
|
44 con : ('context, Elab.con', 'state, 'abort) Search.mapfolderB,
|
adamc@11
|
45 bind : 'context * binder -> 'context}
|
adamc@11
|
46 -> ('context, Elab.con, 'state, 'abort) Search.mapfolderB
|
adamc@6
|
47 val mapfold : {kind : (Elab.kind', 'state, 'abort) Search.mapfolder,
|
adamc@10
|
48 con : (Elab.con', 'state, 'abort) Search.mapfolder}
|
adamc@6
|
49 -> (Elab.con, 'state, 'abort) Search.mapfolder
|
adamc@11
|
50
|
adamc@11
|
51 val mapB : {kind : Elab.kind' -> Elab.kind',
|
adamc@11
|
52 con : 'context -> Elab.con' -> Elab.con',
|
adamc@11
|
53 bind : 'context * binder -> 'context}
|
adamc@11
|
54 -> 'context -> (Elab.con -> Elab.con)
|
adamc@34
|
55 val map : {kind : Elab.kind' -> Elab.kind',
|
adamc@34
|
56 con : Elab.con' -> Elab.con'}
|
adamc@34
|
57 -> Elab.con -> Elab.con
|
adamc@6
|
58 val exists : {kind : Elab.kind' -> bool,
|
adamc@6
|
59 con : Elab.con' -> bool} -> Elab.con -> bool
|
adamc@448
|
60
|
adamc@448
|
61 val foldB : {kind : Elab.kind' * 'state -> 'state,
|
adamc@448
|
62 con : 'context * Elab.con' * 'state -> 'state,
|
adamc@448
|
63 bind : 'context * binder -> 'context}
|
adamc@448
|
64 -> 'context -> 'state -> Elab.con -> 'state
|
adamc@6
|
65 end
|
adamc@6
|
66
|
adamc@10
|
67 structure Exp : sig
|
adamc@11
|
68 datatype binder =
|
adamc@11
|
69 RelC of string * Elab.kind
|
adamc@329
|
70 | NamedC of string * int * Elab.kind
|
adamc@11
|
71 | RelE of string * Elab.con
|
adamc@11
|
72 | NamedE of string * Elab.con
|
adamc@11
|
73
|
adamc@11
|
74 val mapfoldB : {kind : (Elab.kind', 'state, 'abort) Search.mapfolder,
|
adamc@11
|
75 con : ('context, Elab.con', 'state, 'abort) Search.mapfolderB,
|
adamc@11
|
76 exp : ('context, Elab.exp', 'state, 'abort) Search.mapfolderB,
|
adamc@11
|
77 bind : 'context * binder -> 'context}
|
adamc@11
|
78 -> ('context, Elab.exp, 'state, 'abort) Search.mapfolderB
|
adamc@10
|
79 val mapfold : {kind : (Elab.kind', 'state, 'abort) Search.mapfolder,
|
adamc@10
|
80 con : (Elab.con', 'state, 'abort) Search.mapfolder,
|
adamc@10
|
81 exp : (Elab.exp', 'state, 'abort) Search.mapfolder}
|
adamc@10
|
82 -> (Elab.exp, 'state, 'abort) Search.mapfolder
|
adamc@211
|
83 val mapB : {kind : Elab.kind' -> Elab.kind',
|
adamc@211
|
84 con : 'context -> Elab.con' -> Elab.con',
|
adamc@211
|
85 exp : 'context -> Elab.exp' -> Elab.exp',
|
adamc@211
|
86 bind : 'context * binder -> 'context}
|
adamc@211
|
87 -> 'context -> (Elab.exp -> Elab.exp)
|
adamc@10
|
88 val exists : {kind : Elab.kind' -> bool,
|
adamc@10
|
89 con : Elab.con' -> bool,
|
adamc@10
|
90 exp : Elab.exp' -> bool} -> Elab.exp -> bool
|
adamc@448
|
91
|
adamc@448
|
92 val foldB : {kind : Elab.kind' * 'state -> 'state,
|
adamc@448
|
93 con : 'context * Elab.con' * 'state -> 'state,
|
adamc@448
|
94 exp : 'context * Elab.exp' * 'state -> 'state,
|
adamc@448
|
95 bind : 'context * binder -> 'context}
|
adamc@448
|
96 -> 'context -> 'state -> Elab.exp -> 'state
|
adamc@10
|
97 end
|
adamc@10
|
98
|
adamc@34
|
99 structure Sgn : sig
|
adamc@34
|
100 datatype binder =
|
adamc@34
|
101 RelC of string * Elab.kind
|
adamc@329
|
102 | NamedC of string * int * Elab.kind
|
adamc@34
|
103 | Str of string * Elab.sgn
|
adamc@59
|
104 | Sgn of string * Elab.sgn
|
adamc@34
|
105
|
adamc@34
|
106 val mapfoldB : {kind : (Elab.kind', 'state, 'abort) Search.mapfolder,
|
adamc@34
|
107 con : ('context, Elab.con', 'state, 'abort) Search.mapfolderB,
|
adamc@34
|
108 sgn_item : ('context, Elab.sgn_item', 'state, 'abort) Search.mapfolderB,
|
adamc@34
|
109 sgn : ('context, Elab.sgn', 'state, 'abort) Search.mapfolderB,
|
adamc@34
|
110 bind : 'context * binder -> 'context}
|
adamc@34
|
111 -> ('context, Elab.sgn, 'state, 'abort) Search.mapfolderB
|
adamc@34
|
112
|
adamc@34
|
113
|
adamc@34
|
114 val mapfold : {kind : (Elab.kind', 'state, 'abort) Search.mapfolder,
|
adamc@34
|
115 con : (Elab.con', 'state, 'abort) Search.mapfolder,
|
adamc@34
|
116 sgn_item : (Elab.sgn_item', 'state, 'abort) Search.mapfolder,
|
adamc@34
|
117 sgn : (Elab.sgn', 'state, 'abort) Search.mapfolder}
|
adamc@34
|
118 -> (Elab.sgn, 'state, 'abort) Search.mapfolder
|
adamc@34
|
119
|
adamc@34
|
120 val map : {kind : Elab.kind' -> Elab.kind',
|
adamc@34
|
121 con : Elab.con' -> Elab.con',
|
adamc@34
|
122 sgn_item : Elab.sgn_item' -> Elab.sgn_item',
|
adamc@34
|
123 sgn : Elab.sgn' -> Elab.sgn'}
|
adamc@34
|
124 -> Elab.sgn -> Elab.sgn
|
adamc@34
|
125
|
adamc@2
|
126 end
|
adamc@34
|
127
|
adamc@76
|
128 structure Decl : sig
|
adamc@76
|
129 datatype binder =
|
adamc@76
|
130 RelC of string * Elab.kind
|
adamc@329
|
131 | NamedC of string * int * Elab.kind
|
adamc@76
|
132 | RelE of string * Elab.con
|
adamc@76
|
133 | NamedE of string * Elab.con
|
adamc@76
|
134 | Str of string * Elab.sgn
|
adamc@76
|
135 | Sgn of string * Elab.sgn
|
adamc@76
|
136
|
adamc@76
|
137 val mapfoldB : {kind : (Elab.kind', 'state, 'abort) Search.mapfolder,
|
adamc@76
|
138 con : ('context, Elab.con', 'state, 'abort) Search.mapfolderB,
|
adamc@76
|
139 exp : ('context, Elab.exp', 'state, 'abort) Search.mapfolderB,
|
adamc@76
|
140 sgn_item : ('context, Elab.sgn_item', 'state, 'abort) Search.mapfolderB,
|
adamc@76
|
141 sgn : ('context, Elab.sgn', 'state, 'abort) Search.mapfolderB,
|
adamc@76
|
142 str : ('context, Elab.str', 'state, 'abort) Search.mapfolderB,
|
adamc@76
|
143 decl : ('context, Elab.decl', 'state, 'abort) Search.mapfolderB,
|
adamc@76
|
144 bind : 'context * binder -> 'context}
|
adamc@76
|
145 -> ('context, Elab.decl, 'state, 'abort) Search.mapfolderB
|
adamc@76
|
146 val mapfold : {kind : (Elab.kind', 'state, 'abort) Search.mapfolder,
|
adamc@76
|
147 con : (Elab.con', 'state, 'abort) Search.mapfolder,
|
adamc@76
|
148 exp : (Elab.exp', 'state, 'abort) Search.mapfolder,
|
adamc@76
|
149 sgn_item : (Elab.sgn_item', 'state, 'abort) Search.mapfolder,
|
adamc@76
|
150 sgn : (Elab.sgn', 'state, 'abort) Search.mapfolder,
|
adamc@76
|
151 str : (Elab.str', 'state, 'abort) Search.mapfolder,
|
adamc@76
|
152 decl : (Elab.decl', 'state, 'abort) Search.mapfolder}
|
adamc@76
|
153 -> (Elab.decl, 'state, 'abort) Search.mapfolder
|
adamc@76
|
154 val exists : {kind : Elab.kind' -> bool,
|
adamc@76
|
155 con : Elab.con' -> bool,
|
adamc@76
|
156 exp : Elab.exp' -> bool,
|
adamc@76
|
157 sgn_item : Elab.sgn_item' -> bool,
|
adamc@76
|
158 sgn : Elab.sgn' -> bool,
|
adamc@76
|
159 str : Elab.str' -> bool,
|
adamc@76
|
160 decl : Elab.decl' -> bool}
|
adamc@76
|
161 -> Elab.decl -> bool
|
adamc@76
|
162 val search : {kind : Elab.kind' -> 'a option,
|
adamc@76
|
163 con : Elab.con' -> 'a option,
|
adamc@76
|
164 exp : Elab.exp' -> 'a option,
|
adamc@76
|
165 sgn_item : Elab.sgn_item' -> 'a option,
|
adamc@76
|
166 sgn : Elab.sgn' -> 'a option,
|
adamc@76
|
167 str : Elab.str' -> 'a option,
|
adamc@76
|
168 decl : Elab.decl' -> 'a option}
|
adamc@76
|
169 -> Elab.decl -> 'a option
|
adamc@448
|
170
|
adamc@448
|
171 val foldMapB : {kind : Elab.kind' * 'state -> Elab.kind' * 'state,
|
adamc@448
|
172 con : 'context * Elab.con' * 'state -> Elab.con' * 'state,
|
adamc@448
|
173 exp : 'context * Elab.exp' * 'state -> Elab.exp' * 'state,
|
adamc@448
|
174 sgn_item : 'context * Elab.sgn_item' * 'state -> Elab.sgn_item' * 'state,
|
adamc@448
|
175 sgn : 'context * Elab.sgn' * 'state -> Elab.sgn' * 'state,
|
adamc@448
|
176 str : 'context * Elab.str' * 'state -> Elab.str' * 'state,
|
adamc@448
|
177 decl : 'context * Elab.decl' * 'state -> Elab.decl' * 'state,
|
adamc@448
|
178 bind : 'context * binder -> 'context}
|
adamc@448
|
179 -> 'context -> 'state -> Elab.decl -> Elab.decl * 'state
|
adamc@448
|
180 end
|
adamc@448
|
181
|
adamc@448
|
182 structure File : sig
|
adamc@448
|
183 val maxName : Elab.file -> int
|
adamc@34
|
184 end
|
adamc@76
|
185
|
adamc@76
|
186 end
|