annotate src/elab_util.sig @ 198:ab86aa858e6c

'Option' datatype encoding
author Adam Chlipala <adamc@hcoop.net>
date Sat, 09 Aug 2008 19:23:31 -0400
parents 8e9f97508f0d
children e86411f647c6
rev   line source
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@11 41 | Named of string * 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@6 60 end
adamc@6 61
adamc@10 62 structure Exp : sig
adamc@11 63 datatype binder =
adamc@11 64 RelC of string * Elab.kind
adamc@11 65 | NamedC of string * Elab.kind
adamc@11 66 | RelE of string * Elab.con
adamc@11 67 | NamedE of string * Elab.con
adamc@11 68
adamc@11 69 val mapfoldB : {kind : (Elab.kind', 'state, 'abort) Search.mapfolder,
adamc@11 70 con : ('context, Elab.con', 'state, 'abort) Search.mapfolderB,
adamc@11 71 exp : ('context, Elab.exp', 'state, 'abort) Search.mapfolderB,
adamc@11 72 bind : 'context * binder -> 'context}
adamc@11 73 -> ('context, Elab.exp, 'state, 'abort) Search.mapfolderB
adamc@10 74 val mapfold : {kind : (Elab.kind', 'state, 'abort) Search.mapfolder,
adamc@10 75 con : (Elab.con', 'state, 'abort) Search.mapfolder,
adamc@10 76 exp : (Elab.exp', 'state, 'abort) Search.mapfolder}
adamc@10 77 -> (Elab.exp, 'state, 'abort) Search.mapfolder
adamc@10 78 val exists : {kind : Elab.kind' -> bool,
adamc@10 79 con : Elab.con' -> bool,
adamc@10 80 exp : Elab.exp' -> bool} -> Elab.exp -> bool
adamc@10 81 end
adamc@10 82
adamc@34 83 structure Sgn : sig
adamc@34 84 datatype binder =
adamc@34 85 RelC of string * Elab.kind
adamc@34 86 | NamedC of string * Elab.kind
adamc@34 87 | Str of string * Elab.sgn
adamc@59 88 | Sgn of string * Elab.sgn
adamc@34 89
adamc@34 90 val mapfoldB : {kind : (Elab.kind', 'state, 'abort) Search.mapfolder,
adamc@34 91 con : ('context, Elab.con', 'state, 'abort) Search.mapfolderB,
adamc@34 92 sgn_item : ('context, Elab.sgn_item', 'state, 'abort) Search.mapfolderB,
adamc@34 93 sgn : ('context, Elab.sgn', 'state, 'abort) Search.mapfolderB,
adamc@34 94 bind : 'context * binder -> 'context}
adamc@34 95 -> ('context, Elab.sgn, 'state, 'abort) Search.mapfolderB
adamc@34 96
adamc@34 97
adamc@34 98 val mapfold : {kind : (Elab.kind', 'state, 'abort) Search.mapfolder,
adamc@34 99 con : (Elab.con', 'state, 'abort) Search.mapfolder,
adamc@34 100 sgn_item : (Elab.sgn_item', 'state, 'abort) Search.mapfolder,
adamc@34 101 sgn : (Elab.sgn', 'state, 'abort) Search.mapfolder}
adamc@34 102 -> (Elab.sgn, 'state, 'abort) Search.mapfolder
adamc@34 103
adamc@34 104 val map : {kind : Elab.kind' -> Elab.kind',
adamc@34 105 con : Elab.con' -> Elab.con',
adamc@34 106 sgn_item : Elab.sgn_item' -> Elab.sgn_item',
adamc@34 107 sgn : Elab.sgn' -> Elab.sgn'}
adamc@34 108 -> Elab.sgn -> Elab.sgn
adamc@34 109
adamc@2 110 end
adamc@34 111
adamc@76 112 structure Decl : sig
adamc@76 113 datatype binder =
adamc@76 114 RelC of string * Elab.kind
adamc@76 115 | NamedC of string * Elab.kind
adamc@76 116 | RelE of string * Elab.con
adamc@76 117 | NamedE of string * Elab.con
adamc@76 118 | Str of string * Elab.sgn
adamc@76 119 | Sgn of string * Elab.sgn
adamc@76 120
adamc@76 121 val mapfoldB : {kind : (Elab.kind', 'state, 'abort) Search.mapfolder,
adamc@76 122 con : ('context, Elab.con', 'state, 'abort) Search.mapfolderB,
adamc@76 123 exp : ('context, Elab.exp', 'state, 'abort) Search.mapfolderB,
adamc@76 124 sgn_item : ('context, Elab.sgn_item', 'state, 'abort) Search.mapfolderB,
adamc@76 125 sgn : ('context, Elab.sgn', 'state, 'abort) Search.mapfolderB,
adamc@76 126 str : ('context, Elab.str', 'state, 'abort) Search.mapfolderB,
adamc@76 127 decl : ('context, Elab.decl', 'state, 'abort) Search.mapfolderB,
adamc@76 128 bind : 'context * binder -> 'context}
adamc@76 129 -> ('context, Elab.decl, 'state, 'abort) Search.mapfolderB
adamc@76 130 val mapfold : {kind : (Elab.kind', 'state, 'abort) Search.mapfolder,
adamc@76 131 con : (Elab.con', 'state, 'abort) Search.mapfolder,
adamc@76 132 exp : (Elab.exp', 'state, 'abort) Search.mapfolder,
adamc@76 133 sgn_item : (Elab.sgn_item', 'state, 'abort) Search.mapfolder,
adamc@76 134 sgn : (Elab.sgn', 'state, 'abort) Search.mapfolder,
adamc@76 135 str : (Elab.str', 'state, 'abort) Search.mapfolder,
adamc@76 136 decl : (Elab.decl', 'state, 'abort) Search.mapfolder}
adamc@76 137 -> (Elab.decl, 'state, 'abort) Search.mapfolder
adamc@76 138 val exists : {kind : Elab.kind' -> bool,
adamc@76 139 con : Elab.con' -> bool,
adamc@76 140 exp : Elab.exp' -> bool,
adamc@76 141 sgn_item : Elab.sgn_item' -> bool,
adamc@76 142 sgn : Elab.sgn' -> bool,
adamc@76 143 str : Elab.str' -> bool,
adamc@76 144 decl : Elab.decl' -> bool}
adamc@76 145 -> Elab.decl -> bool
adamc@76 146 val search : {kind : Elab.kind' -> 'a option,
adamc@76 147 con : Elab.con' -> 'a option,
adamc@76 148 exp : Elab.exp' -> 'a option,
adamc@76 149 sgn_item : Elab.sgn_item' -> 'a option,
adamc@76 150 sgn : Elab.sgn' -> 'a option,
adamc@76 151 str : Elab.str' -> 'a option,
adamc@76 152 decl : Elab.decl' -> 'a option}
adamc@76 153 -> Elab.decl -> 'a option
adamc@34 154 end
adamc@76 155
adamc@76 156 end