Import Debian changes 20180207-1
[hcoop/debian/mlton.git] / mlton / elaborate / elaborate-env.sig
CommitLineData
7f918cf1
CE
1(* Copyright (C) 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 ELABORATE_ENV_STRUCTS =
11 sig
12 structure Ast: AST
13 structure CoreML: CORE_ML
14 structure TypeEnv: TYPE_ENV
15 sharing Ast.Record = CoreML.Record
16 sharing Ast.SortedRecord = CoreML.SortedRecord
17 sharing CoreML.Atoms = TypeEnv.Atoms
18 sharing CoreML.Type = TypeEnv.Type
19 end
20
21signature ELABORATE_ENV =
22 sig
23 include ELABORATE_ENV_STRUCTS
24
25 structure Decs: DECS
26 sharing CoreML = Decs.CoreML
27
28 structure Tyvar: TYVAR
29 sharing Tyvar = TypeEnv.Tyvar
30 structure TyvarEnv:
31 sig
32 val lookupTyvar: Ast.Tyvar.t -> Tyvar.t option
33 val scope: Ast.Tyvar.t vector * (Tyvar.t vector -> 'a) -> 'a
34 val makeLayoutPretty: unit -> {destroy: unit -> unit, layoutPretty: Tyvar.t -> Layout.t}
35 end
36
37 structure AdmitsEquality: ADMITS_EQUALITY
38 sharing AdmitsEquality = TypeEnv.Tycon.AdmitsEquality
39 structure Kind: TYCON_KIND
40 sharing Kind = TypeEnv.Tycon.Kind
41 structure Tycon: TYCON
42 sharing Tycon = TypeEnv.Tycon
43
44 structure Type:
45 sig
46 type t
47 end
48 sharing Type = TypeEnv.Type
49 structure Scheme:
50 sig
51 type t
52 end
53 sharing Scheme = TypeEnv.Scheme
54
55 (* The value of a vid. This is used to distinguish between vids whose
56 * status cannot be determined at parse time.
57 *)
58 structure Vid:
59 sig
60 datatype t =
61 Con of CoreML.Con.t
62 | Exn of CoreML.Con.t
63 | Overload of Ast.Priority.t * (CoreML.Var.t * Scheme.t) vector
64 | Var of CoreML.Var.t
65
66 val layout: t -> Layout.t
67 end
68
69 structure TypeStr:
70 sig
71 structure Cons:
72 sig
73 type t
74
75 val layout: t -> Layout.t
76 end
77
78 type t
79
80 datatype node =
81 Datatype of {cons: Cons.t,
82 tycon: Tycon.t}
83 | Scheme of Scheme.t
84 | Tycon of Tycon.t
85
86 val abs: t -> t
87 val admitsEquality: t -> AdmitsEquality.t
88 val apply: t * Type.t vector -> Type.t
89 val data: Tycon.t * Cons.t -> t
90 val def: Scheme.t -> t
91 val kind: t -> Kind.t
92 val layout: t -> Layout.t
93 val node: t -> node
94 val toTyconOpt: t -> Tycon.t option (* NONE on Scheme *)
95 val tycon: Tycon.t -> t
96 end
97
98 structure Interface: INTERFACE
99 sharing Interface.Ast = Ast
100 sharing Interface.AdmitsEquality = AdmitsEquality
101 sharing Interface.Kind = Kind
102 sharing Interface.EnvTycon = Tycon
103 sharing Interface.EnvTypeStr = TypeStr
104 sharing Interface.Tyvar = Tyvar
105
106 structure Structure:
107 sig
108 type t
109
110 (* ffi represents MLtonFFI, which is built by the basis library and
111 * set via the special ffiStr MLB annotation.
112 *)
113 val ffi: t option ref
114 val forceUsed: t -> unit
115 val layout: t -> Layout.t
116 end
117 structure FunctorClosure:
118 sig
119 type t
120
121 val apply: (t * Structure.t * string list
122 -> Decs.t * Structure.t option)
123 val argInterface: t -> Interface.t
124 end
125
126 structure InterfaceEnv:
127 sig
128 structure FlexibleTycon:
129 sig
130 type t
131 end
132 structure Scheme:
133 sig
134 type t
135 end
136 structure Status:
137 sig
138 type t
139 end
140 structure TypeStr:
141 sig
142 type t
143 end
144
145 type t
146
147 val extendCon: t * Ast.Con.t * Scheme.t -> unit
148 val extendExn: t * Ast.Con.t * Scheme.t -> unit
149 val extendStrid: t * Ast.Strid.t * Interface.t -> unit
150 val extendTycon: t * Ast.Tycon.t * TypeStr.t -> unit
151 val extendVid: t * Ast.Vid.t * Status.t * Scheme.t -> unit
152 val lookupLongtycon: t * Ast.Longtycon.t -> TypeStr.t option
153 val lookupSigid: t * Ast.Sigid.t -> Interface.t option
154 val makeInterface:
155 t * {isTop: bool} * (unit -> 'a) -> Interface.t * 'a
156 val openInterface: t * Interface.t * Region.t -> unit
157 val rebindTycon: t * Ast.Tycon.t * TypeStr.t -> unit
158 end
159 sharing Interface.FlexibleTycon = InterfaceEnv.FlexibleTycon
160 sharing Interface.Scheme = InterfaceEnv.Scheme
161 sharing Interface.Status = InterfaceEnv.Status
162 sharing Interface.TypeStr = InterfaceEnv.TypeStr
163
164 structure Basis:
165 sig
166 type t
167 val layout: t -> Layout.t
168 end
169
170 type t
171
172 val amInsideFunctor: unit -> bool
173 (* cut keeps only those bindings in the structure that also appear
174 * in the interface. It proceeds recursively on substructures.
175 *)
176 val cut:
177 t * Structure.t * Interface.t
178 * {isFunctor: bool, opaque: bool, prefix: string} * Region.t
179 -> Structure.t * Decs.t
180 val empty: unit -> t
181 val extendBasid: t * Ast.Basid.t * Basis.t -> unit
182 val extendExn: t * Ast.Con.t * CoreML.Con.t * Scheme.t -> unit
183 val extendFctid: t * Ast.Fctid.t * FunctorClosure.t -> unit
184 val extendFix: t * Ast.Vid.t * Ast.Fixity.t -> unit
185 val extendSigid: t * Ast.Sigid.t * Interface.t -> unit
186 val extendStrid: t * Ast.Strid.t * Structure.t -> unit
187 val extendTycon:
188 t * Ast.Tycon.t * TypeStr.t * {forceUsed: bool, isRebind: bool} -> unit
189 val extendVar:
190 t * Ast.Var.t * CoreML.Var.t * Scheme.t * {isRebind: bool} -> unit
191 val extendOverload:
192 t * Ast.Priority.t * Ast.Var.t * (CoreML.Var.t * Scheme.t) vector
193 * Scheme.t
194 -> unit
195 val forceUsed: t -> unit
196 val forceUsedLocal: t * (unit -> 'a) -> 'a
197 val functorClosure:
198 t * Ast.Fctid.t * Interface.t
199 * (Structure.t * string list -> Decs.t * Structure.t option)
200 -> FunctorClosure.t
201 val localAll: t * (unit -> 'a) * ('a -> 'b) -> 'b
202 val localCore: t * (unit -> 'a) * ('a -> 'b) -> 'b
203 val localModule: t * (unit -> 'a) * ('a -> 'b) -> 'b
204 val lookupBasid: t * Ast.Basid.t -> Basis.t option
205 val lookupFctid: t * Ast.Fctid.t -> FunctorClosure.t option
206 val lookupLongcon: t * Ast.Longcon.t -> (CoreML.Con.t * Scheme.t) option
207 val lookupLongexn: t * Ast.Longcon.t -> (CoreML.Con.t * Scheme.t) option
208 val lookupLongstrid: t * Ast.Longstrid.t -> Structure.t option
209 val lookupLongtycon: t * Ast.Longtycon.t -> TypeStr.t option
210 val lookupLongvar: t * Ast.Longvar.t -> (CoreML.Var.t * Scheme.t) option
211 val lookupLongvid: t * Ast.Longvid.t -> (Vid.t * Scheme.t) option
212 val lookupSigid: t * Ast.Sigid.t -> Interface.t option
213 val lookupStrid: t * Ast.Strid.t -> Structure.t option
214 val makeBasis: t * (unit -> 'a) -> 'a * Basis.t
215 val makeInterfaceEnv: t -> InterfaceEnv.t
216 val makeStructure: t * (unit -> 'a) -> 'a * Structure.t
217 val newCons:
218 t * {con: CoreML.Con.t,
219 name: Ast.Con.t,
220 scheme: Scheme.t} vector
221 -> TypeStr.Cons.t
222 (* openStructure (E, S) opens S in the environment E. *)
223 val openStructure: t * Structure.t -> unit
224 (* openBasis (E, B) opens B in the environment E. *)
225 val openBasis: t * Basis.t -> unit
226 val output: t * Out.t * {compact: bool, def: bool, flat: bool, onlyCurrent: bool, prefixUnset: bool} -> unit
227 val peekFix: t * Ast.Vid.t -> Ast.Fixity.t option
228 val peekLongcon: t * Ast.Longcon.t -> (CoreML.Con.t * Scheme.t) option
229 val processDefUse: t -> unit
230 (* scope f evaluates f () in a new scope so that extensions that occur
231 * during f () are forgotten afterwards.
232 * scope works for infixes, types, values, and structures
233 *)
234 val scope: t * (unit -> 'a) -> 'a
235 (* like scope, but works for bases, signatures and functors as well *)
236 val scopeAll: t * (unit -> 'a) -> 'a
237 val makeLayoutPrettyTycon:
238 t * {prefixUnset: bool}
239 -> {destroy: unit -> unit,
240 layoutPrettyTycon: Tycon.t -> Layout.t,
241 setLayoutPrettyTycon: Tycon.t * Layout.t -> unit,
242 loopStr: Structure.t * int * Ast.Strid.t list -> unit}
243 val makeLayoutPrettyTyconAndFlexTycon:
244 t * InterfaceEnv.t * Interface.t option * {prefixUnset: bool}
245 -> {destroy: unit -> unit,
246 layoutPrettyTycon: Tycon.t -> Layout.t,
247 layoutPrettyFlexTycon: Interface.FlexibleTycon.t -> Layout.t,
248 setLayoutPrettyTycon: Tycon.t * Layout.t -> unit}
249 val sizeMessage: t -> Layout.t
250 val snapshot: t -> (unit -> 'a) -> 'a
251 end