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