annotate src/expl.sml @ 732:5819fb63c93a

Effectness analysis
author Adam Chlipala <adamc@hcoop.net>
date Thu, 16 Apr 2009 15:29:39 -0400
parents e0dd85ea58e1
children 8688e01ae469
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@624 40 | KRel of int
adamc@624 41 | KFun of string * kind
adamc@624 42
adamc@38 43 withtype kind = kind' located
adamc@38 44
adamc@38 45 datatype con' =
adamc@38 46 TFun of con * con
adamc@38 47 | TCFun of string * kind * con
adamc@38 48 | TRecord of con
adamc@38 49
adamc@38 50 | CRel of int
adamc@38 51 | CNamed of int
adamc@38 52 | CModProj of int * string list * string
adamc@38 53 | CApp of con * con
adamc@38 54 | CAbs of string * kind * con
adamc@38 55
adamc@624 56 | CKAbs of string * con
adamc@624 57 | CKApp of con * kind
adamc@624 58 | TKFun of string * con
adamc@624 59
adamc@38 60 | CName of string
adamc@38 61
adamc@38 62 | CRecord of kind * (con * con) list
adamc@38 63 | CConcat of con * con
adamc@621 64 | CMap of kind * kind
adamc@38 65
adamc@87 66 | CUnit
adamc@87 67
adamc@213 68 | CTuple of con list
adamc@213 69 | CProj of con * int
adamc@213 70
adamc@38 71 withtype con = con' located
adamc@38 72
adamc@731 73 datatype datatype_kind = datatype DatatypeKind.datatype_kind
adamc@188 74
adamc@176 75 datatype patCon =
adamc@176 76 PConVar of int
adamc@176 77 | PConProj of int * string list * string
adamc@176 78
adamc@176 79 datatype pat' =
adamc@176 80 PWild
adamc@182 81 | PVar of string * con
adamc@176 82 | PPrim of Prim.t
adamc@191 83 | PCon of datatype_kind * patCon * con list * pat option
adamc@182 84 | PRecord of (string * pat * con) list
adamc@176 85
adamc@176 86 withtype pat = pat' located
adamc@176 87
adamc@38 88 datatype exp' =
adamc@38 89 EPrim of Prim.t
adamc@38 90 | ERel of int
adamc@38 91 | ENamed of int
adamc@38 92 | EModProj of int * string list * string
adamc@38 93 | EApp of exp * exp
adamc@38 94 | EAbs of string * con * con * exp
adamc@38 95 | ECApp of exp * con
adamc@38 96 | ECAbs of string * kind * exp
adamc@38 97
adamc@624 98 | EKAbs of string * exp
adamc@624 99 | EKApp of exp * kind
adamc@624 100
adamc@38 101 | ERecord of (con * exp * con) list
adamc@38 102 | EField of exp * con * { field : con, rest : con }
adamc@445 103 | EConcat of exp * con * exp * con
adamc@149 104 | ECut of exp * con * { field : con, rest : con }
adamc@493 105 | ECutMulti of exp * con * { rest : con }
adamc@38 106
adamc@182 107 | ECase of exp * (pat * exp) list * { disc : con, result : con }
adamc@176 108
adamc@109 109 | EWrite of exp
adamc@109 110
adamc@449 111 | ELet of string * con * exp * exp
adamc@449 112
adamc@38 113 withtype exp = exp' located
adamc@38 114
adamc@38 115 datatype sgn_item' =
adamc@38 116 SgiConAbs of string * int * kind
adamc@38 117 | SgiCon of string * int * kind * con
adamc@191 118 | SgiDatatype of string * int * string list * (string * int * con option) list
adamc@191 119 | SgiDatatypeImp of string * int * int * string list * string * string list * (string * int * con option) list
adamc@38 120 | SgiVal of string * int * con
adamc@64 121 | SgiSgn of string * int * sgn
adamc@38 122 | SgiStr of string * int * sgn
adamc@38 123
adamc@38 124 and sgn' =
adamc@38 125 SgnConst of sgn_item list
adamc@38 126 | SgnVar of int
adamc@45 127 | SgnFun of string * int * sgn * sgn
adamc@45 128 | SgnWhere of sgn * string * con
adamc@64 129 | SgnProj of int * string list * string
adamc@38 130
adamc@38 131 withtype sgn_item = sgn_item' located
adamc@38 132 and sgn = sgn' located
adamc@38 133
adamc@38 134 datatype decl' =
adamc@38 135 DCon of string * int * kind * con
adamc@191 136 | DDatatype of string * int * string list * (string * int * con option) list
adamc@191 137 | DDatatypeImp of string * int * int * string list * string * string list * (string * int * con option) list
adamc@38 138 | DVal of string * int * con * exp
adamc@124 139 | DValRec of (string * int * con * exp) list
adamc@38 140 | DSgn of string * int * sgn
adamc@38 141 | DStr of string * int * sgn * str
adamc@48 142 | DFfiStr of string * int * sgn
adamc@109 143 | DExport of int * sgn * str
adamc@707 144 | DTable of int * string * int * con * exp * con * exp * con
adamc@338 145 | DSequence of int * string * int
adamc@271 146 | DDatabase of string
adamc@460 147 | DCookie of int * string * int * con
adamc@720 148 | DStyle of int * string * int
adamc@38 149
adamc@38 150 and str' =
adamc@38 151 StrConst of decl list
adamc@38 152 | StrVar of int
adamc@38 153 | StrProj of str * string
adamc@45 154 | StrFun of string * int * sgn * sgn * str
adamc@45 155 | StrApp of str * str
adamc@38 156
adamc@38 157 withtype decl = decl' located
adamc@38 158 and str = str' located
adamc@38 159
adamc@38 160 type file = decl list
adamc@38 161
adamc@38 162 end