annotate src/core_util.sig @ 626:230654093b51

demo/hello compiles with kind polymorphism
author Adam Chlipala <adamc@hcoop.net>
date Sun, 22 Feb 2009 17:17:01 -0500
parents 3162bbf8e30f
children 54ec237a3028
rev   line source
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@193 31 val compare : Core.kind * Core.kind -> order
adamc@193 32
adamc@626 33 val mapfoldB : {kind : ('context, Core.kind', 'state, 'abort) Search.mapfolderB,
adamc@626 34 bind : 'context * string -> 'context}
adamc@626 35 -> ('context, Core.kind, 'state, 'abort) Search.mapfolderB
adamc@16 36 val mapfold : (Core.kind', 'state, 'abort) Search.mapfolder
adamc@16 37 -> (Core.kind, 'state, 'abort) Search.mapfolder
adamc@16 38 val map : (Core.kind' -> Core.kind') -> Core.kind -> Core.kind
adamc@16 39 val exists : (Core.kind' -> bool) -> Core.kind -> bool
adamc@626 40 val mapB : {kind : 'context -> Core.kind' -> Core.kind',
adamc@626 41 bind : 'context * string -> 'context}
adamc@626 42 -> 'context -> (Core.kind -> Core.kind)
adamc@16 43 end
adamc@16 44
adamc@16 45 structure Con : sig
adamc@193 46 val compare : Core.con * Core.con -> order
adamc@193 47
adamc@16 48 datatype binder =
adamc@626 49 RelK of string
adamc@626 50 | RelC of string * Core.kind
adamc@626 51 | NamedC of string * int * Core.kind * Core.con option
adamc@16 52
adamc@626 53 val mapfoldB : {kind : ('context, Core.kind', 'state, 'abort) Search.mapfolderB,
adamc@16 54 con : ('context, Core.con', 'state, 'abort) Search.mapfolderB,
adamc@16 55 bind : 'context * binder -> 'context}
adamc@16 56 -> ('context, Core.con, 'state, 'abort) Search.mapfolderB
adamc@16 57 val mapfold : {kind : (Core.kind', 'state, 'abort) Search.mapfolder,
adamc@16 58 con : (Core.con', 'state, 'abort) Search.mapfolder}
adamc@16 59 -> (Core.con, 'state, 'abort) Search.mapfolder
adamc@16 60
adamc@16 61 val map : {kind : Core.kind' -> Core.kind',
adamc@16 62 con : Core.con' -> Core.con'}
adamc@16 63 -> Core.con -> Core.con
adamc@16 64
adamc@626 65 val mapB : {kind : 'context -> Core.kind' -> Core.kind',
adamc@16 66 con : 'context -> Core.con' -> Core.con',
adamc@16 67 bind : 'context * binder -> 'context}
adamc@16 68 -> 'context -> (Core.con -> Core.con)
adamc@23 69
adamc@23 70 val fold : {kind : Core.kind' * 'state -> 'state,
adamc@23 71 con : Core.con' * 'state -> 'state}
adamc@23 72 -> 'state -> Core.con -> 'state
adamc@23 73
adamc@16 74 val exists : {kind : Core.kind' -> bool,
adamc@16 75 con : Core.con' -> bool} -> Core.con -> bool
adamc@193 76
adamc@193 77 val foldMap : {kind : Core.kind' * 'state -> Core.kind' * 'state,
adamc@193 78 con : Core.con' * 'state -> Core.con' * 'state}
adamc@193 79 -> 'state -> Core.con -> Core.con * 'state
adamc@16 80 end
adamc@16 81
adamc@16 82 structure Exp : sig
adamc@479 83 val compare : Core.exp * Core.exp -> order
adamc@479 84
adamc@16 85 datatype binder =
adamc@626 86 RelK of string
adamc@626 87 | RelC of string * Core.kind
adamc@20 88 | NamedC of string * int * Core.kind * Core.con option
adamc@16 89 | RelE of string * Core.con
adamc@109 90 | NamedE of string * int * Core.con * Core.exp option * string
adamc@16 91
adamc@626 92 val mapfoldB : {kind : ('context, Core.kind', 'state, 'abort) Search.mapfolderB,
adamc@16 93 con : ('context, Core.con', 'state, 'abort) Search.mapfolderB,
adamc@16 94 exp : ('context, Core.exp', 'state, 'abort) Search.mapfolderB,
adamc@16 95 bind : 'context * binder -> 'context}
adamc@16 96 -> ('context, Core.exp, 'state, 'abort) Search.mapfolderB
adamc@16 97 val mapfold : {kind : (Core.kind', 'state, 'abort) Search.mapfolder,
adamc@16 98 con : (Core.con', 'state, 'abort) Search.mapfolder,
adamc@16 99 exp : (Core.exp', 'state, 'abort) Search.mapfolder}
adamc@16 100 -> (Core.exp, 'state, 'abort) Search.mapfolder
adamc@16 101
adamc@16 102 val map : {kind : Core.kind' -> Core.kind',
adamc@16 103 con : Core.con' -> Core.con',
adamc@16 104 exp : Core.exp' -> Core.exp'}
adamc@16 105 -> Core.exp -> Core.exp
adamc@626 106 val mapB : {kind : 'context -> Core.kind' -> Core.kind',
adamc@21 107 con : 'context -> Core.con' -> Core.con',
adamc@21 108 exp : 'context -> Core.exp' -> Core.exp',
adamc@21 109 bind : 'context * binder -> 'context}
adamc@21 110 -> 'context -> (Core.exp -> Core.exp)
adamc@23 111
adamc@23 112 val fold : {kind : Core.kind' * 'state -> 'state,
adamc@23 113 con : Core.con' * 'state -> 'state,
adamc@23 114 exp : Core.exp' * 'state -> 'state}
adamc@23 115 -> 'state -> Core.exp -> 'state
adamc@484 116
adamc@626 117 val foldB : {kind : 'context * Core.kind' * 'state -> 'state,
adamc@484 118 con : 'context * Core.con' * 'state -> 'state,
adamc@484 119 exp : 'context * Core.exp' * 'state -> 'state,
adamc@484 120 bind : 'context * binder -> 'context}
adamc@484 121 -> 'context -> 'state -> Core.exp -> 'state
adamc@23 122
adamc@16 123 val exists : {kind : Core.kind' -> bool,
adamc@16 124 con : Core.con' -> bool,
adamc@16 125 exp : Core.exp' -> bool} -> Core.exp -> bool
adamc@443 126
adamc@626 127 val existsB : {kind : 'context * Core.kind' -> bool,
adamc@479 128 con : 'context * Core.con' -> bool,
adamc@479 129 exp : 'context * Core.exp' -> bool,
adamc@479 130 bind : 'context * binder -> 'context}
adamc@479 131 -> 'context -> Core.exp -> bool
adamc@479 132
adamc@443 133 val foldMap : {kind : Core.kind' * 'state -> Core.kind' * 'state,
adamc@443 134 con : Core.con' * 'state -> Core.con' * 'state,
adamc@443 135 exp : Core.exp' * 'state -> Core.exp' * 'state}
adamc@443 136 -> 'state -> Core.exp -> Core.exp * 'state
adamc@626 137 val foldMapB : {kind : 'context * Core.kind' * 'state -> Core.kind' * 'state,
adamc@488 138 con : 'context * Core.con' * 'state -> Core.con' * 'state,
adamc@488 139 exp : 'context * Core.exp' * 'state -> Core.exp' * 'state,
adamc@488 140 bind : 'context * binder -> 'context}
adamc@488 141 -> 'context -> 'state -> Core.exp -> Core.exp * 'state
adamc@16 142 end
adamc@16 143
adamc@20 144 structure Decl : sig
adamc@20 145 datatype binder = datatype Exp.binder
adamc@20 146
adamc@626 147 val mapfoldB : {kind : ('context, Core.kind', 'state, 'abort) Search.mapfolderB,
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.decl, 'state, 'abort) Search.mapfolderB
adamc@23 153 val mapfold : {kind : (Core.kind', 'state, 'abort) Search.mapfolder,
adamc@23 154 con : (Core.con', 'state, 'abort) Search.mapfolder,
adamc@23 155 exp : (Core.exp', 'state, 'abort) Search.mapfolder,
adamc@23 156 decl : (Core.decl', 'state, 'abort) Search.mapfolder}
adamc@23 157 -> (Core.decl, 'state, 'abort) Search.mapfolder
adamc@23 158
adamc@23 159 val fold : {kind : Core.kind' * 'state -> 'state,
adamc@23 160 con : Core.con' * 'state -> 'state,
adamc@23 161 exp : Core.exp' * 'state -> 'state,
adamc@23 162 decl : Core.decl' * 'state -> 'state}
adamc@23 163 -> 'state -> Core.decl -> 'state
adamc@110 164
adamc@110 165 val foldMap : {kind : Core.kind' * 'state -> Core.kind' * 'state,
adamc@110 166 con : Core.con' * 'state -> Core.con' * 'state,
adamc@110 167 exp : Core.exp' * 'state -> Core.exp' * 'state,
adamc@110 168 decl : Core.decl' * 'state -> Core.decl' * 'state}
adamc@110 169 -> 'state -> Core.decl -> Core.decl * 'state
adamc@626 170 val foldMapB : {kind : 'context * Core.kind' * 'state -> Core.kind' * 'state,
adamc@484 171 con : 'context * Core.con' * 'state -> Core.con' * 'state,
adamc@484 172 exp : 'context * Core.exp' * 'state -> Core.exp' * 'state,
adamc@484 173 decl : 'context * Core.decl' * 'state -> Core.decl' * 'state,
adamc@484 174 bind : 'context * binder -> 'context}
adamc@484 175 -> 'context -> 'state -> Core.decl -> Core.decl * 'state
adamc@522 176
adamc@522 177 val exists : {kind : Core.kind' -> bool,
adamc@522 178 con : Core.con' -> bool,
adamc@522 179 exp : Core.exp' -> bool,
adamc@522 180 decl : Core.decl' -> bool} -> Core.decl -> bool
adamc@16 181 end
adamc@20 182
adamc@20 183 structure File : sig
adamc@179 184 val maxName : Core.file -> int
adamc@179 185
adamc@20 186 datatype binder = datatype Exp.binder
adamc@20 187
adamc@626 188 val mapfoldB : {kind : ('context, Core.kind', 'state, 'abort) Search.mapfolderB,
adamc@20 189 con : ('context, Core.con', 'state, 'abort) Search.mapfolderB,
adamc@20 190 exp : ('context, Core.exp', 'state, 'abort) Search.mapfolderB,
adamc@20 191 decl : ('context, Core.decl', 'state, 'abort) Search.mapfolderB,
adamc@20 192 bind : 'context * binder -> 'context}
adamc@20 193 -> ('context, Core.file, 'state, 'abort) Search.mapfolderB
adamc@20 194
adamc@23 195 val mapfold : {kind : (Core.kind', 'state, 'abort) Search.mapfolder,
adamc@23 196 con : (Core.con', 'state, 'abort) Search.mapfolder,
adamc@23 197 exp : (Core.exp', 'state, 'abort) Search.mapfolder,
adamc@23 198 decl : (Core.decl', 'state, 'abort) Search.mapfolder}
adamc@23 199 -> (Core.file, 'state, 'abort) Search.mapfolder
adamc@23 200
adamc@626 201 val mapB : {kind : 'context -> Core.kind' -> Core.kind',
adamc@20 202 con : 'context -> Core.con' -> Core.con',
adamc@20 203 exp : 'context -> Core.exp' -> Core.exp',
adamc@20 204 decl : 'context -> Core.decl' -> Core.decl',
adamc@20 205 bind : 'context * binder -> 'context}
adamc@20 206 -> 'context -> Core.file -> Core.file
adamc@23 207
adamc@482 208 val map : {kind : Core.kind' -> Core.kind',
adamc@482 209 con : Core.con' -> Core.con',
adamc@482 210 exp : Core.exp' -> Core.exp',
adamc@482 211 decl : Core.decl' -> Core.decl'}
adamc@482 212 -> Core.file -> Core.file
adamc@482 213
adamc@23 214 val fold : {kind : Core.kind' * 'state -> 'state,
adamc@23 215 con : Core.con' * 'state -> 'state,
adamc@23 216 exp : Core.exp' * 'state -> 'state,
adamc@23 217 decl : Core.decl' * 'state -> 'state}
adamc@23 218 -> 'state -> Core.file -> 'state
adamc@110 219
adamc@110 220 val foldMap : {kind : Core.kind' * 'state -> Core.kind' * 'state,
adamc@110 221 con : Core.con' * 'state -> Core.con' * 'state,
adamc@110 222 exp : Core.exp' * 'state -> Core.exp' * 'state,
adamc@110 223 decl : Core.decl' * 'state -> Core.decl' * 'state}
adamc@110 224 -> 'state -> Core.file -> Core.file * 'state
adamc@20 225 end
adamc@20 226
adamc@20 227 end