annotate src/elab_util.sig @ 2201:1091227f535a

Unnest properly in presence of kind polymorphism
author Adam Chlipala <adam@chlipala.net>
date Sun, 20 Dec 2015 13:41:35 -0500
parents d28adceef22a
children
rev   line source
adam@1732 1 (* Copyright (c) 2008-2010, 2012, 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
adam@1303 32 val mliftConInCon : (int -> Elab.con -> Elab.con) ref
adam@1303 33
adamc@2 34 structure Kind : sig
adamc@623 35 val mapfoldB : {kind : ('context, Elab.kind', 'state, 'abort) Search.mapfolderB,
adamc@623 36 bind : 'context * string -> 'context}
adamc@623 37 -> ('context, Elab.kind, 'state, 'abort) Search.mapfolderB
adamc@6 38 val mapfold : (Elab.kind', 'state, 'abort) Search.mapfolder
adamc@2 39 -> (Elab.kind, 'state, 'abort) Search.mapfolder
adamc@2 40 val exists : (Elab.kind' -> bool) -> Elab.kind -> bool
adamc@623 41 val mapB : {kind : 'context -> Elab.kind' -> Elab.kind',
adamc@623 42 bind : 'context * string -> 'context}
adamc@623 43 -> 'context -> (Elab.kind -> Elab.kind)
adam@2201 44 val foldB : {kind : 'context * Elab.kind' * 'state -> 'state,
adam@2201 45 bind : 'context * string -> 'context}
adam@2201 46 -> 'context -> 'state -> Elab.kind -> 'state
adamc@2 47 end
adamc@2 48
adamc@6 49 structure Con : sig
adamc@11 50 datatype binder =
adamc@623 51 RelK of string
adamc@623 52 | RelC of string * Elab.kind
adamc@792 53 | NamedC of string * int * Elab.kind * Elab.con option
adamc@11 54
adamc@623 55 val mapfoldB : {kind : ('context, Elab.kind', 'state, 'abort) Search.mapfolderB,
adamc@11 56 con : ('context, Elab.con', 'state, 'abort) Search.mapfolderB,
adamc@11 57 bind : 'context * binder -> 'context}
adamc@11 58 -> ('context, Elab.con, 'state, 'abort) Search.mapfolderB
adamc@6 59 val mapfold : {kind : (Elab.kind', 'state, 'abort) Search.mapfolder,
adamc@10 60 con : (Elab.con', 'state, 'abort) Search.mapfolder}
adamc@6 61 -> (Elab.con, 'state, 'abort) Search.mapfolder
adamc@11 62
adamc@623 63 val mapB : {kind : 'context -> Elab.kind' -> Elab.kind',
adamc@11 64 con : 'context -> Elab.con' -> Elab.con',
adamc@11 65 bind : 'context * binder -> 'context}
adamc@11 66 -> 'context -> (Elab.con -> Elab.con)
adamc@34 67 val map : {kind : Elab.kind' -> Elab.kind',
adamc@34 68 con : Elab.con' -> Elab.con'}
adamc@34 69 -> Elab.con -> Elab.con
adam@1639 70 val appB : {kind : 'context -> Elab.kind' -> unit,
adam@1639 71 con : 'context -> Elab.con' -> unit,
adam@1639 72 bind : 'context * binder -> 'context}
adam@1639 73 -> 'context -> (Elab.con -> unit)
adam@1639 74 val app : {kind : Elab.kind' -> unit,
adam@1639 75 con : Elab.con' -> unit}
adam@1639 76 -> Elab.con -> unit
adamc@711 77 val existsB : {kind : 'context * Elab.kind' -> bool,
adamc@711 78 con : 'context * Elab.con' -> bool,
adamc@711 79 bind : 'context * binder -> 'context}
adamc@711 80 -> 'context -> Elab.con -> bool
adamc@6 81 val exists : {kind : Elab.kind' -> bool,
adamc@6 82 con : Elab.con' -> bool} -> Elab.con -> bool
adamc@448 83
adamc@623 84 val foldB : {kind : 'context * Elab.kind' * 'state -> 'state,
adamc@448 85 con : 'context * Elab.con' * 'state -> 'state,
adamc@448 86 bind : 'context * binder -> 'context}
adamc@448 87 -> 'context -> 'state -> Elab.con -> 'state
adamc@839 88 val fold : {kind : Elab.kind' * 'state -> 'state,
adamc@839 89 con : Elab.con' * 'state -> 'state}
adamc@839 90 -> 'state -> Elab.con -> 'state
adamc@6 91 end
adamc@6 92
adamc@10 93 structure Exp : sig
adamc@11 94 datatype binder =
adamc@623 95 RelK of string
adamc@623 96 | RelC of string * Elab.kind
adamc@792 97 | NamedC of string * int * Elab.kind * Elab.con option
adamc@11 98 | RelE of string * Elab.con
adamc@11 99 | NamedE of string * Elab.con
adamc@11 100
adamc@623 101 val mapfoldB : {kind : ('context, Elab.kind', 'state, 'abort) Search.mapfolderB,
adamc@11 102 con : ('context, Elab.con', 'state, 'abort) Search.mapfolderB,
adamc@11 103 exp : ('context, Elab.exp', 'state, 'abort) Search.mapfolderB,
adamc@11 104 bind : 'context * binder -> 'context}
adamc@11 105 -> ('context, Elab.exp, 'state, 'abort) Search.mapfolderB
adamc@10 106 val mapfold : {kind : (Elab.kind', 'state, 'abort) Search.mapfolder,
adamc@10 107 con : (Elab.con', 'state, 'abort) Search.mapfolder,
adamc@10 108 exp : (Elab.exp', 'state, 'abort) Search.mapfolder}
adamc@10 109 -> (Elab.exp, 'state, 'abort) Search.mapfolder
adamc@623 110 val mapB : {kind : 'context -> Elab.kind' -> Elab.kind',
adamc@211 111 con : 'context -> Elab.con' -> Elab.con',
adamc@211 112 exp : 'context -> Elab.exp' -> Elab.exp',
adamc@211 113 bind : 'context * binder -> 'context}
adamc@211 114 -> 'context -> (Elab.exp -> Elab.exp)
adamc@10 115 val exists : {kind : Elab.kind' -> bool,
adamc@10 116 con : Elab.con' -> bool,
adamc@10 117 exp : Elab.exp' -> bool} -> Elab.exp -> bool
adam@1795 118 val existsB : {kind : 'context * Elab.kind' -> bool,
adam@1795 119 con : 'context * Elab.con' -> bool,
adam@1795 120 exp : 'context * Elab.exp' -> bool,
adam@1795 121 bind : 'context * binder -> 'context}
adam@1795 122 -> 'context -> Elab.exp -> bool
adamc@448 123
adamc@623 124 val foldB : {kind : 'context * Elab.kind' * 'state -> 'state,
adamc@448 125 con : 'context * Elab.con' * 'state -> 'state,
adamc@448 126 exp : 'context * Elab.exp' * 'state -> 'state,
adamc@448 127 bind : 'context * binder -> 'context}
adamc@448 128 -> 'context -> 'state -> Elab.exp -> 'state
adamc@10 129 end
adamc@10 130
adamc@34 131 structure Sgn : sig
adamc@34 132 datatype binder =
adamc@623 133 RelK of string
adamc@623 134 | RelC of string * Elab.kind
adamc@792 135 | NamedC of string * int * Elab.kind * Elab.con option
adamc@792 136 | Str of string * int * Elab.sgn
adamc@792 137 | Sgn of string * int * Elab.sgn
adamc@34 138
adamc@623 139 val mapfoldB : {kind : ('context, Elab.kind', 'state, 'abort) Search.mapfolderB,
adamc@34 140 con : ('context, Elab.con', 'state, 'abort) Search.mapfolderB,
adamc@34 141 sgn_item : ('context, Elab.sgn_item', 'state, 'abort) Search.mapfolderB,
adamc@34 142 sgn : ('context, Elab.sgn', 'state, 'abort) Search.mapfolderB,
adamc@34 143 bind : 'context * binder -> 'context}
adamc@34 144 -> ('context, Elab.sgn, 'state, 'abort) Search.mapfolderB
adamc@34 145
adamc@34 146
adamc@34 147 val mapfold : {kind : (Elab.kind', 'state, 'abort) Search.mapfolder,
adamc@34 148 con : (Elab.con', 'state, 'abort) Search.mapfolder,
adamc@34 149 sgn_item : (Elab.sgn_item', 'state, 'abort) Search.mapfolder,
adamc@34 150 sgn : (Elab.sgn', 'state, 'abort) Search.mapfolder}
adamc@34 151 -> (Elab.sgn, 'state, 'abort) Search.mapfolder
adamc@34 152
adamc@34 153 val map : {kind : Elab.kind' -> Elab.kind',
adamc@34 154 con : Elab.con' -> Elab.con',
adamc@34 155 sgn_item : Elab.sgn_item' -> Elab.sgn_item',
adamc@34 156 sgn : Elab.sgn' -> Elab.sgn'}
adamc@34 157 -> Elab.sgn -> Elab.sgn
adamc@34 158
adamc@792 159 val mapB : {kind : 'context -> Elab.kind' -> Elab.kind',
adamc@792 160 con : 'context -> Elab.con' -> Elab.con',
adamc@792 161 sgn_item : 'context -> Elab.sgn_item' -> Elab.sgn_item',
adamc@792 162 sgn : 'context -> Elab.sgn' -> Elab.sgn',
adamc@792 163 bind : 'context * binder -> 'context}
adamc@792 164 -> 'context -> Elab.sgn -> Elab.sgn
adamc@792 165
adamc@2 166 end
adamc@34 167
adamc@76 168 structure Decl : sig
adamc@76 169 datatype binder =
adamc@623 170 RelK of string
adamc@623 171 | RelC of string * Elab.kind
adamc@792 172 | NamedC of string * int * Elab.kind * Elab.con option
adamc@76 173 | RelE of string * Elab.con
adamc@76 174 | NamedE of string * Elab.con
adam@1345 175 | Str of string * int * Elab.sgn
adam@1345 176 | Sgn of string * int * Elab.sgn
adamc@76 177
adamc@623 178 val mapfoldB : {kind : ('context, Elab.kind', 'state, 'abort) Search.mapfolderB,
adamc@76 179 con : ('context, Elab.con', 'state, 'abort) Search.mapfolderB,
adamc@76 180 exp : ('context, Elab.exp', 'state, 'abort) Search.mapfolderB,
adamc@76 181 sgn_item : ('context, Elab.sgn_item', 'state, 'abort) Search.mapfolderB,
adamc@76 182 sgn : ('context, Elab.sgn', 'state, 'abort) Search.mapfolderB,
adamc@76 183 str : ('context, Elab.str', 'state, 'abort) Search.mapfolderB,
adamc@76 184 decl : ('context, Elab.decl', 'state, 'abort) Search.mapfolderB,
adamc@76 185 bind : 'context * binder -> 'context}
adamc@76 186 -> ('context, Elab.decl, 'state, 'abort) Search.mapfolderB
adamc@76 187 val mapfold : {kind : (Elab.kind', 'state, 'abort) Search.mapfolder,
adamc@76 188 con : (Elab.con', 'state, 'abort) Search.mapfolder,
adamc@76 189 exp : (Elab.exp', 'state, 'abort) Search.mapfolder,
adamc@76 190 sgn_item : (Elab.sgn_item', 'state, 'abort) Search.mapfolder,
adamc@76 191 sgn : (Elab.sgn', 'state, 'abort) Search.mapfolder,
adamc@76 192 str : (Elab.str', 'state, 'abort) Search.mapfolder,
adamc@76 193 decl : (Elab.decl', 'state, 'abort) Search.mapfolder}
adamc@76 194 -> (Elab.decl, 'state, 'abort) Search.mapfolder
adamc@76 195 val exists : {kind : Elab.kind' -> bool,
adamc@76 196 con : Elab.con' -> bool,
adamc@76 197 exp : Elab.exp' -> bool,
adamc@76 198 sgn_item : Elab.sgn_item' -> bool,
adamc@76 199 sgn : Elab.sgn' -> bool,
adamc@76 200 str : Elab.str' -> bool,
adamc@76 201 decl : Elab.decl' -> bool}
adamc@76 202 -> Elab.decl -> bool
adamc@76 203 val search : {kind : Elab.kind' -> 'a option,
adamc@76 204 con : Elab.con' -> 'a option,
adamc@76 205 exp : Elab.exp' -> 'a option,
adamc@76 206 sgn_item : Elab.sgn_item' -> 'a option,
adamc@76 207 sgn : Elab.sgn' -> 'a option,
adamc@76 208 str : Elab.str' -> 'a option,
adamc@76 209 decl : Elab.decl' -> 'a option}
adamc@76 210 -> Elab.decl -> 'a option
adamc@448 211
adamc@623 212 val foldMapB : {kind : 'context * Elab.kind' * 'state -> Elab.kind' * 'state,
adamc@448 213 con : 'context * Elab.con' * 'state -> Elab.con' * 'state,
adamc@448 214 exp : 'context * Elab.exp' * 'state -> Elab.exp' * 'state,
adamc@448 215 sgn_item : 'context * Elab.sgn_item' * 'state -> Elab.sgn_item' * 'state,
adamc@448 216 sgn : 'context * Elab.sgn' * 'state -> Elab.sgn' * 'state,
adamc@448 217 str : 'context * Elab.str' * 'state -> Elab.str' * 'state,
adamc@448 218 decl : 'context * Elab.decl' * 'state -> Elab.decl' * 'state,
adamc@448 219 bind : 'context * binder -> 'context}
adamc@448 220 -> 'context -> 'state -> Elab.decl -> Elab.decl * 'state
adam@1345 221
adam@1345 222 val map : {kind : Elab.kind' -> Elab.kind',
adam@1345 223 con : Elab.con' -> Elab.con',
adam@1345 224 exp : Elab.exp' -> Elab.exp',
adam@1345 225 sgn_item : Elab.sgn_item' -> Elab.sgn_item',
adam@1345 226 sgn : Elab.sgn' -> Elab.sgn',
adam@1345 227 str : Elab.str' -> Elab.str',
adam@1345 228 decl : Elab.decl' -> Elab.decl'}
adam@1345 229 -> Elab.decl -> Elab.decl
adam@1345 230
adam@1345 231 val mapB : {kind : 'context -> Elab.kind' -> Elab.kind',
adam@1345 232 con : 'context -> Elab.con' -> Elab.con',
adam@1345 233 exp : 'context -> Elab.exp' -> Elab.exp',
adam@1345 234 sgn_item : 'context -> Elab.sgn_item' -> Elab.sgn_item',
adam@1345 235 sgn : 'context -> Elab.sgn' -> Elab.sgn',
adam@1345 236 str : 'context -> Elab.str' -> Elab.str',
adam@1345 237 decl : 'context -> Elab.decl' -> Elab.decl',
adam@1345 238 bind : 'context * binder -> 'context}
adam@1345 239 -> 'context -> Elab.decl -> Elab.decl
adam@1732 240
adam@1732 241 val fold : {kind : Elab.kind' * 'state -> 'state,
adam@1732 242 con : Elab.con' * 'state -> 'state,
adam@1732 243 exp : Elab.exp' * 'state -> 'state,
adam@1732 244 sgn_item : Elab.sgn_item' * 'state -> 'state,
adam@1732 245 sgn : Elab.sgn' * 'state -> 'state,
adam@1732 246 str : Elab.str' * 'state -> 'state,
adam@1732 247 decl : Elab.decl' * 'state -> 'state}
adam@1732 248 -> 'state -> Elab.decl -> 'state
adamc@448 249 end
adamc@448 250
adamc@448 251 structure File : sig
adamc@448 252 val maxName : Elab.file -> int
adam@1584 253
adam@1584 254 val findDecl : (Elab.decl -> bool) -> Elab.file -> Elab.decl option
adamc@34 255 end
adamc@76 256
adamc@76 257 end