Import Upstream version 20180207
[hcoop/debian/mlton.git] / mlton / core-ml / core-ml.sig
CommitLineData
7f918cf1
CE
1(* Copyright (C) 2015,2017 Matthew Fluet
2 * Copyright (C) 1999-2008 Henry Cejtin, Matthew Fluet, Suresh
3 * Jagannathan, and Stephen Weeks.
4 * Copyright (C) 1997-2000 NEC Research Institute.
5 *
6 * MLton is released under a BSD-style license.
7 * See the file MLton-LICENSE for details.
8 *)
9
10signature CORE_ML_STRUCTS =
11 sig
12 include ATOMS
13 structure Type:
14 sig
15 type t
16
17 val arrow: t * t -> t
18 val bool: t
19 val deConOpt: t -> (Tycon.t * t vector) option
20 val deRecord: t -> (Record.Field.t * t) vector
21 val isCharX: t -> bool
22 val isInt: t -> bool
23 val layout: t -> Layout.t
24 val makeHom: {con: Tycon.t * 'a vector -> 'a,
25 var: Tyvar.t -> 'a} -> {destroy: unit -> unit,
26 hom: t -> 'a}
27 val tuple: t vector -> t
28 val unit: t
29 end
30 end
31
32signature CORE_ML =
33 sig
34 include CORE_ML_STRUCTS
35
36 structure Pat:
37 sig
38 type t
39 datatype node =
40 Con of {arg: t option,
41 con: Con.t,
42 targs: Type.t vector}
43 | Const of unit -> Const.t
44 | Layered of Var.t * t
45 | List of t vector
46 | Or of t vector
47 | Record of t Record.t
48 | Var of Var.t
49 | Vector of t vector
50 | Wild
51
52 val dest: t -> node * Type.t
53 val falsee: t
54 val foreachVar: t * (Var.t -> unit) -> unit
55 (* true if pattern contains a constant, constructor or variable *)
56 val isRefutable: t -> bool
57 val isUnit: t -> bool
58 val isWild: t -> bool
59 val layout: t -> Layout.t
60 val make: node * Type.t -> t
61 val node: t -> node
62 val var: Var.t * Type.t -> t
63 val truee: t
64 val tuple: t vector -> t
65 val ty: t -> Type.t
66 val wild: Type.t -> t
67 end
68
69 structure Exp:
70 sig
71 type dec
72 type lambda
73 type t
74 datatype noMatch = Impossible | RaiseAgain | RaiseBind | RaiseMatch
75 datatype node =
76 App of t * t
77 | Case of {ctxt: unit -> Layout.t,
78 kind: string * string,
79 nest: string list,
80 matchDiags: {nonexhaustiveExn: Control.Elaborate.DiagDI.t,
81 nonexhaustive: Control.Elaborate.DiagEIW.t,
82 redundant: Control.Elaborate.DiagEIW.t},
83 noMatch: noMatch,
84 region: Region.t,
85 rules: {exp: t,
86 layPat: (unit -> Layout.t) option,
87 pat: Pat.t,
88 regionPat: Region.t} vector,
89 test: t}
90 | Con of Con.t * Type.t vector
91 | Const of unit -> Const.t
92 | EnterLeave of t * SourceInfo.t
93 | Handle of {catch: Var.t * Type.t,
94 handler: t,
95 try: t}
96 | Lambda of lambda
97 | Let of dec vector * t
98 | List of t vector
99 | PrimApp of {args: t vector,
100 prim: Type.t Prim.t,
101 targs: Type.t vector}
102 | Raise of t
103 | Record of t Record.t
104 | Seq of t vector
105 | Var of (unit -> Var.t) * (unit -> Type.t vector)
106 | Vector of t vector
107
108 val andAlso: t * t -> t
109 val casee: {ctxt: unit -> Layout.t,
110 kind: string * string,
111 nest: string list,
112 matchDiags: {nonexhaustiveExn: Control.Elaborate.DiagDI.t,
113 nonexhaustive: Control.Elaborate.DiagEIW.t,
114 redundant: Control.Elaborate.DiagEIW.t},
115 noMatch: noMatch,
116 region: Region.t,
117 rules: {exp: t,
118 layPat: (unit -> Layout.t) option,
119 pat: Pat.t,
120 regionPat: Region.t} vector,
121 test: t} -> t
122 val dest: t -> node * Type.t
123 val iff: t * t * t -> t
124 val falsee: t
125 val foreachVar: t * (Var.t -> unit) -> unit
126 (* true if the expression may side-effect. See p 19 of Definition *)
127 val isExpansive: t -> bool
128 val lambda: lambda -> t
129 val layout: t -> Layout.t
130 val layoutWithType: t -> Layout.t
131 val make: node * Type.t -> t
132 val node: t -> node
133 val orElse: t * t -> t
134 val truee: t
135 val tuple: t vector -> t
136 val ty: t -> Type.t
137 val unit: t
138 val var: Var.t * Type.t -> t
139 val whilee: {expr: t, test: t} -> t
140 end
141
142 structure Lambda:
143 sig
144 type t
145
146 val bogus: t
147 val dest: t -> {arg: Var.t,
148 argType: Type.t,
149 body: Exp.t,
150 mayInline: bool}
151 val make: {arg: Var.t,
152 argType: Type.t,
153 body: Exp.t,
154 mayInline: bool} -> t
155 end
156 sharing type Exp.lambda = Lambda.t
157
158 structure Dec:
159 sig
160 datatype t =
161 Datatype of {cons: {arg: Type.t option,
162 con: Con.t} vector,
163 tycon: Tycon.t,
164 tyvars: Tyvar.t vector} vector
165 | Exception of {arg: Type.t option,
166 con: Con.t}
167 | Fun of {decs: {lambda: Lambda.t,
168 var: Var.t} vector,
169 tyvars: unit -> Tyvar.t vector}
170 | Val of {matchDiags: {nonexhaustiveExn: Control.Elaborate.DiagDI.t,
171 nonexhaustive: Control.Elaborate.DiagEIW.t,
172 redundant: Control.Elaborate.DiagEIW.t},
173 rvbs: {lambda: Lambda.t,
174 var: Var.t} vector,
175 tyvars: unit -> Tyvar.t vector,
176 vbs: {ctxt: unit -> Layout.t,
177 exp: Exp.t,
178 layPat: unit -> Layout.t,
179 nest: string list,
180 pat: Pat.t,
181 regionPat: Region.t} vector}
182
183 val layout: t -> Layout.t
184 end
185 sharing type Exp.dec = Dec.t
186
187 structure Program:
188 sig
189 datatype t = T of {decs: Dec.t vector}
190
191 val layouts: t * (Layout.t -> unit) -> unit
192 end
193 end