annotate src/core.sml @ 534:65c253a9ca92

Pattern typing
author Adam Chlipala <adamc@hcoop.net>
date Sat, 29 Nov 2008 10:49:47 -0500
parents ae03d09043c1
children 0dd40b6bfdf3
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 structure Core = struct
adamc@16 29
adamc@16 30 type 'a located = 'a ErrorMsg.located
adamc@16 31
adamc@16 32 datatype kind' =
adamc@16 33 KType
adamc@16 34 | KArrow of kind * kind
adamc@16 35 | KName
adamc@16 36 | KRecord of kind
adamc@87 37 | KUnit
adamc@214 38 | KTuple of kind list
adamc@16 39
adamc@16 40 withtype kind = kind' located
adamc@16 41
adamc@16 42 datatype con' =
adamc@16 43 TFun of con * con
adamc@16 44 | TCFun of string * kind * con
adamc@16 45 | TRecord of con
adamc@16 46
adamc@16 47 | CRel of int
adamc@16 48 | CNamed of int
adamc@48 49 | CFfi of string * string
adamc@16 50 | CApp of con * con
adamc@16 51 | CAbs of string * kind * con
adamc@16 52
adamc@16 53 | CName of string
adamc@16 54
adamc@16 55 | CRecord of kind * (con * con) list
adamc@16 56 | CConcat of con * con
adamc@69 57 | CFold of kind * kind
adamc@16 58
adamc@87 59 | CUnit
adamc@87 60
adamc@214 61 | CTuple of con list
adamc@214 62 | CProj of con * int
adamc@214 63
adamc@16 64 withtype con = con' located
adamc@16 65
adamc@188 66 datatype datatype_kind = datatype Elab.datatype_kind
adamc@188 67
adamc@177 68 datatype patCon =
adamc@177 69 PConVar of int
adamc@192 70 | PConFfi of {mod : string, datatyp : string, params : string list,
adamc@192 71 con : string, arg : con option, kind : datatype_kind}
adamc@177 72
adamc@177 73 datatype pat' =
adamc@177 74 PWild
adamc@182 75 | PVar of string * con
adamc@177 76 | PPrim of Prim.t
adamc@192 77 | PCon of datatype_kind * patCon * con list * pat option
adamc@182 78 | PRecord of (string * pat * con) list
adamc@177 79
adamc@177 80 withtype pat = pat' located
adamc@177 81
adamc@16 82 datatype exp' =
adamc@16 83 EPrim of Prim.t
adamc@16 84 | ERel of int
adamc@16 85 | ENamed of int
adamc@192 86 | ECon of datatype_kind * patCon * con list * exp option
adamc@48 87 | EFfi of string * string
adamc@48 88 | EFfiApp of string * string * exp list
adamc@16 89 | EApp of exp * exp
adamc@26 90 | EAbs of string * con * con * exp
adamc@16 91 | ECApp of exp * con
adamc@16 92 | ECAbs of string * kind * exp
adamc@16 93
adamc@29 94 | ERecord of (con * exp * con) list
adamc@16 95 | EField of exp * con * { field : con, rest : con }
adamc@445 96 | EConcat of exp * con * exp * con
adamc@149 97 | ECut of exp * con * { field : con, rest : con }
adamc@493 98 | ECutMulti of exp * con * { rest : con }
adamc@73 99 | EFold of kind
adamc@16 100
adamc@182 101 | ECase of exp * (pat * exp) list * { disc : con, result : con }
adamc@177 102
adamc@102 103 | EWrite of exp
adamc@102 104
adamc@110 105 | EClosure of int * exp list
adamc@110 106
adamc@450 107 | ELet of string * con * exp * exp
adamc@450 108
adamc@16 109 withtype exp = exp' located
adamc@16 110
adamc@144 111 datatype export_kind =
adamc@144 112 Link
adamc@144 113 | Action
adamc@144 114
adamc@16 115 datatype decl' =
adamc@16 116 DCon of string * int * kind * con
adamc@192 117 | DDatatype of string * int * string list * (string * int * con option) list
adamc@109 118 | DVal of string * int * con * exp * string
adamc@125 119 | DValRec of (string * int * con * exp * string) list
adamc@144 120 | DExport of export_kind * int
adamc@247 121 | DTable of string * int * con * string
adamc@338 122 | DSequence of string * int * string
adamc@271 123 | DDatabase of string
adamc@461 124 | DCookie of string * int * con * string
adamc@16 125
adamc@16 126 withtype decl = decl' located
adamc@16 127
adamc@16 128 type file = decl list
adamc@16 129
adamc@16 130 end