annotate src/expl.sml @ 533:419f51b1e68d

Typing
author Adam Chlipala <adamc@hcoop.net>
date Sat, 29 Nov 2008 10:34:56 -0500
parents ae03d09043c1
children 8998114760c1
rev   line source
adamc@38 1 (* Copyright (c) 2008, Adam Chlipala
adamc@38 2 * All rights reserved.
adamc@38 3 *
adamc@38 4 * Redistribution and use in source and binary forms, with or without
adamc@38 5 * modification, are permitted provided that the following conditions are met:
adamc@38 6 *
adamc@38 7 * - Redistributions of source code must retain the above copyright notice,
adamc@38 8 * this list of conditions and the following disclaimer.
adamc@38 9 * - Redistributions in binary form must reproduce the above copyright notice,
adamc@38 10 * this list of conditions and the following disclaimer in the documentation
adamc@38 11 * and/or other materials provided with the distribution.
adamc@38 12 * - The names of contributors may not be used to endorse or promote products
adamc@38 13 * derived from this software without specific prior written permission.
adamc@38 14 *
adamc@38 15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
adamc@38 16 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
adamc@38 17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
adamc@38 18 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
adamc@38 19 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
adamc@38 20 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
adamc@38 21 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
adamc@38 22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
adamc@38 23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
adamc@38 24 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
adamc@38 25 * POSSIBILITY OF SUCH DAMAGE.
adamc@38 26 *)
adamc@38 27
adamc@38 28 structure Expl = struct
adamc@38 29
adamc@38 30 type 'a located = 'a ErrorMsg.located
adamc@38 31
adamc@38 32 datatype kind' =
adamc@38 33 KType
adamc@38 34 | KArrow of kind * kind
adamc@38 35 | KName
adamc@87 36 | KUnit
adamc@213 37 | KTuple of kind list
adamc@38 38 | KRecord of kind
adamc@38 39
adamc@38 40 withtype kind = kind' located
adamc@38 41
adamc@38 42 datatype con' =
adamc@38 43 TFun of con * con
adamc@38 44 | TCFun of string * kind * con
adamc@38 45 | TRecord of con
adamc@38 46
adamc@38 47 | CRel of int
adamc@38 48 | CNamed of int
adamc@38 49 | CModProj of int * string list * string
adamc@38 50 | CApp of con * con
adamc@38 51 | CAbs of string * kind * con
adamc@38 52
adamc@38 53 | CName of string
adamc@38 54
adamc@38 55 | CRecord of kind * (con * con) list
adamc@38 56 | CConcat of con * con
adamc@68 57 | CFold of kind * kind
adamc@38 58
adamc@87 59 | CUnit
adamc@87 60
adamc@213 61 | CTuple of con list
adamc@213 62 | CProj of con * int
adamc@213 63
adamc@38 64 withtype con = con' located
adamc@38 65
adamc@188 66 datatype datatype_kind = datatype Elab.datatype_kind
adamc@188 67
adamc@176 68 datatype patCon =
adamc@176 69 PConVar of int
adamc@176 70 | PConProj of int * string list * string
adamc@176 71
adamc@176 72 datatype pat' =
adamc@176 73 PWild
adamc@182 74 | PVar of string * con
adamc@176 75 | PPrim of Prim.t
adamc@191 76 | PCon of datatype_kind * patCon * con list * pat option
adamc@182 77 | PRecord of (string * pat * con) list
adamc@176 78
adamc@176 79 withtype pat = pat' located
adamc@176 80
adamc@38 81 datatype exp' =
adamc@38 82 EPrim of Prim.t
adamc@38 83 | ERel of int
adamc@38 84 | ENamed of int
adamc@38 85 | EModProj of int * string list * string
adamc@38 86 | EApp of exp * exp
adamc@38 87 | EAbs of string * con * con * exp
adamc@38 88 | ECApp of exp * con
adamc@38 89 | ECAbs of string * kind * exp
adamc@38 90
adamc@38 91 | ERecord of (con * exp * con) list
adamc@38 92 | EField of exp * con * { field : con, rest : con }
adamc@445 93 | EConcat of exp * con * exp * con
adamc@149 94 | ECut of exp * con * { field : con, rest : con }
adamc@493 95 | ECutMulti of exp * con * { rest : con }
adamc@72 96 | EFold of kind
adamc@38 97
adamc@182 98 | ECase of exp * (pat * exp) list * { disc : con, result : con }
adamc@176 99
adamc@109 100 | EWrite of exp
adamc@109 101
adamc@449 102 | ELet of string * con * exp * exp
adamc@449 103
adamc@38 104 withtype exp = exp' located
adamc@38 105
adamc@38 106 datatype sgn_item' =
adamc@38 107 SgiConAbs of string * int * kind
adamc@38 108 | SgiCon of string * int * kind * con
adamc@191 109 | SgiDatatype of string * int * string list * (string * int * con option) list
adamc@191 110 | SgiDatatypeImp of string * int * int * string list * string * string list * (string * int * con option) list
adamc@38 111 | SgiVal of string * int * con
adamc@64 112 | SgiSgn of string * int * sgn
adamc@38 113 | SgiStr of string * int * sgn
adamc@38 114
adamc@38 115 and sgn' =
adamc@38 116 SgnConst of sgn_item list
adamc@38 117 | SgnVar of int
adamc@45 118 | SgnFun of string * int * sgn * sgn
adamc@45 119 | SgnWhere of sgn * string * con
adamc@64 120 | SgnProj of int * string list * string
adamc@38 121
adamc@38 122 withtype sgn_item = sgn_item' located
adamc@38 123 and sgn = sgn' located
adamc@38 124
adamc@38 125 datatype decl' =
adamc@38 126 DCon of string * int * kind * con
adamc@191 127 | DDatatype of string * int * string list * (string * int * con option) list
adamc@191 128 | DDatatypeImp of string * int * int * string list * string * string list * (string * int * con option) list
adamc@38 129 | DVal of string * int * con * exp
adamc@124 130 | DValRec of (string * int * con * exp) list
adamc@38 131 | DSgn of string * int * sgn
adamc@38 132 | DStr of string * int * sgn * str
adamc@48 133 | DFfiStr of string * int * sgn
adamc@109 134 | DExport of int * sgn * str
adamc@246 135 | DTable of int * string * int * con
adamc@338 136 | DSequence of int * string * int
adamc@271 137 | DDatabase of string
adamc@460 138 | DCookie of int * string * int * con
adamc@38 139
adamc@38 140 and str' =
adamc@38 141 StrConst of decl list
adamc@38 142 | StrVar of int
adamc@38 143 | StrProj of str * string
adamc@45 144 | StrFun of string * int * sgn * sgn * str
adamc@45 145 | StrApp of str * str
adamc@38 146
adamc@38 147 withtype decl = decl' located
adamc@38 148 and str = str' located
adamc@38 149
adamc@38 150 type file = decl list
adamc@38 151
adamc@38 152 end