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