Import Debian changes 20180207-1
[hcoop/debian/mlton.git] / mlton / elaborate / type-env.sig
1 (* Copyright (C) 2017 Matthew Fluet.
2 * Copyright (C) 1999-2007 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
10 signature TYPE_ENV_STRUCTS =
11 sig
12 include ATOMS
13 end
14
15 signature TYPE_ENV =
16 sig
17 include TYPE_ENV_STRUCTS
18
19 structure Time:
20 sig
21 type t
22
23 val now: unit -> t
24 val tick: {region: Region.t} -> unit
25 end
26
27 structure Type:
28 sig
29 include TYPE_OPS
30
31 (* can two types be unified? not side-effecting. *)
32 val canUnify: t * t -> bool
33 val checkTime:
34 t * Time.t * {layoutPrettyTycon: Tycon.t -> Layout.t,
35 layoutPrettyTyvar: Tyvar.t -> Layout.t}
36 -> (Layout.t * t * {tycons: Tycon.t list, tyvars: Tyvar.t list}) option
37 val copy: t -> t
38 val deEta: t * Tyvar.t vector -> Tycon.t option
39 val deRecord: t -> (Record.Field.t * t) vector
40 val flexRecord: t SortedRecord.t -> t * (unit -> bool)
41 val hom: t * {con: Tycon.t * 'a vector -> 'a,
42 expandOpaque: bool,
43 record: 'a SortedRecord.t -> 'a,
44 replaceSynonyms: bool,
45 var: Tyvar.t -> 'a} -> 'a
46 val isArrow: t -> bool
47 val isBool: t -> bool
48 val isCharX: t -> bool
49 val isCPointer: t -> bool
50 val isInt: t -> bool
51 val isUnit: t -> bool
52 val isUnknown: t -> bool
53 val layout: t -> Layout.t
54 val layoutPretty:
55 t * {expandOpaque: bool,
56 layoutPrettyTycon: Tycon.t -> Layout.t,
57 layoutPrettyTyvar: Tyvar.t -> Layout.t}
58 -> LayoutPretty.t
59 val makeHom: {con: Tycon.t * 'a vector -> 'a,
60 expandOpaque: bool,
61 var: Tyvar.t -> 'a} -> {destroy: unit -> unit,
62 hom: t -> 'a}
63 val makeLayoutPretty:
64 {expandOpaque: bool,
65 layoutPrettyTycon: Tycon.t -> Layout.t,
66 layoutPrettyTyvar: Tyvar.t -> Layout.t}
67 -> {destroy: unit -> unit,
68 layoutPretty: t -> LayoutPretty.t}
69 val new: unit -> t
70 val record: t SortedRecord.t -> t
71 (* make two types identical (recursively). side-effecting. *)
72 val unify:
73 t * t * {error: Layout.t * Layout.t * {notes: unit -> Layout.t} -> unit,
74 layoutPretty: t -> LayoutPretty.t,
75 layoutPrettyTycon: Tycon.t -> Layout.t,
76 layoutPrettyTyvar: Tyvar.t -> Layout.t}
77 -> unit
78 val unresolvedChar: unit -> t
79 val unresolvedInt: unit -> t
80 val unresolvedReal: unit -> t
81 val unresolvedString: unit -> t
82 val unresolvedWord: unit -> t
83 val var: Tyvar.t -> t
84 end
85 (* sharing type Type.intSize = IntSize.t *)
86 sharing type Type.realSize = RealSize.t
87 sharing type Type.wordSize = WordSize.t
88 sharing type Type.tycon = Tycon.t
89
90 structure Scheme:
91 sig
92 type t
93
94 val admitsEquality: t -> bool
95 val apply: t * Type.t vector -> Type.t
96 val checkEquality: t * {layoutPrettyTycon: Tycon.t -> Layout.t} -> Layout.t option
97 val dest: t -> Tyvar.t vector * Type.t
98 val fresh: t -> Tyvar.t vector * Type.t
99 val fromTycon: Tycon.t -> t
100 val fromType: Type.t -> t
101 val haveUnknowns: t -> bool
102 val instantiate: t -> {args: unit -> Type.t vector,
103 instance: Type.t}
104 val kind: t -> TyconKind.t
105 val layout: t -> Layout.t
106 val make: {canGeneralize: bool,
107 ty: Type.t,
108 tyvars: Tyvar.t vector} -> t
109 val ty: t -> Type.t
110 end
111
112 structure TyvarExt:
113 sig
114 type t
115 val makeString: string * {equality: bool} -> t
116 val makeNoname: {equality: bool} -> t
117 val makeLayoutPretty:
118 unit ->
119 {destroy: unit -> unit,
120 layoutPretty: t -> Layout.t,
121 localInit: t vector -> unit}
122 val makeLayoutPrettyLocal:
123 unit ->
124 {destroy: unit -> unit,
125 layoutPretty: t -> Layout.t,
126 reset: unit -> unit}
127 val makeLike: t -> t
128 end
129 sharing type TyvarExt.t = Tyvar.t
130
131 structure TyconExt:
132 sig
133 type t
134 val admitsEquality: t -> AdmitsEquality.t
135 val kind: t -> TyconKind.t
136 val layoutPrettyDefault: t -> Layout.t
137 val make: {admitsEquality: AdmitsEquality.t,
138 kind: TyconKind.t,
139 name: string,
140 prettyDefault: string,
141 region: Region.t} -> t
142 val makeBogus: {name: string,
143 kind: TyconKind.t,
144 region: Region.t option} -> t
145 val makeLike: t -> t
146 val region: t -> Region.t
147 val scopeNew: (unit -> 'a) -> ('a * t list)
148 val setAdmitsEquality: t * AdmitsEquality.t -> unit
149 val setOpaqueExpansion: t * (Type.t vector -> Type.t) -> unit
150 end
151 sharing type TyconExt.t = Tycon.t
152
153 val close:
154 {region: Region.t}
155 -> (Tyvar.t vector
156 * {isExpansive: bool, ty: Type.t, var: 'a} vector
157 * {error: 'a * Layout.t * Tyvar.t list -> unit,
158 layoutPrettyTycon: Tycon.t -> Layout.t,
159 layoutPrettyTyvar: Tyvar.t -> Layout.t})
160 -> {bound: unit -> Tyvar.t vector,
161 schemes: Scheme.t vector}
162 end