firefly-compiler 0.4.6 → 0.4.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/output/js/ff/compiler/Builder.mjs +444 -444
  2. package/output/js/ff/compiler/Compiler.mjs +416 -416
  3. package/output/js/ff/compiler/Dependencies.mjs +389 -389
  4. package/output/js/ff/compiler/Deriver.mjs +1170 -1170
  5. package/output/js/ff/compiler/Dictionaries.mjs +1309 -1309
  6. package/output/js/ff/compiler/Environment.mjs +1015 -1015
  7. package/output/js/ff/compiler/Inference.mjs +4268 -4268
  8. package/output/js/ff/compiler/JsEmitter.mjs +5391 -5391
  9. package/output/js/ff/compiler/JsImporter.mjs +266 -266
  10. package/output/js/ff/compiler/LspHook.mjs +793 -793
  11. package/output/js/ff/compiler/Main.mjs +1675 -1675
  12. package/output/js/ff/compiler/Parser.mjs +4008 -4008
  13. package/output/js/ff/compiler/Patterns.mjs +927 -927
  14. package/output/js/ff/compiler/Resolver.mjs +2307 -2307
  15. package/output/js/ff/compiler/Substitution.mjs +1150 -1150
  16. package/output/js/ff/compiler/Syntax.mjs +12434 -12434
  17. package/output/js/ff/compiler/Token.mjs +3096 -3096
  18. package/output/js/ff/compiler/Tokenizer.mjs +593 -593
  19. package/output/js/ff/compiler/Unification.mjs +1752 -1752
  20. package/output/js/ff/compiler/Wildcards.mjs +608 -608
  21. package/output/js/ff/compiler/Workspace.mjs +687 -687
  22. package/output/js/ff/core/Any.mjs +143 -143
  23. package/output/js/ff/core/Array.mjs +547 -547
  24. package/output/js/ff/core/AssetSystem.mjs +274 -274
  25. package/output/js/ff/core/Atomic.mjs +154 -154
  26. package/output/js/ff/core/Bool.mjs +152 -152
  27. package/output/js/ff/core/Box.mjs +112 -112
  28. package/output/js/ff/core/BrowserSystem.mjs +126 -126
  29. package/output/js/ff/core/Buffer.mjs +395 -395
  30. package/output/js/ff/core/BuildSystem.mjs +296 -296
  31. package/output/js/ff/core/Channel.mjs +189 -189
  32. package/output/js/ff/core/Char.mjs +149 -149
  33. package/output/js/ff/core/Core.mjs +300 -300
  34. package/output/js/ff/core/Duration.mjs +116 -116
  35. package/output/js/ff/core/Equal.mjs +179 -179
  36. package/output/js/ff/core/Error.mjs +142 -142
  37. package/output/js/ff/core/FileHandle.mjs +150 -150
  38. package/output/js/ff/core/Float.mjs +225 -225
  39. package/output/js/ff/core/HttpClient.mjs +191 -191
  40. package/output/js/ff/core/Instant.mjs +109 -109
  41. package/output/js/ff/core/Int.mjs +265 -265
  42. package/output/js/ff/core/IntMap.mjs +280 -280
  43. package/output/js/ff/core/JsSystem.mjs +238 -238
  44. package/output/js/ff/core/JsValue.mjs +708 -708
  45. package/output/js/ff/core/List.mjs +2334 -2334
  46. package/output/js/ff/core/Lock.mjs +229 -229
  47. package/output/js/ff/core/Log.mjs +163 -163
  48. package/output/js/ff/core/Map.mjs +362 -362
  49. package/output/js/ff/core/NodeSystem.mjs +294 -294
  50. package/output/js/ff/core/Nothing.mjs +104 -104
  51. package/output/js/ff/core/Option.mjs +1015 -1015
  52. package/output/js/ff/core/Ordering.mjs +730 -730
  53. package/output/js/ff/core/Pair.mjs +331 -331
  54. package/output/js/ff/core/Path.mjs +545 -545
  55. package/output/js/ff/core/RbMap.mjs +1940 -1940
  56. package/output/js/ff/core/Serializable.mjs +428 -428
  57. package/output/js/ff/core/Set.mjs +254 -254
  58. package/output/js/ff/core/Show.mjs +205 -205
  59. package/output/js/ff/core/SourceLocation.mjs +229 -229
  60. package/output/js/ff/core/Stack.mjs +529 -529
  61. package/output/js/ff/core/Stream.mjs +1304 -1304
  62. package/output/js/ff/core/String.mjs +365 -365
  63. package/output/js/ff/core/StringMap.mjs +280 -280
  64. package/output/js/ff/core/Task.mjs +320 -320
  65. package/output/js/ff/core/Try.mjs +507 -507
  66. package/output/js/ff/core/Unit.mjs +151 -151
  67. package/package.json +1 -1
  68. package/vscode/package.json +1 -1
@@ -1,2307 +1,2307 @@
1
-
2
-
3
- import * as ff_compiler_Resolver from "../../ff/compiler/Resolver.mjs"
4
-
5
- import * as ff_compiler_LspHook from "../../ff/compiler/LspHook.mjs"
6
-
7
- import * as ff_compiler_Syntax from "../../ff/compiler/Syntax.mjs"
8
-
9
- import * as ff_core_Any from "../../ff/core/Any.mjs"
10
-
11
- import * as ff_core_Array from "../../ff/core/Array.mjs"
12
-
13
- import * as ff_core_AssetSystem from "../../ff/core/AssetSystem.mjs"
14
-
15
- import * as ff_core_Atomic from "../../ff/core/Atomic.mjs"
16
-
17
- import * as ff_core_Bool from "../../ff/core/Bool.mjs"
18
-
19
- import * as ff_core_Box from "../../ff/core/Box.mjs"
20
-
21
- import * as ff_core_BrowserSystem from "../../ff/core/BrowserSystem.mjs"
22
-
23
- import * as ff_core_Buffer from "../../ff/core/Buffer.mjs"
24
-
25
- import * as ff_core_BuildSystem from "../../ff/core/BuildSystem.mjs"
26
-
27
- import * as ff_core_Channel from "../../ff/core/Channel.mjs"
28
-
29
- import * as ff_core_Char from "../../ff/core/Char.mjs"
30
-
31
- import * as ff_core_Core from "../../ff/core/Core.mjs"
32
-
33
- import * as ff_core_Duration from "../../ff/core/Duration.mjs"
34
-
35
- import * as ff_core_Equal from "../../ff/core/Equal.mjs"
36
-
37
- import * as ff_core_Error from "../../ff/core/Error.mjs"
38
-
39
- import * as ff_core_FileHandle from "../../ff/core/FileHandle.mjs"
40
-
41
- import * as ff_core_Float from "../../ff/core/Float.mjs"
42
-
43
- import * as ff_core_HttpClient from "../../ff/core/HttpClient.mjs"
44
-
45
- import * as ff_core_Instant from "../../ff/core/Instant.mjs"
46
-
47
- import * as ff_core_Int from "../../ff/core/Int.mjs"
48
-
49
- import * as ff_core_IntMap from "../../ff/core/IntMap.mjs"
50
-
51
- import * as ff_core_JsSystem from "../../ff/core/JsSystem.mjs"
52
-
53
- import * as ff_core_JsValue from "../../ff/core/JsValue.mjs"
54
-
55
- import * as ff_core_List from "../../ff/core/List.mjs"
56
-
57
- import * as ff_core_Lock from "../../ff/core/Lock.mjs"
58
-
59
- import * as ff_core_Log from "../../ff/core/Log.mjs"
60
-
61
- import * as ff_core_Map from "../../ff/core/Map.mjs"
62
-
63
- import * as ff_core_NodeSystem from "../../ff/core/NodeSystem.mjs"
64
-
65
- import * as ff_core_Nothing from "../../ff/core/Nothing.mjs"
66
-
67
- import * as ff_core_Option from "../../ff/core/Option.mjs"
68
-
69
- import * as ff_core_Ordering from "../../ff/core/Ordering.mjs"
70
-
71
- import * as ff_core_Pair from "../../ff/core/Pair.mjs"
72
-
73
- import * as ff_core_Path from "../../ff/core/Path.mjs"
74
-
75
- import * as ff_core_Serializable from "../../ff/core/Serializable.mjs"
76
-
77
- import * as ff_core_Set from "../../ff/core/Set.mjs"
78
-
79
- import * as ff_core_Show from "../../ff/core/Show.mjs"
80
-
81
- import * as ff_core_SourceLocation from "../../ff/core/SourceLocation.mjs"
82
-
83
- import * as ff_core_Stack from "../../ff/core/Stack.mjs"
84
-
85
- import * as ff_core_Stream from "../../ff/core/Stream.mjs"
86
-
87
- import * as ff_core_String from "../../ff/core/String.mjs"
88
-
89
- import * as ff_core_StringMap from "../../ff/core/StringMap.mjs"
90
-
91
- import * as ff_core_Task from "../../ff/core/Task.mjs"
92
-
93
- import * as ff_core_Try from "../../ff/core/Try.mjs"
94
-
95
- import * as ff_core_Unit from "../../ff/core/Unit.mjs"
96
-
97
- // type Resolver
98
- export function Resolver(variables_, variableLocations_, variants_, types_, typeGenerics_, typeLocations_, asyncTypes_, typeParameters_, traits_, traitLocations_, state_, lspHook_) {
99
- return {variables_, variableLocations_, variants_, types_, typeGenerics_, typeLocations_, asyncTypes_, typeParameters_, traits_, traitLocations_, state_, lspHook_};
100
- }
101
-
102
- // type ResolverState
103
- export function ResolverState(nextUnificationVariableIndex_) {
104
- return {nextUnificationVariableIndex_};
105
- }
106
-
107
-
108
-
109
- export function make_(packagePair_, moduleName_, lspHook_) {
110
- return ff_compiler_Resolver.Resolver(ff_core_List.List_toMap(ff_core_List.Empty(), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_List.List_toMap(ff_core_List.Empty(), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_List.List_toMap(ff_core_List.Empty(), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_List.List_toMap(ff_core_List.Empty(), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_List.List_toMap(ff_core_List.Empty(), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_List.List_toMap(ff_core_List.Empty(), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_List.List_toSet(ff_core_List.Empty(), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_List.List_toSet(ff_core_List.Empty(), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_List.List_toMap(ff_core_List.Empty(), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_List.List_toMap(ff_core_List.Empty(), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_compiler_Resolver.ResolverState(2), lspHook_)
111
- }
112
-
113
- export async function make_$(packagePair_, moduleName_, lspHook_, $task) {
114
- return ff_compiler_Resolver.Resolver(ff_core_List.List_toMap(ff_core_List.Empty(), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_List.List_toMap(ff_core_List.Empty(), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_List.List_toMap(ff_core_List.Empty(), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_List.List_toMap(ff_core_List.Empty(), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_List.List_toMap(ff_core_List.Empty(), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_List.List_toMap(ff_core_List.Empty(), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_List.List_toSet(ff_core_List.Empty(), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_List.List_toSet(ff_core_List.Empty(), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_List.List_toMap(ff_core_List.Empty(), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_List.List_toMap(ff_core_List.Empty(), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_compiler_Resolver.ResolverState(2), lspHook_)
115
- }
116
-
117
- export function Resolver_freshUnificationVariable(self_, at_) {
118
- const result_ = ff_compiler_Syntax.TVariable(at_, self_.state_.nextUnificationVariableIndex_);
119
- self_.state_.nextUnificationVariableIndex_ += 3;
120
- return result_
121
- }
122
-
123
- export function Resolver_resolveModule(self_, module_, otherModules_) {
124
- const moduleNamespace_ = ff_core_String.String_takeWhile(ff_core_String.String_reverse(ff_core_String.String_takeWhile(ff_core_String.String_reverse(ff_core_String.String_replace(module_.file_, "\\", "/")), ((_w1) => {
125
- return (_w1 !== 47)
126
- }))), ((_w1) => {
127
- return (_w1 !== 46)
128
- }));
129
- const self2_ = ff_compiler_Resolver.Resolver_processImports(self_, module_.imports_, otherModules_);
130
- const self3_ = ff_compiler_Resolver.Resolver_processDefinitions(self2_, module_, ff_core_Option.None());
131
- const module2_ = (((_c) => {
132
- return ff_compiler_Syntax.Module(_c.file_, _c.packagePair_, _c.imports_, ff_core_List.List_map(module_.types_, ((_w1) => {
133
- return ff_compiler_Resolver.Resolver_resolveTypeDefinition(self3_, _w1)
134
- })), ff_core_List.List_map(module_.traits_, ((_w1) => {
135
- return ff_compiler_Resolver.Resolver_resolveTraitDefinition(self3_, _w1)
136
- })), ff_core_List.List_map(module_.instances_, ((_w1) => {
137
- return ff_compiler_Resolver.Resolver_resolveInstanceDefinition(self3_, _w1)
138
- })), ff_core_List.List_map(module_.extends_, ((_w1) => {
139
- return ff_compiler_Resolver.Resolver_resolveExtendDefinition(self3_, _w1)
140
- })), ff_core_List.List_map(module_.lets_, ((_w1) => {
141
- return ff_compiler_Resolver.Resolver_resolveLetDefinition(self3_, _w1, true)
142
- })), ff_core_List.List_map(module_.functions_, ((_w1) => {
143
- return ff_compiler_Resolver.Resolver_resolveFunctionDefinition(self3_, _w1, true, false)
144
- })))
145
- }))(module_);
146
- ff_core_List.List_each(module2_.instances_, ((_w1) => {
147
- ff_core_List.List_each(_w1.typeArguments_, ((_w1) => {
148
- ff_compiler_Resolver.Resolver_checkInstanceType(self3_, _w1)
149
- }))
150
- }));
151
- return module2_
152
- }
153
-
154
- export function Resolver_checkInstanceType(self_, type_) {
155
- {
156
- const _1 = type_;
157
- {
158
- if(_1.TConstructor) {
159
- const name_ = _1.name_;
160
- const typeArguments_ = _1.generics_;
161
- if(ff_core_Set.Set_contains(self_.asyncTypes_, name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String)) {
162
- throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(type_.at_, "Traits must not be instantiated for capability types"), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
163
- };
164
- ff_core_List.List_each(typeArguments_, ((_w1) => {
165
- ff_compiler_Resolver.Resolver_checkInstanceType(self_, _w1)
166
- }))
167
- return
168
- }
169
- }
170
- {
171
-
172
- return
173
- }
174
- }
175
- }
176
-
177
- export function Resolver_processImports(self_, imports_, modules_) {
178
- let resolver_ = self_;
179
- ff_core_List.List_each(imports_, ((import_) => {
180
- {
181
- const _1 = ff_core_List.List_find(modules_, ((_w1) => {
182
- return (ff_core_String.String_dropLast(_w1.file_, 3) === import_.file_)
183
- }));
184
- {
185
- if(_1.Some) {
186
- const module_ = _1.value_;
187
- resolver_ = ff_compiler_Resolver.Resolver_processDefinitions(resolver_, module_, ff_core_Option.Some(import_.alias_))
188
- return
189
- }
190
- }
191
- {
192
- if(_1.None) {
193
- throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(import_.at_, ("No such module: " + import_.file_)), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
194
- return
195
- }
196
- }
197
- }
198
- }));
199
- return resolver_
200
- }
201
-
202
- export function Resolver_processDefinitions(self_, module_, importAlias_) {
203
- function entry_(name_, unqualified_) {
204
- const full_ = ((((ff_compiler_Syntax.PackagePair_groupName(module_.packagePair_, ":") + "/") + ff_core_String.String_dropLast(module_.file_, 3)) + ".") + name_);
205
- {
206
- const _1 = importAlias_;
207
- {
208
- if(_1.None) {
209
- return ff_core_List.Link(ff_core_Pair.Pair(name_, full_), ff_core_List.Link(ff_core_Pair.Pair(full_, full_), ff_core_List.Empty()))
210
- return
211
- }
212
- }
213
- {
214
- if(_1.Some) {
215
- const alias_ = _1.value_;
216
- const _guard1 = unqualified_;
217
- if(_guard1) {
218
- return ff_core_List.Link(ff_core_Pair.Pair(((alias_ + ".") + name_), full_), ff_core_List.Link(ff_core_Pair.Pair(name_, full_), ff_core_List.Link(ff_core_Pair.Pair(full_, full_), ff_core_List.Empty())))
219
- return
220
- }
221
- }
222
- }
223
- {
224
- if(_1.Some) {
225
- const alias_ = _1.value_;
226
- return ff_core_List.Link(ff_core_Pair.Pair(((alias_ + ".") + name_), full_), ff_core_List.Link(ff_core_Pair.Pair(full_, full_), ff_core_List.Empty()))
227
- return
228
- }
229
- }
230
- }
231
- }
232
- const isCore_ = (((module_.packagePair_.group_ === "ff") && (module_.packagePair_.name_ === "core")) && (module_.file_ === "Core.ff"));
233
- const lets_ = ff_core_List.List_toMap(ff_core_List.List_flatMap(module_.lets_, ((_w1) => {
234
- return entry_(_w1.name_, isCore_)
235
- })), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
236
- const letLocations_ = ff_core_List.List_toMap(ff_core_List.List_flatMap(module_.lets_, ((d_) => {
237
- return ff_core_List.List_map(entry_(d_.name_, true), ((_w1) => {
238
- return ff_core_Pair.Pair_mapSecond(_w1, ((_) => {
239
- return d_.at_
240
- }))
241
- }))
242
- })), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
243
- const functions_ = ff_core_List.List_toMap(ff_core_List.List_flatMap(module_.functions_, ((_w1) => {
244
- return entry_(_w1.signature_.name_, isCore_)
245
- })), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
246
- const functionLocations_ = ff_core_List.List_toMap(ff_core_List.List_flatMap(module_.functions_, ((d_) => {
247
- return ff_core_List.List_map(entry_(d_.signature_.name_, true), ((_w1) => {
248
- return ff_core_Pair.Pair_mapSecond(_w1, ((_) => {
249
- return d_.at_
250
- }))
251
- }))
252
- })), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
253
- const traitMethods_ = ff_core_List.List_toMap(ff_core_List.List_flatMap(ff_core_List.List_flatMap(module_.traits_, ((_w1) => {
254
- return _w1.methods_
255
- })), ((_w1) => {
256
- return entry_(_w1.name_, false)
257
- })), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
258
- const traitMethodLocations_ = ff_core_List.List_toMap(ff_core_List.List_flatMap(ff_core_List.List_flatMap(module_.traits_, ((_w1) => {
259
- return _w1.methods_
260
- })), ((d_) => {
261
- return ff_core_List.List_map(entry_(d_.name_, true), ((_w1) => {
262
- return ff_core_Pair.Pair_mapSecond(_w1, ((_) => {
263
- return d_.at_
264
- }))
265
- }))
266
- })), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
267
- const traits_ = ff_core_List.List_toMap(ff_core_List.List_flatMap(module_.traits_, ((_w1) => {
268
- return entry_(_w1.name_, true)
269
- })), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
270
- const traitLocations_ = ff_core_List.List_toMap(ff_core_List.List_flatMap(module_.traits_, ((d_) => {
271
- return ff_core_List.List_map(entry_(d_.name_, true), ((_w1) => {
272
- return ff_core_Pair.Pair_mapSecond(_w1, ((_) => {
273
- return d_.at_
274
- }))
275
- }))
276
- })), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
277
- const types_ = ff_core_List.List_toMap(ff_core_List.List_flatMap(module_.types_, ((_w1) => {
278
- return entry_(_w1.name_, true)
279
- })), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
280
- const typeGenerics_ = ff_core_List.List_toMap(ff_core_List.List_flatMap(module_.types_, ((d_) => {
281
- return ff_core_List.List_map(entry_(d_.name_, true), ((p_) => {
282
- return ff_core_Pair.Pair(p_.first_, d_.generics_)
283
- }))
284
- })), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
285
- const typeLocations_ = ff_core_List.List_toMap(ff_core_List.List_flatMap(module_.types_, ((d_) => {
286
- return ff_core_List.List_map(entry_(d_.name_, true), ((_w1) => {
287
- return ff_core_Pair.Pair_mapSecond(_w1, ((_) => {
288
- return d_.at_
289
- }))
290
- }))
291
- })), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
292
- const asyncTypes_ = ff_core_List.List_toSet(ff_core_List.List_flatMap(ff_core_List.List_filter(module_.types_, ((_w1) => {
293
- return ff_core_Option.Option_any(ff_core_List.List_first(_w1.generics_), ((_w1) => {
294
- return (_w1 === "Q$")
295
- }))
296
- })), ((_w1) => {
297
- return ff_core_List.List_map(entry_(_w1.name_, true), ((_w1) => {
298
- return _w1.first_
299
- }))
300
- })), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
301
- const variants_ = ff_core_List.List_toMap(ff_core_List.List_flatMap(ff_core_List.List_flatMap(module_.types_, ((_w1) => {
302
- return _w1.variants_
303
- })), ((_w1) => {
304
- return entry_(_w1.name_, true)
305
- })), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
306
- {
307
- const _1 = self_;
308
- {
309
- const _c = _1;
310
- return ff_compiler_Resolver.Resolver(ff_core_Map.Map_addAll(ff_core_Map.Map_addAll(ff_core_Map.Map_addAll(self_.variables_, lets_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), functions_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), traitMethods_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Map.Map_addAll(ff_core_Map.Map_addAll(ff_core_Map.Map_addAll(self_.variableLocations_, letLocations_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), functionLocations_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), traitMethodLocations_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Map.Map_addAll(self_.variants_, variants_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Map.Map_addAll(self_.types_, types_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Map.Map_addAll(self_.typeGenerics_, typeGenerics_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Map.Map_addAll(self_.typeLocations_, typeLocations_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Set.Set_addAll(self_.asyncTypes_, asyncTypes_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_List.List_toSet(ff_core_List.Empty(), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Map.Map_addAll(self_.traits_, traits_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Map.Map_addAll(self_.traitLocations_, traitLocations_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), self_.state_, _c.lspHook_)
311
- return
312
- }
313
- }
314
- }
315
-
316
- export function Resolver_resolveTypeDefinition(self_, definition_) {
317
- if(ff_compiler_LspHook.LspHook_isAt(self_.lspHook_, definition_.at_)) {
318
- ff_compiler_LspHook.LspHook_emit(self_.lspHook_, ff_compiler_LspHook.ResolveSymbolHook(ff_compiler_LspHook.SymbolHook(definition_.name_, definition_.at_, definition_.at_), ff_core_Option.None()))
319
- };
320
- const generics_ = ff_core_List.List_toMap(ff_core_List.List_map(definition_.generics_, ((g_) => {
321
- return ff_core_Pair.Pair(g_, g_)
322
- })), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
323
- const self2_ = (((_c) => {
324
- return ff_compiler_Resolver.Resolver(_c.variables_, _c.variableLocations_, _c.variants_, ff_core_Map.Map_addAll(self_.types_, generics_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), _c.typeGenerics_, _c.typeLocations_, ff_core_Set.Set_removeAll(self_.asyncTypes_, ff_core_List.List_toSet(definition_.generics_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Set.Set_addAll(self_.typeParameters_, ff_core_List.List_toSet(definition_.generics_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), _c.traits_, _c.traitLocations_, _c.state_, _c.lspHook_)
325
- }))(self_);
326
- if((!ff_core_Option.Option_any(ff_core_List.List_first(definition_.generics_), ((_w1) => {
327
- return (_w1 === "Q$")
328
- })))) {
329
- ff_core_List.List_each(ff_core_List.List_addAll(definition_.commonFields_, ff_core_List.List_flatMap(definition_.variants_, ((_w1) => {
330
- return _w1.fields_
331
- }))), ((f_) => {
332
- if(ff_compiler_Resolver.Resolver_containsAsyncType(self2_, f_.valueType_)) {
333
- throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(f_.at_, "Only capabilities can contain fields of concrete capability types"), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
334
- }
335
- }))
336
- };
337
- {
338
- const _1 = definition_;
339
- {
340
- const _c = _1;
341
- return ff_compiler_Syntax.DType(_c.at_, _c.newtype_, _c.data_, _c.name_, _c.generics_, ff_core_List.List_map(definition_.constraints_, ((_w1) => {
342
- return ff_compiler_Resolver.Resolver_resolveConstraint(self2_, _w1, true)
343
- })), ff_core_List.List_map(definition_.commonFields_, ((f_) => {
344
- const valueType_ = ff_compiler_Resolver.Resolver_resolveType(self2_, f_.valueType_, true);
345
- if((ff_compiler_LspHook.LspHook_isAt(self_.lspHook_, f_.at_) || ff_compiler_LspHook.LspHook_isDefinedAt(self_.lspHook_, f_.at_))) {
346
- ff_compiler_LspHook.LspHook_emit(self_.lspHook_, ff_compiler_LspHook.ResolveVariantFieldHook(ff_compiler_LspHook.SymbolHook(f_.name_, f_.at_, f_.at_), valueType_, true))
347
- };
348
- {
349
- const _1 = f_;
350
- {
351
- const _c = _1;
352
- return ff_compiler_Syntax.Parameter(_c.at_, _c.mutable_, _c.name_, valueType_, ff_core_Option.Option_map(f_.default_, ((_w1) => {
353
- return ff_compiler_Resolver.Resolver_resolveTerm(self2_, _w1, true)
354
- })))
355
- return
356
- }
357
- }
358
- })), ff_core_List.List_map(definition_.variants_, ((v_) => {
359
- if(ff_compiler_LspHook.LspHook_isAt(self_.lspHook_, v_.at_)) {
360
- ff_compiler_LspHook.LspHook_emit(self_.lspHook_, ff_compiler_LspHook.ResolveSymbolHook(ff_compiler_LspHook.SymbolHook(v_.name_, v_.at_, v_.at_), ff_core_Option.None()))
361
- };
362
- {
363
- const _1 = v_;
364
- {
365
- const _c = _1;
366
- return ff_compiler_Syntax.Variant(_c.at_, _c.name_, ff_core_List.List_map(v_.fields_, ((f_) => {
367
- const valueType_ = ff_compiler_Resolver.Resolver_resolveType(self2_, f_.valueType_, true);
368
- if((ff_compiler_LspHook.LspHook_isAt(self_.lspHook_, f_.at_) || ff_compiler_LspHook.LspHook_isDefinedAt(self_.lspHook_, f_.at_))) {
369
- ff_compiler_LspHook.LspHook_emit(self_.lspHook_, ff_compiler_LspHook.ResolveVariantFieldHook(ff_compiler_LspHook.SymbolHook(f_.name_, f_.at_, f_.at_), valueType_, false))
370
- };
371
- {
372
- const _1 = f_;
373
- {
374
- const _c = _1;
375
- return ff_compiler_Syntax.Parameter(_c.at_, _c.mutable_, _c.name_, valueType_, ff_core_Option.Option_map(f_.default_, ((_w1) => {
376
- return ff_compiler_Resolver.Resolver_resolveTerm(self2_, _w1, true)
377
- })))
378
- return
379
- }
380
- }
381
- })))
382
- return
383
- }
384
- }
385
- })))
386
- return
387
- }
388
- }
389
- }
390
-
391
- export function Resolver_resolveTraitDefinition(self_, definition_) {
392
- if((ff_compiler_LspHook.LspHook_isAt(self_.lspHook_, definition_.at_) || ff_compiler_LspHook.LspHook_isDefinedAt(self_.lspHook_, definition_.at_))) {
393
- ff_compiler_LspHook.LspHook_emit(self_.lspHook_, ff_compiler_LspHook.ResolveSymbolHook(ff_compiler_LspHook.SymbolHook(definition_.name_, definition_.at_, definition_.at_), ff_core_Option.None()))
394
- };
395
- const generics_ = ff_core_List.List_toMap(ff_core_List.List_map(definition_.generics_, ((g_) => {
396
- return ff_core_Pair.Pair(g_, g_)
397
- })), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
398
- const self2_ = (((_c) => {
399
- return ff_compiler_Resolver.Resolver(_c.variables_, _c.variableLocations_, _c.variants_, ff_core_Map.Map_addAll(self_.types_, generics_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), _c.typeGenerics_, _c.typeLocations_, ff_core_Set.Set_removeAll(self_.asyncTypes_, ff_core_List.List_toSet(definition_.generics_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Set.Set_addAll(self_.typeParameters_, ff_core_List.List_toSet(definition_.generics_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), _c.traits_, _c.traitLocations_, _c.state_, _c.lspHook_)
400
- }))(self_);
401
- {
402
- const _1 = definition_;
403
- {
404
- const _c = _1;
405
- return ff_compiler_Syntax.DTrait(_c.at_, _c.name_, _c.generics_, ff_core_List.List_map(definition_.constraints_, ((_w1) => {
406
- return ff_compiler_Resolver.Resolver_resolveConstraint(self2_, _w1, true)
407
- })), _c.generatorParameters_, ff_core_List.List_map(definition_.methods_, ((_w1) => {
408
- return ff_compiler_Resolver.Resolver_resolveSignature(self2_, _w1, true, false)
409
- })), ff_core_List.List_map(definition_.methodDefaults_, ((_1) => {
410
- {
411
- const name_ = _1.first_;
412
- const lambda_ = _1.second_;
413
- const signature_ = ff_core_Option.Option_grab(ff_core_List.List_find(definition_.methods_, ((_w1) => {
414
- return (_w1.name_ === name_)
415
- })));
416
- const function1_ = ff_compiler_Syntax.DFunction(signature_.at_, signature_, ff_compiler_Syntax.FireflyTarget(lambda_));
417
- const function2_ = ff_compiler_Resolver.Resolver_resolveFunctionDefinition(self2_, function1_, true, false);
418
- return ff_core_Pair.Pair(name_, (((_1) => {
419
- {
420
- if(_1.FireflyTarget) {
421
- const lambda_ = _1.lambda_;
422
- return lambda_
423
- return
424
- }
425
- }
426
- {
427
- throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(signature_.at_, "Internal error: Expected method default to be a lambda"), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
428
- return
429
- }
430
- }))(function2_.body_))
431
- return
432
- }
433
- })), _c.methodGenerators_)
434
- return
435
- }
436
- }
437
- }
438
-
439
- export function Resolver_resolveInstanceDefinition(self_, definition_) {
440
- const traitDefinedAt_ = ff_core_Option.Option_else(ff_core_Map.Map_get(self_.traitLocations_, definition_.traitName_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), (() => {
441
- return definition_.at_
442
- }));
443
- if((ff_compiler_LspHook.LspHook_isAt(self_.lspHook_, definition_.at_) || ff_compiler_LspHook.LspHook_isDefinedAt(self_.lspHook_, traitDefinedAt_))) {
444
- ff_compiler_LspHook.LspHook_emit(self_.lspHook_, ff_compiler_LspHook.ResolveSymbolHook(ff_compiler_LspHook.SymbolHook(definition_.traitName_, definition_.at_, traitDefinedAt_), ff_core_Option.None()))
445
- };
446
- const generics_ = ff_core_List.List_toMap(ff_core_List.List_map(definition_.generics_, ((g_) => {
447
- return ff_core_Pair.Pair(g_, g_)
448
- })), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
449
- const self2_ = (((_c) => {
450
- return ff_compiler_Resolver.Resolver(_c.variables_, _c.variableLocations_, _c.variants_, ff_core_Map.Map_addAll(self_.types_, generics_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), _c.typeGenerics_, _c.typeLocations_, ff_core_Set.Set_removeAll(self_.asyncTypes_, ff_core_List.List_toSet(definition_.generics_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Set.Set_addAll(self_.typeParameters_, ff_core_List.List_toSet(definition_.generics_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), _c.traits_, _c.traitLocations_, _c.state_, _c.lspHook_)
451
- }))(self_);
452
- const traitName_ = ff_core_Option.Option_else(ff_core_Map.Map_get(self2_.traits_, definition_.traitName_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), (() => {
453
- throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(definition_.at_, ("No such trait: " + definition_.traitName_)), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
454
- }));
455
- {
456
- const _1 = definition_;
457
- {
458
- const _c = _1;
459
- return ff_compiler_Syntax.DInstance(_c.at_, _c.generics_, ff_core_List.List_map(definition_.constraints_, ((_w1) => {
460
- return ff_compiler_Resolver.Resolver_resolveConstraint(self2_, _w1, true)
461
- })), traitName_, ff_core_List.List_map(definition_.typeArguments_, ((_w1) => {
462
- return ff_compiler_Resolver.Resolver_resolveType(self2_, _w1, true)
463
- })), _c.generatorArguments_, ff_core_List.List_map(definition_.methods_, ((_w1) => {
464
- return ff_compiler_Resolver.Resolver_resolveFunctionDefinition(self2_, _w1, true, true)
465
- })), _c.derived_)
466
- return
467
- }
468
- }
469
- }
470
-
471
- export function Resolver_resolveExtendDefinition(self_, definition_) {
472
- const generics_ = ff_core_List.List_toMap(ff_core_List.List_map(definition_.generics_, ((g_) => {
473
- return ff_core_Pair.Pair(g_, g_)
474
- })), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
475
- const selfWithNoQ_ = (((_c) => {
476
- return ff_compiler_Resolver.Resolver(ff_core_Map.Map_add(self_.variables_, definition_.name_, definition_.name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Map.Map_add(self_.variableLocations_, definition_.name_, definition_.at_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), _c.variants_, ff_core_Map.Map_addAll(self_.types_, generics_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), _c.typeGenerics_, _c.typeLocations_, ff_core_Set.Set_removeAll(self_.asyncTypes_, ff_core_List.List_toSet(definition_.generics_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Set.Set_addAll(self_.typeParameters_, ff_core_List.List_toSet(definition_.generics_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), _c.traits_, _c.traitLocations_, _c.state_, _c.lspHook_)
477
- }))(self_);
478
- const selfWithQ_ = (((_c) => {
479
- return ff_compiler_Resolver.Resolver(_c.variables_, _c.variableLocations_, _c.variants_, ff_core_Map.Map_add(selfWithNoQ_.types_, "Q$", "Q$", ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), _c.typeGenerics_, _c.typeLocations_, _c.asyncTypes_, ff_core_Set.Set_add(selfWithNoQ_.typeParameters_, "Q$", ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), _c.traits_, _c.traitLocations_, _c.state_, _c.lspHook_)
480
- }))(selfWithNoQ_);
481
- {
482
- const _1 = definition_;
483
- {
484
- const _c = _1;
485
- return ff_compiler_Syntax.DExtend(_c.at_, _c.name_, _c.generics_, ff_core_List.List_map(definition_.constraints_, ((_w1) => {
486
- return ff_compiler_Resolver.Resolver_resolveConstraint(selfWithQ_, _w1, true)
487
- })), ff_compiler_Resolver.Resolver_resolveType(selfWithQ_, definition_.type_, true), ff_core_List.List_map(definition_.methods_, ((_w1) => {
488
- return ff_compiler_Resolver.Resolver_resolveFunctionDefinition(selfWithNoQ_, _w1, true, false)
489
- })))
490
- return
491
- }
492
- }
493
- }
494
-
495
- export function Resolver_resolveLetDefinition(self_, definition_, topLevel_) {
496
- if((ff_compiler_LspHook.LspHook_isAt(self_.lspHook_, definition_.at_) || ff_compiler_LspHook.LspHook_isDefinedAt(self_.lspHook_, definition_.at_))) {
497
- ff_compiler_LspHook.LspHook_emit(self_.lspHook_, ff_compiler_LspHook.ResolveSymbolHook(ff_compiler_LspHook.SymbolHook(definition_.name_, definition_.at_, definition_.at_), ff_core_Option.None()))
498
- };
499
- {
500
- const _1 = definition_;
501
- {
502
- const _c = _1;
503
- return ff_compiler_Syntax.DLet(_c.at_, _c.name_, ff_compiler_Resolver.Resolver_resolveType(self_, definition_.variableType_, topLevel_), ff_compiler_Resolver.Resolver_resolveTerm(self_, definition_.value_, true))
504
- return
505
- }
506
- }
507
- }
508
-
509
- export function Resolver_resolveTerm(self_, term_, topLevel_) {
510
- {
511
- const self_a = self_;
512
- const term_a = term_;
513
- const topLevel_a = topLevel_;
514
- {
515
- if(term_a.EString) {
516
- return term_
517
- return
518
- }
519
- }
520
- {
521
- if(term_a.EChar) {
522
- return term_
523
- return
524
- }
525
- }
526
- {
527
- if(term_a.EInt) {
528
- return term_
529
- return
530
- }
531
- }
532
- {
533
- if(term_a.EFloat) {
534
- return term_
535
- return
536
- }
537
- }
538
- {
539
- if(term_a.EVariable) {
540
- const e_ = term_a;
541
- if(ff_compiler_LspHook.LspHook_isEnabled(self_.lspHook_)) {
542
- const at_ = ff_core_Option.Option_else(ff_core_Map.Map_get(self_.variableLocations_, e_.name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), (() => {
543
- return e_.at_
544
- }));
545
- if((ff_compiler_LspHook.LspHook_isAt(self_.lspHook_, e_.at_) || ff_compiler_LspHook.LspHook_isDefinedAt(self_.lspHook_, at_))) {
546
- ff_compiler_LspHook.LspHook_emit(self_.lspHook_, ff_compiler_LspHook.ResolveSymbolHook(ff_compiler_LspHook.SymbolHook(e_.name_, e_.at_, at_), ff_core_Option.None()))
547
- }
548
- };
549
- return ff_core_Option.Option_else(ff_core_Option.Option_map(ff_core_Map.Map_get(self_.variables_, e_.name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ((_w1) => {
550
- {
551
- const _1 = e_;
552
- {
553
- const _c = _1;
554
- return ff_compiler_Syntax.EVariable(_c.at_, _w1)
555
- return
556
- }
557
- }
558
- })), (() => {
559
- return term_
560
- }))
561
- return
562
- }
563
- }
564
- {
565
- if(term_a.EList) {
566
- const at_ = term_a.at_;
567
- const t_ = term_a.elementType_;
568
- const items_ = term_a.items_;
569
- return ff_compiler_Syntax.EList(at_, ff_compiler_Resolver.Resolver_resolveType(self_, t_, topLevel_), ff_core_List.List_map(items_, ((_1) => {
570
- {
571
- const item_ = _1.first_;
572
- const spread_ = _1.second_;
573
- return ff_core_Pair.Pair(ff_compiler_Resolver.Resolver_resolveTerm(self_, item_, topLevel_), spread_)
574
- return
575
- }
576
- })))
577
- return
578
- }
579
- }
580
- {
581
- if(term_a.EVariant) {
582
- const at_ = term_a.at_;
583
- const name_ = term_a.name_;
584
- const typeArguments_ = term_a.typeArguments_;
585
- const arguments_ = term_a.arguments_;
586
- return ff_compiler_Syntax.EVariant(at_, ff_core_Option.Option_else(ff_core_Map.Map_get(self_.variants_, name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), (() => {
587
- return name_
588
- })), ff_core_List.List_map(typeArguments_, ((_w1) => {
589
- return ff_compiler_Resolver.Resolver_resolveType(self_, _w1, topLevel_)
590
- })), ff_core_Option.Option_map(arguments_, ((_w1) => {
591
- return ff_core_List.List_map(_w1, ((a_) => {
592
- {
593
- const _1 = a_;
594
- {
595
- const _c = _1;
596
- return ff_compiler_Syntax.Argument(_c.at_, _c.name_, ff_compiler_Resolver.Resolver_resolveTerm(self_, a_.value_, topLevel_))
597
- return
598
- }
599
- }
600
- }))
601
- })))
602
- return
603
- }
604
- }
605
- {
606
- if(term_a.EVariantIs) {
607
- const at_ = term_a.at_;
608
- const name_ = term_a.name_;
609
- const typeArguments_ = term_a.typeArguments_;
610
- return ff_compiler_Syntax.EVariantIs(at_, ff_core_Option.Option_else(ff_core_Map.Map_get(self_.variants_, name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), (() => {
611
- throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(at_, ("No such variant: " + name_)), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
612
- })), ff_core_List.List_map(typeArguments_, ((_w1) => {
613
- return ff_compiler_Resolver.Resolver_resolveType(self_, _w1, topLevel_)
614
- })))
615
- return
616
- }
617
- }
618
- {
619
- if(term_a.ECopy) {
620
- const at_ = term_a.at_;
621
- const name_ = term_a.name_;
622
- const record_ = term_a.record_;
623
- const arguments_ = term_a.arguments_;
624
- return ff_compiler_Syntax.ECopy(at_, ff_core_Option.Option_else(ff_core_Map.Map_get(self_.variants_, name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), (() => {
625
- return name_
626
- })), ff_compiler_Resolver.Resolver_resolveTerm(self_, record_, topLevel_), ff_core_List.List_map(arguments_, ((f_) => {
627
- {
628
- const _1 = f_;
629
- {
630
- const _c = _1;
631
- return ff_compiler_Syntax.Field(_c.at_, _c.name_, ff_compiler_Resolver.Resolver_resolveTerm(self_, f_.value_, topLevel_))
632
- return
633
- }
634
- }
635
- })))
636
- return
637
- }
638
- }
639
- {
640
- if(term_a.EField) {
641
- const e_ = term_a;
642
- {
643
- const _1 = e_;
644
- {
645
- const _c = _1;
646
- return ff_compiler_Syntax.EField(_c.at_, _c.newtype_, ff_compiler_Resolver.Resolver_resolveTerm(self_, e_.record_, topLevel_), _c.field_)
647
- return
648
- }
649
- }
650
- return
651
- }
652
- }
653
- {
654
- if(term_a.ELambda) {
655
- const at_ = term_a.at_;
656
- const lambdaAt_ = term_a.lambda_.at_;
657
- const cases_ = term_a.lambda_.cases_;
658
- const effect_ = ff_compiler_Resolver.Resolver_makeEffectArgument(self_, lambdaAt_, topLevel_);
659
- return ff_compiler_Syntax.ELambda(at_, ff_compiler_Syntax.Lambda(lambdaAt_, effect_, ff_core_List.List_map(cases_, ((_w1) => {
660
- return ff_compiler_Resolver.Resolver_resolveCase(self_, _w1, topLevel_)
661
- }))))
662
- return
663
- }
664
- }
665
- {
666
- if(term_a.EPipe) {
667
- const at_ = term_a.at_;
668
- const value_ = term_a.value_;
669
- const effect_ = term_a.effect_;
670
- const function_ = term_a.function_;
671
- return ff_compiler_Syntax.EPipe(at_, ff_compiler_Resolver.Resolver_resolveTerm(self_, value_, topLevel_), ff_compiler_Resolver.Resolver_resolveType(self_, effect_, topLevel_), ff_compiler_Resolver.Resolver_resolveTerm(self_, function_, topLevel_))
672
- return
673
- }
674
- }
675
- {
676
- if(term_a.ECall) {
677
- const at_ = term_a.at_;
678
- if(term_a.target_.DynamicCall) {
679
- const target_ = term_a.target_;
680
- const effect_ = term_a.effect_;
681
- const typeArguments_ = term_a.typeArguments_;
682
- const arguments_ = term_a.arguments_;
683
- const dictionaries_ = term_a.dictionaries_;
684
- return ff_compiler_Syntax.ECall(at_, (((_c) => {
685
- return ff_compiler_Syntax.DynamicCall(ff_compiler_Resolver.Resolver_resolveTerm(self_, target_.function_, topLevel_), _c.tailCall_)
686
- }))(target_), ff_compiler_Resolver.Resolver_resolveType(self_, effect_, topLevel_), ff_core_List.List_map(typeArguments_, ((_w1) => {
687
- return ff_compiler_Resolver.Resolver_resolveType(self_, _w1, topLevel_)
688
- })), ff_core_List.List_map(arguments_, ((a_) => {
689
- {
690
- const _1 = a_;
691
- {
692
- const _c = _1;
693
- return ff_compiler_Syntax.Argument(_c.at_, _c.name_, ff_compiler_Resolver.Resolver_resolveTerm(self_, a_.value_, topLevel_))
694
- return
695
- }
696
- }
697
- })), dictionaries_)
698
- return
699
- }
700
- }
701
- }
702
- {
703
- if(term_a.ECall) {
704
- const at_ = term_a.at_;
705
- if(term_a.target_.StaticCall) {
706
- throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(at_, "Internal error: Static calls not expected in the Resolver phase"), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
707
- return
708
- }
709
- }
710
- }
711
- {
712
- if(term_a.ERecord) {
713
- const at_ = term_a.at_;
714
- const fields_ = term_a.fields_;
715
- return ff_compiler_Syntax.ERecord(at_, ff_core_List.List_map(fields_, ((f_) => {
716
- {
717
- const _1 = f_;
718
- {
719
- const _c = _1;
720
- return ff_compiler_Syntax.Field(_c.at_, _c.name_, ff_compiler_Resolver.Resolver_resolveTerm(self_, f_.value_, topLevel_))
721
- return
722
- }
723
- }
724
- })))
725
- return
726
- }
727
- }
728
- {
729
- if(term_a.EWildcard) {
730
- const e_ = term_a;
731
- if((e_.index_ === 0)) {
732
- throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(e_.at_, "Unbound wildcard"), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
733
- };
734
- {
735
- const _1 = e_;
736
- {
737
- const _c = _1;
738
- return ff_compiler_Syntax.EWildcard(_c.at_, _c.index_)
739
- return
740
- }
741
- }
742
- return
743
- }
744
- }
745
- {
746
- if(term_a.EFunctions) {
747
- const at_ = term_a.at_;
748
- const functions_ = term_a.functions_;
749
- const body_ = term_a.body_;
750
- const functionMap_ = ff_core_List.List_toMap(ff_core_List.List_map(ff_core_List.List_map(functions_, ((_w1) => {
751
- return _w1.signature_.name_
752
- })), ((name_) => {
753
- return ff_core_Pair.Pair(name_, name_)
754
- })), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
755
- const locationMap_ = ff_core_List.List_toMap(ff_core_List.List_map(ff_core_List.List_map(functions_, ((_w1) => {
756
- return _w1.signature_
757
- })), ((s_) => {
758
- return ff_core_Pair.Pair(s_.name_, s_.at_)
759
- })), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
760
- const self2_ = (((_c) => {
761
- return ff_compiler_Resolver.Resolver(ff_core_Map.Map_addAll(self_.variables_, functionMap_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Map.Map_addAll(self_.variableLocations_, locationMap_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), _c.variants_, _c.types_, _c.typeGenerics_, _c.typeLocations_, _c.asyncTypes_, _c.typeParameters_, _c.traits_, _c.traitLocations_, _c.state_, _c.lspHook_)
762
- }))(self_);
763
- return ff_compiler_Syntax.EFunctions(at_, ff_core_List.List_map(functions_, ((_w1) => {
764
- return ff_compiler_Resolver.Resolver_resolveFunctionDefinition(self2_, _w1, topLevel_, false)
765
- })), ff_compiler_Resolver.Resolver_resolveTerm(self2_, body_, topLevel_))
766
- return
767
- }
768
- }
769
- {
770
- if(term_a.ELet) {
771
- const e_ = term_a;
772
- const self2_ = (((_c) => {
773
- return ff_compiler_Resolver.Resolver(ff_core_Map.Map_add(self_.variables_, e_.name_, e_.name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Map.Map_add(self_.variableLocations_, e_.name_, e_.at_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), _c.variants_, _c.types_, _c.typeGenerics_, _c.typeLocations_, _c.asyncTypes_, _c.typeParameters_, _c.traits_, _c.traitLocations_, _c.state_, _c.lspHook_)
774
- }))(self_);
775
- if(ff_compiler_LspHook.LspHook_isEnabled(self_.lspHook_)) {
776
- if((ff_compiler_LspHook.LspHook_isAt(self_.lspHook_, e_.at_) || ff_compiler_LspHook.LspHook_isDefinedAt(self_.lspHook_, e_.at_))) {
777
- ff_compiler_LspHook.LspHook_emit(self_.lspHook_, ff_compiler_LspHook.ResolveSymbolHook(ff_compiler_LspHook.SymbolHook(e_.name_, e_.at_, e_.at_), ff_core_Option.None()))
778
- }
779
- };
780
- {
781
- const _1 = e_;
782
- {
783
- const _c = _1;
784
- return ff_compiler_Syntax.ELet(_c.at_, _c.mutable_, _c.name_, ff_compiler_Resolver.Resolver_resolveType(self_, e_.valueType_, topLevel_), ff_compiler_Resolver.Resolver_resolveTerm(self_, e_.value_, topLevel_), ff_compiler_Resolver.Resolver_resolveTerm(self2_, e_.body_, topLevel_))
785
- return
786
- }
787
- }
788
- return
789
- }
790
- }
791
- {
792
- if(term_a.ESequential) {
793
- const at_ = term_a.at_;
794
- const before_ = term_a.before_;
795
- const after_ = term_a.after_;
796
- return ff_compiler_Syntax.ESequential(at_, ff_compiler_Resolver.Resolver_resolveTerm(self_, before_, topLevel_), ff_compiler_Resolver.Resolver_resolveTerm(self_, after_, topLevel_))
797
- return
798
- }
799
- }
800
- {
801
- if(term_a.EAssign) {
802
- const at_ = term_a.at_;
803
- const operator_ = term_a.operator_;
804
- const variable_ = term_a.variable_;
805
- const value_ = term_a.value_;
806
- return ff_compiler_Syntax.EAssign(at_, operator_, ff_core_Option.Option_else(ff_core_Map.Map_get(self_.variables_, variable_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), (() => {
807
- throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(at_, ("No such variable: " + variable_)), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
808
- })), ff_compiler_Resolver.Resolver_resolveTerm(self_, value_, topLevel_))
809
- return
810
- }
811
- }
812
- {
813
- if(term_a.EAssignField) {
814
- const at_ = term_a.at_;
815
- const operator_ = term_a.operator_;
816
- const record_ = term_a.record_;
817
- const field_ = term_a.field_;
818
- const value_ = term_a.value_;
819
- return ff_compiler_Syntax.EAssignField(at_, operator_, ff_compiler_Resolver.Resolver_resolveTerm(self_, record_, topLevel_), field_, ff_compiler_Resolver.Resolver_resolveTerm(self_, value_, topLevel_))
820
- return
821
- }
822
- }
823
- }
824
- }
825
-
826
- export function Resolver_resolveType(self_, type_, topLevel_) {
827
- {
828
- const self_a = self_;
829
- const type_a = type_;
830
- const topLevel_a = topLevel_;
831
- {
832
- if(type_a.TVariable) {
833
- return type_
834
- return
835
- }
836
- }
837
- {
838
- if(type_a.TConstructor) {
839
- const constructor_ = type_a;
840
- if(ff_compiler_LspHook.LspHook_isEnabled(self_.lspHook_)) {
841
- const at_ = ff_core_Option.Option_else(ff_core_Map.Map_get(self_.typeLocations_, constructor_.name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), (() => {
842
- return type_.at_
843
- }));
844
- if((ff_compiler_LspHook.LspHook_isAt(self_.lspHook_, type_.at_) || ff_compiler_LspHook.LspHook_isDefinedAt(self_.lspHook_, at_))) {
845
- ff_compiler_LspHook.LspHook_emit(self_.lspHook_, ff_compiler_LspHook.ResolveTypeHook(self_.types_, self_.typeGenerics_, ff_compiler_LspHook.SymbolHook(constructor_.name_, type_.at_, at_), type_))
846
- }
847
- };
848
- const name_ = (ff_core_String.String_contains(constructor_.name_, "$")
849
- ? constructor_.name_
850
- : ff_core_Option.Option_else(ff_core_Map.Map_get(self_.types_, constructor_.name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), (() => {
851
- if((!ff_compiler_LspHook.LspHook_isEnabled(self_.lspHook_))) {
852
- throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(constructor_.at_, ("No such type: " + constructor_.name_)), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
853
- } else {
854
- return constructor_.name_
855
- }
856
- })));
857
- const isFunctionType_ = ff_core_String.String_startsWith(name_, "Function$", 0);
858
- const effect_ = ((isFunctionType_ || ff_core_Set.Set_contains(self_.asyncTypes_, constructor_.name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String))
859
- ? ff_core_List.Link(ff_compiler_Resolver.Resolver_makeEffectArgument(self_, constructor_.at_, topLevel_), ff_core_List.Empty())
860
- : ff_core_List.Empty());
861
- const generics_ = ff_core_List.List_map(constructor_.generics_, ((_w1) => {
862
- return ff_compiler_Resolver.Resolver_resolveType(self_, _w1, topLevel_)
863
- }));
864
- if(isFunctionType_) {
865
- const arguments_ = ff_core_List.List_dropLast(generics_, 1);
866
- const returnType_ = ff_core_List.List_grabLast(generics_);
867
- {
868
- const _1 = constructor_;
869
- {
870
- const _c = _1;
871
- return ff_compiler_Syntax.TConstructor(_c.at_, name_, ff_core_List.List_addAll(effect_, ff_core_List.List_addAll(arguments_, ff_core_List.Link(returnType_, ff_core_List.Empty()))))
872
- return
873
- }
874
- }
875
- } else {
876
- {
877
- const _1 = constructor_;
878
- {
879
- const _c = _1;
880
- return ff_compiler_Syntax.TConstructor(_c.at_, name_, ff_core_List.List_addAll(effect_, generics_))
881
- return
882
- }
883
- }
884
- }
885
- return
886
- }
887
- }
888
- }
889
- }
890
-
891
- export function Resolver_makeEffectArgument(self_, at_, topLevel_) {
892
- if(topLevel_) {
893
- if((!ff_core_Set.Set_contains(self_.typeParameters_, "Q$", ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String))) {
894
- return ff_compiler_Syntax.TConstructor(at_, "ff:core/Nothing.Nothing", ff_core_List.Empty())
895
- } else {
896
- return ff_compiler_Syntax.TConstructor(at_, "Q$", ff_core_List.Empty())
897
- }
898
- } else {
899
- return ff_compiler_Resolver.Resolver_freshUnificationVariable(self_, at_)
900
- }
901
- }
902
-
903
- export function Resolver_resolveConstraint(self_, constraint_, topLevel_) {
904
- const traitDefinedAt_ = ff_core_Option.Option_else(ff_core_Map.Map_get(self_.traitLocations_, constraint_.name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), (() => {
905
- return constraint_.at_
906
- }));
907
- if((ff_compiler_LspHook.LspHook_isAt(self_.lspHook_, constraint_.at_) || ff_compiler_LspHook.LspHook_isDefinedAt(self_.lspHook_, traitDefinedAt_))) {
908
- ff_compiler_LspHook.LspHook_emit(self_.lspHook_, ff_compiler_LspHook.ResolveConstraintHook(ff_compiler_LspHook.SymbolHook(constraint_.name_, constraint_.at_, traitDefinedAt_), constraint_))
909
- };
910
- const name_ = ff_core_Option.Option_else(ff_core_Map.Map_get(self_.traits_, constraint_.name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), (() => {
911
- throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(constraint_.at_, ("No such trait: " + constraint_.name_)), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
912
- }));
913
- {
914
- const _1 = constraint_;
915
- {
916
- const _c = _1;
917
- return ff_compiler_Syntax.Constraint(_c.at_, name_, ff_core_List.List_map(constraint_.generics_, ((_w1) => {
918
- return ff_compiler_Resolver.Resolver_resolveType(self_, _w1, topLevel_)
919
- })))
920
- return
921
- }
922
- }
923
- }
924
-
925
- export function Resolver_resolveFunctionDefinition(self_, definition_, topLevel_, isInstanceMethod_) {
926
- const signature_ = ff_compiler_Resolver.Resolver_resolveSignature(self_, definition_.signature_, topLevel_, isInstanceMethod_);
927
- const self2_ = ff_compiler_Resolver.Resolver_withSignature(self_, signature_);
928
- const body_ = ff_compiler_Syntax.Target_mapFirefly(definition_.body_, ((lambda_) => {
929
- {
930
- const _1 = lambda_;
931
- {
932
- const _c = _1;
933
- return ff_compiler_Syntax.Lambda(_c.at_, signature_.effect_, ff_core_List.List_map(lambda_.cases_, ((_w1) => {
934
- return ff_compiler_Resolver.Resolver_resolveCase(self2_, _w1, false)
935
- })))
936
- return
937
- }
938
- }
939
- }));
940
- return ff_compiler_Syntax.DFunction(definition_.at_, signature_, body_)
941
- }
942
-
943
- export function Resolver_resolveSignature(self_, signature_, topLevel_, isInstanceMethod_) {
944
- if((ff_compiler_LspHook.LspHook_isAt(self_.lspHook_, signature_.at_) || ff_compiler_LspHook.LspHook_isDefinedAt(self_.lspHook_, signature_.at_))) {
945
- ff_compiler_LspHook.LspHook_emit(self_.lspHook_, ff_compiler_LspHook.ResolveSignatureHook(signature_, isInstanceMethod_))
946
- };
947
- const newSignature_ = (topLevel_
948
- ? (((_c) => {
949
- return ff_compiler_Syntax.Signature(_c.at_, _c.name_, _c.member_, ff_core_List.Link("Q$", signature_.generics_), _c.constraints_, _c.parameters_, _c.returnType_, ff_compiler_Syntax.TConstructor(signature_.at_, "Q$", ff_core_List.Empty()))
950
- }))(signature_)
951
- : (((_c) => {
952
- return ff_compiler_Syntax.Signature(_c.at_, _c.name_, _c.member_, _c.generics_, _c.constraints_, _c.parameters_, _c.returnType_, ff_compiler_Resolver.Resolver_freshUnificationVariable(self_, signature_.at_))
953
- }))(signature_));
954
- ff_core_Option.Option_each(ff_core_List.List_find(newSignature_.generics_, ((name_) => {
955
- return ff_core_Set.Set_contains(self_.typeParameters_, name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String)
956
- })), ((name_) => {
957
- throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(signature_.at_, (("Type parameter " + name_) + " is already in scope")), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
958
- }));
959
- const self2_ = ff_compiler_Resolver.Resolver_withSignature(self_, newSignature_);
960
- {
961
- const _1 = newSignature_;
962
- {
963
- const _c = _1;
964
- return ff_compiler_Syntax.Signature(_c.at_, _c.name_, _c.member_, _c.generics_, ff_core_List.List_map(newSignature_.constraints_, ((_w1) => {
965
- return ff_compiler_Resolver.Resolver_resolveConstraint(self2_, _w1, topLevel_)
966
- })), ff_core_List.List_map(newSignature_.parameters_, ((p_) => {
967
- {
968
- const _1 = p_;
969
- {
970
- const _c = _1;
971
- return ff_compiler_Syntax.Parameter(_c.at_, _c.mutable_, _c.name_, ff_compiler_Resolver.Resolver_resolveType(self2_, p_.valueType_, topLevel_), ff_core_Option.Option_map(p_.default_, ((_w1) => {
972
- return ff_compiler_Resolver.Resolver_resolveTerm(self2_, _w1, topLevel_)
973
- })))
974
- return
975
- }
976
- }
977
- })), ff_compiler_Resolver.Resolver_resolveType(self2_, newSignature_.returnType_, topLevel_), _c.effect_)
978
- return
979
- }
980
- }
981
- }
982
-
983
- export function Resolver_withSignature(self_, signature_) {
984
- const variableMap_ = ff_core_List.List_toMap(ff_core_List.List_map(ff_core_List.List_map(signature_.parameters_, ((_w1) => {
985
- return _w1.name_
986
- })), ((name_) => {
987
- return ff_core_Pair.Pair(name_, name_)
988
- })), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
989
- const variableLocationMap_ = ff_core_List.List_toMap(ff_core_List.List_map(signature_.parameters_, ((p_) => {
990
- return ff_core_Pair.Pair(p_.name_, p_.at_)
991
- })), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
992
- const typeMap_ = ff_core_List.List_toMap(ff_core_List.List_map(signature_.generics_, ((name_) => {
993
- return ff_core_Pair.Pair(name_, name_)
994
- })), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
995
- {
996
- const _1 = self_;
997
- {
998
- const _c = _1;
999
- return ff_compiler_Resolver.Resolver(ff_core_Map.Map_addAll(self_.variables_, variableMap_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Map.Map_addAll(self_.variableLocations_, variableLocationMap_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), _c.variants_, ff_core_Map.Map_addAll(self_.types_, typeMap_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), _c.typeGenerics_, _c.typeLocations_, ff_core_Set.Set_removeAll(self_.asyncTypes_, ff_core_List.List_toSet(signature_.generics_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Set.Set_addAll(self_.typeParameters_, ff_core_List.List_toSet(signature_.generics_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), _c.traits_, _c.traitLocations_, _c.state_, _c.lspHook_)
1000
- return
1001
- }
1002
- }
1003
- }
1004
-
1005
- export function Resolver_resolveCase(self_, case_, topLevel_) {
1006
- function findVariables_(pattern_) {
1007
- {
1008
- const pattern_a = pattern_;
1009
- {
1010
- if(pattern_a.PString) {
1011
- return ff_core_Map.empty_()
1012
- return
1013
- }
1014
- }
1015
- {
1016
- if(pattern_a.PInt) {
1017
- return ff_core_Map.empty_()
1018
- return
1019
- }
1020
- }
1021
- {
1022
- if(pattern_a.PChar) {
1023
- return ff_core_Map.empty_()
1024
- return
1025
- }
1026
- }
1027
- {
1028
- if(pattern_a.PVariable) {
1029
- const at_ = pattern_a.at_;
1030
- if(pattern_a.name_.Some) {
1031
- const name_ = pattern_a.name_.value_;
1032
- return ff_core_List.List_toMap(ff_core_List.Link(ff_core_Pair.Pair(name_, ff_core_Pair.Pair(at_, name_)), ff_core_List.Empty()), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String)
1033
- return
1034
- }
1035
- }
1036
- }
1037
- {
1038
- if(pattern_a.PVariable) {
1039
- if(pattern_a.name_.None) {
1040
- return ff_core_Map.empty_()
1041
- return
1042
- }
1043
- }
1044
- }
1045
- {
1046
- if(pattern_a.PVariant) {
1047
- const patterns_ = pattern_a.patterns_;
1048
- return ff_core_List.List_foldLeft(ff_core_List.List_map(patterns_, ((pattern_) => {
1049
- return findVariables_(pattern_)
1050
- })), ff_core_Map.empty_(), ((_w1, _w2) => {
1051
- return ff_core_Map.Map_addAll(_w1, _w2, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String)
1052
- }))
1053
- return
1054
- }
1055
- }
1056
- {
1057
- if(pattern_a.PVariantAs) {
1058
- const at_ = pattern_a.at_;
1059
- const variableAt_ = pattern_a.variableAt_;
1060
- const variable_ = pattern_a.variable_;
1061
- return ff_core_List.List_toMap(ff_core_List.List_map(ff_core_Option.Option_toList(variable_), ((x_) => {
1062
- return ff_core_Pair.Pair(x_, ff_core_Pair.Pair(variableAt_, x_))
1063
- })), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String)
1064
- return
1065
- }
1066
- }
1067
- {
1068
- if(pattern_a.PAlias) {
1069
- const at_ = pattern_a.at_;
1070
- const pattern_ = pattern_a.pattern_;
1071
- const variable_ = pattern_a.variable_;
1072
- return ff_core_Map.Map_addAll(ff_core_List.List_toMap(ff_core_List.Link(ff_core_Pair.Pair(variable_, ff_core_Pair.Pair(at_, variable_)), ff_core_List.Empty()), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), findVariables_(pattern_), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String)
1073
- return
1074
- }
1075
- }
1076
- }
1077
- }
1078
- const variableMap_ = ff_core_List.List_foldLeft(ff_core_List.List_map(case_.patterns_, ((pattern_) => {
1079
- return findVariables_(pattern_)
1080
- })), ff_core_Map.empty_(), ((_w1, _w2) => {
1081
- return ff_core_Map.Map_addAll(_w1, _w2, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String)
1082
- }));
1083
- let guards_ = ff_core_List.Empty();
1084
- const variableMap2_ = ff_core_List.List_foldLeft(case_.guards_, variableMap_, ((variableMap1_, g_) => {
1085
- const self2_ = (((_c) => {
1086
- return ff_compiler_Resolver.Resolver(ff_core_Map.Map_addAll(self_.variables_, ff_core_Map.Map_mapValues(variableMap1_, ((_, p_) => {
1087
- return p_.second_
1088
- }), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Map.Map_addAll(self_.variableLocations_, ff_core_Map.Map_mapValues(variableMap1_, ((_, p_) => {
1089
- return p_.first_
1090
- }), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), _c.variants_, _c.types_, _c.typeGenerics_, _c.typeLocations_, _c.asyncTypes_, _c.typeParameters_, _c.traits_, _c.traitLocations_, _c.state_, _c.lspHook_)
1091
- }))(self_);
1092
- const guard_ = (((_c) => {
1093
- return ff_compiler_Syntax.MatchGuard(_c.at_, ff_compiler_Resolver.Resolver_resolveTerm(self2_, g_.term_, topLevel_), ff_compiler_Resolver.Resolver_resolvePattern(self2_, g_.pattern_))
1094
- }))(g_);
1095
- guards_ = ff_core_List.Link(guard_, guards_);
1096
- return ff_core_Map.Map_addAll(variableMap1_, findVariables_(guard_.pattern_), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String)
1097
- }));
1098
- const self3_ = (((_c) => {
1099
- return ff_compiler_Resolver.Resolver(ff_core_Map.Map_addAll(self_.variables_, ff_core_Map.Map_mapValues(variableMap2_, ((_, p_) => {
1100
- return p_.second_
1101
- }), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Map.Map_addAll(self_.variableLocations_, ff_core_Map.Map_mapValues(variableMap2_, ((_, p_) => {
1102
- return p_.first_
1103
- }), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), _c.variants_, _c.types_, _c.typeGenerics_, _c.typeLocations_, _c.asyncTypes_, _c.typeParameters_, _c.traits_, _c.traitLocations_, _c.state_, _c.lspHook_)
1104
- }))(self_);
1105
- return ff_compiler_Syntax.MatchCase(case_.at_, ff_core_List.List_map(case_.patterns_, ((_w1) => {
1106
- return ff_compiler_Resolver.Resolver_resolvePattern(self_, _w1)
1107
- })), ff_core_List.List_reverse(guards_), ff_compiler_Resolver.Resolver_resolveTerm(self3_, case_.body_, topLevel_))
1108
- }
1109
-
1110
- export function Resolver_resolvePattern(self_, pattern_) {
1111
- {
1112
- const self_a = self_;
1113
- const pattern_a = pattern_;
1114
- {
1115
- if(pattern_a.PString) {
1116
- return pattern_
1117
- return
1118
- }
1119
- }
1120
- {
1121
- if(pattern_a.PInt) {
1122
- return pattern_
1123
- return
1124
- }
1125
- }
1126
- {
1127
- if(pattern_a.PChar) {
1128
- return pattern_
1129
- return
1130
- }
1131
- }
1132
- {
1133
- if(pattern_a.PVariable) {
1134
- return pattern_
1135
- return
1136
- }
1137
- }
1138
- {
1139
- if(pattern_a.PVariant) {
1140
- const at_ = pattern_a.at_;
1141
- const name_ = pattern_a.name_;
1142
- const patterns_ = pattern_a.patterns_;
1143
- const newName_ = ff_core_Option.Option_else(ff_core_Map.Map_get(self_.variants_, name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), (() => {
1144
- return name_
1145
- }));
1146
- const newPatterns_ = ff_core_List.List_map(patterns_, ((_w1) => {
1147
- return ff_compiler_Resolver.Resolver_resolvePattern(self_, _w1)
1148
- }));
1149
- return ff_compiler_Syntax.PVariant(at_, newName_, newPatterns_)
1150
- return
1151
- }
1152
- }
1153
- {
1154
- if(pattern_a.PVariantAs) {
1155
- const at_ = pattern_a.at_;
1156
- const name_ = pattern_a.name_;
1157
- const variableAt_ = pattern_a.variableAt_;
1158
- const variable_ = pattern_a.variable_;
1159
- const newName_ = ff_core_Option.Option_else(ff_core_Map.Map_get(self_.variants_, name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), (() => {
1160
- return name_
1161
- }));
1162
- return ff_compiler_Syntax.PVariantAs(at_, newName_, variableAt_, variable_)
1163
- return
1164
- }
1165
- }
1166
- {
1167
- if(pattern_a.PAlias) {
1168
- const at_ = pattern_a.at_;
1169
- const pattern_ = pattern_a.pattern_;
1170
- const variable_ = pattern_a.variable_;
1171
- const newPattern_ = ff_compiler_Resolver.Resolver_resolvePattern(self_, pattern_);
1172
- return ff_compiler_Syntax.PAlias(at_, newPattern_, variable_)
1173
- return
1174
- }
1175
- }
1176
- }
1177
- }
1178
-
1179
- export function Resolver_containsAsyncType(self_, type_) {
1180
- {
1181
- const self_a = self_;
1182
- const type_a = type_;
1183
- {
1184
- if(type_a.TVariable) {
1185
- return false
1186
- return
1187
- }
1188
- }
1189
- {
1190
- if(type_a.TConstructor) {
1191
- const constructor_ = type_a;
1192
- const name_ = (ff_core_String.String_contains(constructor_.name_, "$")
1193
- ? constructor_.name_
1194
- : ff_core_Option.Option_else(ff_core_Map.Map_get(self_.types_, constructor_.name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), (() => {
1195
- if(ff_compiler_LspHook.LspHook_isEnabled(self_.lspHook_)) {
1196
- return constructor_.name_
1197
- } else {
1198
- throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(constructor_.at_, ("No such type: " + constructor_.name_)), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
1199
- }
1200
- })));
1201
- const isFunctionType_ = ff_core_String.String_startsWith(name_, "Function$", 0);
1202
- return ((isFunctionType_ || ff_core_Set.Set_contains(self_.asyncTypes_, constructor_.name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String)) || ff_core_List.List_any(constructor_.generics_, ((_w1) => {
1203
- return ff_compiler_Resolver.Resolver_containsAsyncType(self_, _w1)
1204
- })))
1205
- return
1206
- }
1207
- }
1208
- }
1209
- }
1210
-
1211
- export async function Resolver_freshUnificationVariable$(self_, at_, $task) {
1212
- const result_ = ff_compiler_Syntax.TVariable(at_, self_.state_.nextUnificationVariableIndex_);
1213
- self_.state_.nextUnificationVariableIndex_ += 3;
1214
- return result_
1215
- }
1216
-
1217
- export async function Resolver_resolveModule$(self_, module_, otherModules_, $task) {
1218
- const moduleNamespace_ = ff_core_String.String_takeWhile(ff_core_String.String_reverse(ff_core_String.String_takeWhile(ff_core_String.String_reverse(ff_core_String.String_replace(module_.file_, "\\", "/")), ((_w1) => {
1219
- return (_w1 !== 47)
1220
- }))), ((_w1) => {
1221
- return (_w1 !== 46)
1222
- }));
1223
- const self2_ = ff_compiler_Resolver.Resolver_processImports(self_, module_.imports_, otherModules_);
1224
- const self3_ = ff_compiler_Resolver.Resolver_processDefinitions(self2_, module_, ff_core_Option.None());
1225
- const module2_ = (((_c) => {
1226
- return ff_compiler_Syntax.Module(_c.file_, _c.packagePair_, _c.imports_, ff_core_List.List_map(module_.types_, ((_w1) => {
1227
- return ff_compiler_Resolver.Resolver_resolveTypeDefinition(self3_, _w1)
1228
- })), ff_core_List.List_map(module_.traits_, ((_w1) => {
1229
- return ff_compiler_Resolver.Resolver_resolveTraitDefinition(self3_, _w1)
1230
- })), ff_core_List.List_map(module_.instances_, ((_w1) => {
1231
- return ff_compiler_Resolver.Resolver_resolveInstanceDefinition(self3_, _w1)
1232
- })), ff_core_List.List_map(module_.extends_, ((_w1) => {
1233
- return ff_compiler_Resolver.Resolver_resolveExtendDefinition(self3_, _w1)
1234
- })), ff_core_List.List_map(module_.lets_, ((_w1) => {
1235
- return ff_compiler_Resolver.Resolver_resolveLetDefinition(self3_, _w1, true)
1236
- })), ff_core_List.List_map(module_.functions_, ((_w1) => {
1237
- return ff_compiler_Resolver.Resolver_resolveFunctionDefinition(self3_, _w1, true, false)
1238
- })))
1239
- }))(module_);
1240
- ff_core_List.List_each(module2_.instances_, ((_w1) => {
1241
- ff_core_List.List_each(_w1.typeArguments_, ((_w1) => {
1242
- ff_compiler_Resolver.Resolver_checkInstanceType(self3_, _w1)
1243
- }))
1244
- }));
1245
- return module2_
1246
- }
1247
-
1248
- export async function Resolver_checkInstanceType$(self_, type_, $task) {
1249
- {
1250
- const _1 = type_;
1251
- {
1252
- if(_1.TConstructor) {
1253
- const name_ = _1.name_;
1254
- const typeArguments_ = _1.generics_;
1255
- if(ff_core_Set.Set_contains(self_.asyncTypes_, name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String)) {
1256
- throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(type_.at_, "Traits must not be instantiated for capability types"), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
1257
- };
1258
- ff_core_List.List_each(typeArguments_, ((_w1) => {
1259
- ff_compiler_Resolver.Resolver_checkInstanceType(self_, _w1)
1260
- }))
1261
- return
1262
- }
1263
- }
1264
- {
1265
-
1266
- return
1267
- }
1268
- }
1269
- }
1270
-
1271
- export async function Resolver_processImports$(self_, imports_, modules_, $task) {
1272
- let resolver_ = self_;
1273
- ff_core_List.List_each(imports_, ((import_) => {
1274
- {
1275
- const _1 = ff_core_List.List_find(modules_, ((_w1) => {
1276
- return (ff_core_String.String_dropLast(_w1.file_, 3) === import_.file_)
1277
- }));
1278
- {
1279
- if(_1.Some) {
1280
- const module_ = _1.value_;
1281
- resolver_ = ff_compiler_Resolver.Resolver_processDefinitions(resolver_, module_, ff_core_Option.Some(import_.alias_))
1282
- return
1283
- }
1284
- }
1285
- {
1286
- if(_1.None) {
1287
- throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(import_.at_, ("No such module: " + import_.file_)), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
1288
- return
1289
- }
1290
- }
1291
- }
1292
- }));
1293
- return resolver_
1294
- }
1295
-
1296
- export async function Resolver_processDefinitions$(self_, module_, importAlias_, $task) {
1297
- function entry_(name_, unqualified_) {
1298
- const full_ = ((((ff_compiler_Syntax.PackagePair_groupName(module_.packagePair_, ":") + "/") + ff_core_String.String_dropLast(module_.file_, 3)) + ".") + name_);
1299
- {
1300
- const _1 = importAlias_;
1301
- {
1302
- if(_1.None) {
1303
- return ff_core_List.Link(ff_core_Pair.Pair(name_, full_), ff_core_List.Link(ff_core_Pair.Pair(full_, full_), ff_core_List.Empty()))
1304
- return
1305
- }
1306
- }
1307
- {
1308
- if(_1.Some) {
1309
- const alias_ = _1.value_;
1310
- const _guard1 = unqualified_;
1311
- if(_guard1) {
1312
- return ff_core_List.Link(ff_core_Pair.Pair(((alias_ + ".") + name_), full_), ff_core_List.Link(ff_core_Pair.Pair(name_, full_), ff_core_List.Link(ff_core_Pair.Pair(full_, full_), ff_core_List.Empty())))
1313
- return
1314
- }
1315
- }
1316
- }
1317
- {
1318
- if(_1.Some) {
1319
- const alias_ = _1.value_;
1320
- return ff_core_List.Link(ff_core_Pair.Pair(((alias_ + ".") + name_), full_), ff_core_List.Link(ff_core_Pair.Pair(full_, full_), ff_core_List.Empty()))
1321
- return
1322
- }
1323
- }
1324
- }
1325
- }
1326
- const isCore_ = (((module_.packagePair_.group_ === "ff") && (module_.packagePair_.name_ === "core")) && (module_.file_ === "Core.ff"));
1327
- const lets_ = ff_core_List.List_toMap(ff_core_List.List_flatMap(module_.lets_, ((_w1) => {
1328
- return entry_(_w1.name_, isCore_)
1329
- })), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
1330
- const letLocations_ = ff_core_List.List_toMap(ff_core_List.List_flatMap(module_.lets_, ((d_) => {
1331
- return ff_core_List.List_map(entry_(d_.name_, true), ((_w1) => {
1332
- return ff_core_Pair.Pair_mapSecond(_w1, ((_) => {
1333
- return d_.at_
1334
- }))
1335
- }))
1336
- })), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
1337
- const functions_ = ff_core_List.List_toMap(ff_core_List.List_flatMap(module_.functions_, ((_w1) => {
1338
- return entry_(_w1.signature_.name_, isCore_)
1339
- })), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
1340
- const functionLocations_ = ff_core_List.List_toMap(ff_core_List.List_flatMap(module_.functions_, ((d_) => {
1341
- return ff_core_List.List_map(entry_(d_.signature_.name_, true), ((_w1) => {
1342
- return ff_core_Pair.Pair_mapSecond(_w1, ((_) => {
1343
- return d_.at_
1344
- }))
1345
- }))
1346
- })), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
1347
- const traitMethods_ = ff_core_List.List_toMap(ff_core_List.List_flatMap(ff_core_List.List_flatMap(module_.traits_, ((_w1) => {
1348
- return _w1.methods_
1349
- })), ((_w1) => {
1350
- return entry_(_w1.name_, false)
1351
- })), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
1352
- const traitMethodLocations_ = ff_core_List.List_toMap(ff_core_List.List_flatMap(ff_core_List.List_flatMap(module_.traits_, ((_w1) => {
1353
- return _w1.methods_
1354
- })), ((d_) => {
1355
- return ff_core_List.List_map(entry_(d_.name_, true), ((_w1) => {
1356
- return ff_core_Pair.Pair_mapSecond(_w1, ((_) => {
1357
- return d_.at_
1358
- }))
1359
- }))
1360
- })), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
1361
- const traits_ = ff_core_List.List_toMap(ff_core_List.List_flatMap(module_.traits_, ((_w1) => {
1362
- return entry_(_w1.name_, true)
1363
- })), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
1364
- const traitLocations_ = ff_core_List.List_toMap(ff_core_List.List_flatMap(module_.traits_, ((d_) => {
1365
- return ff_core_List.List_map(entry_(d_.name_, true), ((_w1) => {
1366
- return ff_core_Pair.Pair_mapSecond(_w1, ((_) => {
1367
- return d_.at_
1368
- }))
1369
- }))
1370
- })), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
1371
- const types_ = ff_core_List.List_toMap(ff_core_List.List_flatMap(module_.types_, ((_w1) => {
1372
- return entry_(_w1.name_, true)
1373
- })), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
1374
- const typeGenerics_ = ff_core_List.List_toMap(ff_core_List.List_flatMap(module_.types_, ((d_) => {
1375
- return ff_core_List.List_map(entry_(d_.name_, true), ((p_) => {
1376
- return ff_core_Pair.Pair(p_.first_, d_.generics_)
1377
- }))
1378
- })), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
1379
- const typeLocations_ = ff_core_List.List_toMap(ff_core_List.List_flatMap(module_.types_, ((d_) => {
1380
- return ff_core_List.List_map(entry_(d_.name_, true), ((_w1) => {
1381
- return ff_core_Pair.Pair_mapSecond(_w1, ((_) => {
1382
- return d_.at_
1383
- }))
1384
- }))
1385
- })), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
1386
- const asyncTypes_ = ff_core_List.List_toSet(ff_core_List.List_flatMap(ff_core_List.List_filter(module_.types_, ((_w1) => {
1387
- return ff_core_Option.Option_any(ff_core_List.List_first(_w1.generics_), ((_w1) => {
1388
- return (_w1 === "Q$")
1389
- }))
1390
- })), ((_w1) => {
1391
- return ff_core_List.List_map(entry_(_w1.name_, true), ((_w1) => {
1392
- return _w1.first_
1393
- }))
1394
- })), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
1395
- const variants_ = ff_core_List.List_toMap(ff_core_List.List_flatMap(ff_core_List.List_flatMap(module_.types_, ((_w1) => {
1396
- return _w1.variants_
1397
- })), ((_w1) => {
1398
- return entry_(_w1.name_, true)
1399
- })), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
1400
- {
1401
- const _1 = self_;
1402
- {
1403
- const _c = _1;
1404
- return ff_compiler_Resolver.Resolver(ff_core_Map.Map_addAll(ff_core_Map.Map_addAll(ff_core_Map.Map_addAll(self_.variables_, lets_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), functions_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), traitMethods_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Map.Map_addAll(ff_core_Map.Map_addAll(ff_core_Map.Map_addAll(self_.variableLocations_, letLocations_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), functionLocations_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), traitMethodLocations_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Map.Map_addAll(self_.variants_, variants_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Map.Map_addAll(self_.types_, types_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Map.Map_addAll(self_.typeGenerics_, typeGenerics_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Map.Map_addAll(self_.typeLocations_, typeLocations_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Set.Set_addAll(self_.asyncTypes_, asyncTypes_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_List.List_toSet(ff_core_List.Empty(), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Map.Map_addAll(self_.traits_, traits_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Map.Map_addAll(self_.traitLocations_, traitLocations_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), self_.state_, _c.lspHook_)
1405
- return
1406
- }
1407
- }
1408
- }
1409
-
1410
- export async function Resolver_resolveTypeDefinition$(self_, definition_, $task) {
1411
- if(ff_compiler_LspHook.LspHook_isAt(self_.lspHook_, definition_.at_)) {
1412
- ff_compiler_LspHook.LspHook_emit(self_.lspHook_, ff_compiler_LspHook.ResolveSymbolHook(ff_compiler_LspHook.SymbolHook(definition_.name_, definition_.at_, definition_.at_), ff_core_Option.None()))
1413
- };
1414
- const generics_ = ff_core_List.List_toMap(ff_core_List.List_map(definition_.generics_, ((g_) => {
1415
- return ff_core_Pair.Pair(g_, g_)
1416
- })), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
1417
- const self2_ = (((_c) => {
1418
- return ff_compiler_Resolver.Resolver(_c.variables_, _c.variableLocations_, _c.variants_, ff_core_Map.Map_addAll(self_.types_, generics_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), _c.typeGenerics_, _c.typeLocations_, ff_core_Set.Set_removeAll(self_.asyncTypes_, ff_core_List.List_toSet(definition_.generics_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Set.Set_addAll(self_.typeParameters_, ff_core_List.List_toSet(definition_.generics_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), _c.traits_, _c.traitLocations_, _c.state_, _c.lspHook_)
1419
- }))(self_);
1420
- if((!ff_core_Option.Option_any(ff_core_List.List_first(definition_.generics_), ((_w1) => {
1421
- return (_w1 === "Q$")
1422
- })))) {
1423
- ff_core_List.List_each(ff_core_List.List_addAll(definition_.commonFields_, ff_core_List.List_flatMap(definition_.variants_, ((_w1) => {
1424
- return _w1.fields_
1425
- }))), ((f_) => {
1426
- if(ff_compiler_Resolver.Resolver_containsAsyncType(self2_, f_.valueType_)) {
1427
- throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(f_.at_, "Only capabilities can contain fields of concrete capability types"), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
1428
- }
1429
- }))
1430
- };
1431
- {
1432
- const _1 = definition_;
1433
- {
1434
- const _c = _1;
1435
- return ff_compiler_Syntax.DType(_c.at_, _c.newtype_, _c.data_, _c.name_, _c.generics_, ff_core_List.List_map(definition_.constraints_, ((_w1) => {
1436
- return ff_compiler_Resolver.Resolver_resolveConstraint(self2_, _w1, true)
1437
- })), ff_core_List.List_map(definition_.commonFields_, ((f_) => {
1438
- const valueType_ = ff_compiler_Resolver.Resolver_resolveType(self2_, f_.valueType_, true);
1439
- if((ff_compiler_LspHook.LspHook_isAt(self_.lspHook_, f_.at_) || ff_compiler_LspHook.LspHook_isDefinedAt(self_.lspHook_, f_.at_))) {
1440
- ff_compiler_LspHook.LspHook_emit(self_.lspHook_, ff_compiler_LspHook.ResolveVariantFieldHook(ff_compiler_LspHook.SymbolHook(f_.name_, f_.at_, f_.at_), valueType_, true))
1441
- };
1442
- {
1443
- const _1 = f_;
1444
- {
1445
- const _c = _1;
1446
- return ff_compiler_Syntax.Parameter(_c.at_, _c.mutable_, _c.name_, valueType_, ff_core_Option.Option_map(f_.default_, ((_w1) => {
1447
- return ff_compiler_Resolver.Resolver_resolveTerm(self2_, _w1, true)
1448
- })))
1449
- return
1450
- }
1451
- }
1452
- })), ff_core_List.List_map(definition_.variants_, ((v_) => {
1453
- if(ff_compiler_LspHook.LspHook_isAt(self_.lspHook_, v_.at_)) {
1454
- ff_compiler_LspHook.LspHook_emit(self_.lspHook_, ff_compiler_LspHook.ResolveSymbolHook(ff_compiler_LspHook.SymbolHook(v_.name_, v_.at_, v_.at_), ff_core_Option.None()))
1455
- };
1456
- {
1457
- const _1 = v_;
1458
- {
1459
- const _c = _1;
1460
- return ff_compiler_Syntax.Variant(_c.at_, _c.name_, ff_core_List.List_map(v_.fields_, ((f_) => {
1461
- const valueType_ = ff_compiler_Resolver.Resolver_resolveType(self2_, f_.valueType_, true);
1462
- if((ff_compiler_LspHook.LspHook_isAt(self_.lspHook_, f_.at_) || ff_compiler_LspHook.LspHook_isDefinedAt(self_.lspHook_, f_.at_))) {
1463
- ff_compiler_LspHook.LspHook_emit(self_.lspHook_, ff_compiler_LspHook.ResolveVariantFieldHook(ff_compiler_LspHook.SymbolHook(f_.name_, f_.at_, f_.at_), valueType_, false))
1464
- };
1465
- {
1466
- const _1 = f_;
1467
- {
1468
- const _c = _1;
1469
- return ff_compiler_Syntax.Parameter(_c.at_, _c.mutable_, _c.name_, valueType_, ff_core_Option.Option_map(f_.default_, ((_w1) => {
1470
- return ff_compiler_Resolver.Resolver_resolveTerm(self2_, _w1, true)
1471
- })))
1472
- return
1473
- }
1474
- }
1475
- })))
1476
- return
1477
- }
1478
- }
1479
- })))
1480
- return
1481
- }
1482
- }
1483
- }
1484
-
1485
- export async function Resolver_resolveTraitDefinition$(self_, definition_, $task) {
1486
- if((ff_compiler_LspHook.LspHook_isAt(self_.lspHook_, definition_.at_) || ff_compiler_LspHook.LspHook_isDefinedAt(self_.lspHook_, definition_.at_))) {
1487
- ff_compiler_LspHook.LspHook_emit(self_.lspHook_, ff_compiler_LspHook.ResolveSymbolHook(ff_compiler_LspHook.SymbolHook(definition_.name_, definition_.at_, definition_.at_), ff_core_Option.None()))
1488
- };
1489
- const generics_ = ff_core_List.List_toMap(ff_core_List.List_map(definition_.generics_, ((g_) => {
1490
- return ff_core_Pair.Pair(g_, g_)
1491
- })), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
1492
- const self2_ = (((_c) => {
1493
- return ff_compiler_Resolver.Resolver(_c.variables_, _c.variableLocations_, _c.variants_, ff_core_Map.Map_addAll(self_.types_, generics_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), _c.typeGenerics_, _c.typeLocations_, ff_core_Set.Set_removeAll(self_.asyncTypes_, ff_core_List.List_toSet(definition_.generics_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Set.Set_addAll(self_.typeParameters_, ff_core_List.List_toSet(definition_.generics_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), _c.traits_, _c.traitLocations_, _c.state_, _c.lspHook_)
1494
- }))(self_);
1495
- {
1496
- const _1 = definition_;
1497
- {
1498
- const _c = _1;
1499
- return ff_compiler_Syntax.DTrait(_c.at_, _c.name_, _c.generics_, ff_core_List.List_map(definition_.constraints_, ((_w1) => {
1500
- return ff_compiler_Resolver.Resolver_resolveConstraint(self2_, _w1, true)
1501
- })), _c.generatorParameters_, ff_core_List.List_map(definition_.methods_, ((_w1) => {
1502
- return ff_compiler_Resolver.Resolver_resolveSignature(self2_, _w1, true, false)
1503
- })), ff_core_List.List_map(definition_.methodDefaults_, ((_1) => {
1504
- {
1505
- const name_ = _1.first_;
1506
- const lambda_ = _1.second_;
1507
- const signature_ = ff_core_Option.Option_grab(ff_core_List.List_find(definition_.methods_, ((_w1) => {
1508
- return (_w1.name_ === name_)
1509
- })));
1510
- const function1_ = ff_compiler_Syntax.DFunction(signature_.at_, signature_, ff_compiler_Syntax.FireflyTarget(lambda_));
1511
- const function2_ = ff_compiler_Resolver.Resolver_resolveFunctionDefinition(self2_, function1_, true, false);
1512
- return ff_core_Pair.Pair(name_, (((_1) => {
1513
- {
1514
- if(_1.FireflyTarget) {
1515
- const lambda_ = _1.lambda_;
1516
- return lambda_
1517
- return
1518
- }
1519
- }
1520
- {
1521
- throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(signature_.at_, "Internal error: Expected method default to be a lambda"), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
1522
- return
1523
- }
1524
- }))(function2_.body_))
1525
- return
1526
- }
1527
- })), _c.methodGenerators_)
1528
- return
1529
- }
1530
- }
1531
- }
1532
-
1533
- export async function Resolver_resolveInstanceDefinition$(self_, definition_, $task) {
1534
- const traitDefinedAt_ = ff_core_Option.Option_else(ff_core_Map.Map_get(self_.traitLocations_, definition_.traitName_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), (() => {
1535
- return definition_.at_
1536
- }));
1537
- if((ff_compiler_LspHook.LspHook_isAt(self_.lspHook_, definition_.at_) || ff_compiler_LspHook.LspHook_isDefinedAt(self_.lspHook_, traitDefinedAt_))) {
1538
- ff_compiler_LspHook.LspHook_emit(self_.lspHook_, ff_compiler_LspHook.ResolveSymbolHook(ff_compiler_LspHook.SymbolHook(definition_.traitName_, definition_.at_, traitDefinedAt_), ff_core_Option.None()))
1539
- };
1540
- const generics_ = ff_core_List.List_toMap(ff_core_List.List_map(definition_.generics_, ((g_) => {
1541
- return ff_core_Pair.Pair(g_, g_)
1542
- })), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
1543
- const self2_ = (((_c) => {
1544
- return ff_compiler_Resolver.Resolver(_c.variables_, _c.variableLocations_, _c.variants_, ff_core_Map.Map_addAll(self_.types_, generics_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), _c.typeGenerics_, _c.typeLocations_, ff_core_Set.Set_removeAll(self_.asyncTypes_, ff_core_List.List_toSet(definition_.generics_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Set.Set_addAll(self_.typeParameters_, ff_core_List.List_toSet(definition_.generics_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), _c.traits_, _c.traitLocations_, _c.state_, _c.lspHook_)
1545
- }))(self_);
1546
- const traitName_ = ff_core_Option.Option_else(ff_core_Map.Map_get(self2_.traits_, definition_.traitName_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), (() => {
1547
- throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(definition_.at_, ("No such trait: " + definition_.traitName_)), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
1548
- }));
1549
- {
1550
- const _1 = definition_;
1551
- {
1552
- const _c = _1;
1553
- return ff_compiler_Syntax.DInstance(_c.at_, _c.generics_, ff_core_List.List_map(definition_.constraints_, ((_w1) => {
1554
- return ff_compiler_Resolver.Resolver_resolveConstraint(self2_, _w1, true)
1555
- })), traitName_, ff_core_List.List_map(definition_.typeArguments_, ((_w1) => {
1556
- return ff_compiler_Resolver.Resolver_resolveType(self2_, _w1, true)
1557
- })), _c.generatorArguments_, ff_core_List.List_map(definition_.methods_, ((_w1) => {
1558
- return ff_compiler_Resolver.Resolver_resolveFunctionDefinition(self2_, _w1, true, true)
1559
- })), _c.derived_)
1560
- return
1561
- }
1562
- }
1563
- }
1564
-
1565
- export async function Resolver_resolveExtendDefinition$(self_, definition_, $task) {
1566
- const generics_ = ff_core_List.List_toMap(ff_core_List.List_map(definition_.generics_, ((g_) => {
1567
- return ff_core_Pair.Pair(g_, g_)
1568
- })), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
1569
- const selfWithNoQ_ = (((_c) => {
1570
- return ff_compiler_Resolver.Resolver(ff_core_Map.Map_add(self_.variables_, definition_.name_, definition_.name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Map.Map_add(self_.variableLocations_, definition_.name_, definition_.at_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), _c.variants_, ff_core_Map.Map_addAll(self_.types_, generics_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), _c.typeGenerics_, _c.typeLocations_, ff_core_Set.Set_removeAll(self_.asyncTypes_, ff_core_List.List_toSet(definition_.generics_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Set.Set_addAll(self_.typeParameters_, ff_core_List.List_toSet(definition_.generics_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), _c.traits_, _c.traitLocations_, _c.state_, _c.lspHook_)
1571
- }))(self_);
1572
- const selfWithQ_ = (((_c) => {
1573
- return ff_compiler_Resolver.Resolver(_c.variables_, _c.variableLocations_, _c.variants_, ff_core_Map.Map_add(selfWithNoQ_.types_, "Q$", "Q$", ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), _c.typeGenerics_, _c.typeLocations_, _c.asyncTypes_, ff_core_Set.Set_add(selfWithNoQ_.typeParameters_, "Q$", ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), _c.traits_, _c.traitLocations_, _c.state_, _c.lspHook_)
1574
- }))(selfWithNoQ_);
1575
- {
1576
- const _1 = definition_;
1577
- {
1578
- const _c = _1;
1579
- return ff_compiler_Syntax.DExtend(_c.at_, _c.name_, _c.generics_, ff_core_List.List_map(definition_.constraints_, ((_w1) => {
1580
- return ff_compiler_Resolver.Resolver_resolveConstraint(selfWithQ_, _w1, true)
1581
- })), ff_compiler_Resolver.Resolver_resolveType(selfWithQ_, definition_.type_, true), ff_core_List.List_map(definition_.methods_, ((_w1) => {
1582
- return ff_compiler_Resolver.Resolver_resolveFunctionDefinition(selfWithNoQ_, _w1, true, false)
1583
- })))
1584
- return
1585
- }
1586
- }
1587
- }
1588
-
1589
- export async function Resolver_resolveLetDefinition$(self_, definition_, topLevel_, $task) {
1590
- if((ff_compiler_LspHook.LspHook_isAt(self_.lspHook_, definition_.at_) || ff_compiler_LspHook.LspHook_isDefinedAt(self_.lspHook_, definition_.at_))) {
1591
- ff_compiler_LspHook.LspHook_emit(self_.lspHook_, ff_compiler_LspHook.ResolveSymbolHook(ff_compiler_LspHook.SymbolHook(definition_.name_, definition_.at_, definition_.at_), ff_core_Option.None()))
1592
- };
1593
- {
1594
- const _1 = definition_;
1595
- {
1596
- const _c = _1;
1597
- return ff_compiler_Syntax.DLet(_c.at_, _c.name_, ff_compiler_Resolver.Resolver_resolveType(self_, definition_.variableType_, topLevel_), ff_compiler_Resolver.Resolver_resolveTerm(self_, definition_.value_, true))
1598
- return
1599
- }
1600
- }
1601
- }
1602
-
1603
- export async function Resolver_resolveTerm$(self_, term_, topLevel_, $task) {
1604
- {
1605
- const self_a = self_;
1606
- const term_a = term_;
1607
- const topLevel_a = topLevel_;
1608
- {
1609
- if(term_a.EString) {
1610
- return term_
1611
- return
1612
- }
1613
- }
1614
- {
1615
- if(term_a.EChar) {
1616
- return term_
1617
- return
1618
- }
1619
- }
1620
- {
1621
- if(term_a.EInt) {
1622
- return term_
1623
- return
1624
- }
1625
- }
1626
- {
1627
- if(term_a.EFloat) {
1628
- return term_
1629
- return
1630
- }
1631
- }
1632
- {
1633
- if(term_a.EVariable) {
1634
- const e_ = term_a;
1635
- if(ff_compiler_LspHook.LspHook_isEnabled(self_.lspHook_)) {
1636
- const at_ = ff_core_Option.Option_else(ff_core_Map.Map_get(self_.variableLocations_, e_.name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), (() => {
1637
- return e_.at_
1638
- }));
1639
- if((ff_compiler_LspHook.LspHook_isAt(self_.lspHook_, e_.at_) || ff_compiler_LspHook.LspHook_isDefinedAt(self_.lspHook_, at_))) {
1640
- ff_compiler_LspHook.LspHook_emit(self_.lspHook_, ff_compiler_LspHook.ResolveSymbolHook(ff_compiler_LspHook.SymbolHook(e_.name_, e_.at_, at_), ff_core_Option.None()))
1641
- }
1642
- };
1643
- return ff_core_Option.Option_else(ff_core_Option.Option_map(ff_core_Map.Map_get(self_.variables_, e_.name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ((_w1) => {
1644
- {
1645
- const _1 = e_;
1646
- {
1647
- const _c = _1;
1648
- return ff_compiler_Syntax.EVariable(_c.at_, _w1)
1649
- return
1650
- }
1651
- }
1652
- })), (() => {
1653
- return term_
1654
- }))
1655
- return
1656
- }
1657
- }
1658
- {
1659
- if(term_a.EList) {
1660
- const at_ = term_a.at_;
1661
- const t_ = term_a.elementType_;
1662
- const items_ = term_a.items_;
1663
- return ff_compiler_Syntax.EList(at_, ff_compiler_Resolver.Resolver_resolveType(self_, t_, topLevel_), ff_core_List.List_map(items_, ((_1) => {
1664
- {
1665
- const item_ = _1.first_;
1666
- const spread_ = _1.second_;
1667
- return ff_core_Pair.Pair(ff_compiler_Resolver.Resolver_resolveTerm(self_, item_, topLevel_), spread_)
1668
- return
1669
- }
1670
- })))
1671
- return
1672
- }
1673
- }
1674
- {
1675
- if(term_a.EVariant) {
1676
- const at_ = term_a.at_;
1677
- const name_ = term_a.name_;
1678
- const typeArguments_ = term_a.typeArguments_;
1679
- const arguments_ = term_a.arguments_;
1680
- return ff_compiler_Syntax.EVariant(at_, ff_core_Option.Option_else(ff_core_Map.Map_get(self_.variants_, name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), (() => {
1681
- return name_
1682
- })), ff_core_List.List_map(typeArguments_, ((_w1) => {
1683
- return ff_compiler_Resolver.Resolver_resolveType(self_, _w1, topLevel_)
1684
- })), ff_core_Option.Option_map(arguments_, ((_w1) => {
1685
- return ff_core_List.List_map(_w1, ((a_) => {
1686
- {
1687
- const _1 = a_;
1688
- {
1689
- const _c = _1;
1690
- return ff_compiler_Syntax.Argument(_c.at_, _c.name_, ff_compiler_Resolver.Resolver_resolveTerm(self_, a_.value_, topLevel_))
1691
- return
1692
- }
1693
- }
1694
- }))
1695
- })))
1696
- return
1697
- }
1698
- }
1699
- {
1700
- if(term_a.EVariantIs) {
1701
- const at_ = term_a.at_;
1702
- const name_ = term_a.name_;
1703
- const typeArguments_ = term_a.typeArguments_;
1704
- return ff_compiler_Syntax.EVariantIs(at_, ff_core_Option.Option_else(ff_core_Map.Map_get(self_.variants_, name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), (() => {
1705
- throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(at_, ("No such variant: " + name_)), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
1706
- })), ff_core_List.List_map(typeArguments_, ((_w1) => {
1707
- return ff_compiler_Resolver.Resolver_resolveType(self_, _w1, topLevel_)
1708
- })))
1709
- return
1710
- }
1711
- }
1712
- {
1713
- if(term_a.ECopy) {
1714
- const at_ = term_a.at_;
1715
- const name_ = term_a.name_;
1716
- const record_ = term_a.record_;
1717
- const arguments_ = term_a.arguments_;
1718
- return ff_compiler_Syntax.ECopy(at_, ff_core_Option.Option_else(ff_core_Map.Map_get(self_.variants_, name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), (() => {
1719
- return name_
1720
- })), ff_compiler_Resolver.Resolver_resolveTerm(self_, record_, topLevel_), ff_core_List.List_map(arguments_, ((f_) => {
1721
- {
1722
- const _1 = f_;
1723
- {
1724
- const _c = _1;
1725
- return ff_compiler_Syntax.Field(_c.at_, _c.name_, ff_compiler_Resolver.Resolver_resolveTerm(self_, f_.value_, topLevel_))
1726
- return
1727
- }
1728
- }
1729
- })))
1730
- return
1731
- }
1732
- }
1733
- {
1734
- if(term_a.EField) {
1735
- const e_ = term_a;
1736
- {
1737
- const _1 = e_;
1738
- {
1739
- const _c = _1;
1740
- return ff_compiler_Syntax.EField(_c.at_, _c.newtype_, ff_compiler_Resolver.Resolver_resolveTerm(self_, e_.record_, topLevel_), _c.field_)
1741
- return
1742
- }
1743
- }
1744
- return
1745
- }
1746
- }
1747
- {
1748
- if(term_a.ELambda) {
1749
- const at_ = term_a.at_;
1750
- const lambdaAt_ = term_a.lambda_.at_;
1751
- const cases_ = term_a.lambda_.cases_;
1752
- const effect_ = ff_compiler_Resolver.Resolver_makeEffectArgument(self_, lambdaAt_, topLevel_);
1753
- return ff_compiler_Syntax.ELambda(at_, ff_compiler_Syntax.Lambda(lambdaAt_, effect_, ff_core_List.List_map(cases_, ((_w1) => {
1754
- return ff_compiler_Resolver.Resolver_resolveCase(self_, _w1, topLevel_)
1755
- }))))
1756
- return
1757
- }
1758
- }
1759
- {
1760
- if(term_a.EPipe) {
1761
- const at_ = term_a.at_;
1762
- const value_ = term_a.value_;
1763
- const effect_ = term_a.effect_;
1764
- const function_ = term_a.function_;
1765
- return ff_compiler_Syntax.EPipe(at_, ff_compiler_Resolver.Resolver_resolveTerm(self_, value_, topLevel_), ff_compiler_Resolver.Resolver_resolveType(self_, effect_, topLevel_), ff_compiler_Resolver.Resolver_resolveTerm(self_, function_, topLevel_))
1766
- return
1767
- }
1768
- }
1769
- {
1770
- if(term_a.ECall) {
1771
- const at_ = term_a.at_;
1772
- if(term_a.target_.DynamicCall) {
1773
- const target_ = term_a.target_;
1774
- const effect_ = term_a.effect_;
1775
- const typeArguments_ = term_a.typeArguments_;
1776
- const arguments_ = term_a.arguments_;
1777
- const dictionaries_ = term_a.dictionaries_;
1778
- return ff_compiler_Syntax.ECall(at_, (((_c) => {
1779
- return ff_compiler_Syntax.DynamicCall(ff_compiler_Resolver.Resolver_resolveTerm(self_, target_.function_, topLevel_), _c.tailCall_)
1780
- }))(target_), ff_compiler_Resolver.Resolver_resolveType(self_, effect_, topLevel_), ff_core_List.List_map(typeArguments_, ((_w1) => {
1781
- return ff_compiler_Resolver.Resolver_resolveType(self_, _w1, topLevel_)
1782
- })), ff_core_List.List_map(arguments_, ((a_) => {
1783
- {
1784
- const _1 = a_;
1785
- {
1786
- const _c = _1;
1787
- return ff_compiler_Syntax.Argument(_c.at_, _c.name_, ff_compiler_Resolver.Resolver_resolveTerm(self_, a_.value_, topLevel_))
1788
- return
1789
- }
1790
- }
1791
- })), dictionaries_)
1792
- return
1793
- }
1794
- }
1795
- }
1796
- {
1797
- if(term_a.ECall) {
1798
- const at_ = term_a.at_;
1799
- if(term_a.target_.StaticCall) {
1800
- throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(at_, "Internal error: Static calls not expected in the Resolver phase"), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
1801
- return
1802
- }
1803
- }
1804
- }
1805
- {
1806
- if(term_a.ERecord) {
1807
- const at_ = term_a.at_;
1808
- const fields_ = term_a.fields_;
1809
- return ff_compiler_Syntax.ERecord(at_, ff_core_List.List_map(fields_, ((f_) => {
1810
- {
1811
- const _1 = f_;
1812
- {
1813
- const _c = _1;
1814
- return ff_compiler_Syntax.Field(_c.at_, _c.name_, ff_compiler_Resolver.Resolver_resolveTerm(self_, f_.value_, topLevel_))
1815
- return
1816
- }
1817
- }
1818
- })))
1819
- return
1820
- }
1821
- }
1822
- {
1823
- if(term_a.EWildcard) {
1824
- const e_ = term_a;
1825
- if((e_.index_ === 0)) {
1826
- throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(e_.at_, "Unbound wildcard"), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
1827
- };
1828
- {
1829
- const _1 = e_;
1830
- {
1831
- const _c = _1;
1832
- return ff_compiler_Syntax.EWildcard(_c.at_, _c.index_)
1833
- return
1834
- }
1835
- }
1836
- return
1837
- }
1838
- }
1839
- {
1840
- if(term_a.EFunctions) {
1841
- const at_ = term_a.at_;
1842
- const functions_ = term_a.functions_;
1843
- const body_ = term_a.body_;
1844
- const functionMap_ = ff_core_List.List_toMap(ff_core_List.List_map(ff_core_List.List_map(functions_, ((_w1) => {
1845
- return _w1.signature_.name_
1846
- })), ((name_) => {
1847
- return ff_core_Pair.Pair(name_, name_)
1848
- })), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
1849
- const locationMap_ = ff_core_List.List_toMap(ff_core_List.List_map(ff_core_List.List_map(functions_, ((_w1) => {
1850
- return _w1.signature_
1851
- })), ((s_) => {
1852
- return ff_core_Pair.Pair(s_.name_, s_.at_)
1853
- })), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
1854
- const self2_ = (((_c) => {
1855
- return ff_compiler_Resolver.Resolver(ff_core_Map.Map_addAll(self_.variables_, functionMap_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Map.Map_addAll(self_.variableLocations_, locationMap_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), _c.variants_, _c.types_, _c.typeGenerics_, _c.typeLocations_, _c.asyncTypes_, _c.typeParameters_, _c.traits_, _c.traitLocations_, _c.state_, _c.lspHook_)
1856
- }))(self_);
1857
- return ff_compiler_Syntax.EFunctions(at_, ff_core_List.List_map(functions_, ((_w1) => {
1858
- return ff_compiler_Resolver.Resolver_resolveFunctionDefinition(self2_, _w1, topLevel_, false)
1859
- })), ff_compiler_Resolver.Resolver_resolveTerm(self2_, body_, topLevel_))
1860
- return
1861
- }
1862
- }
1863
- {
1864
- if(term_a.ELet) {
1865
- const e_ = term_a;
1866
- const self2_ = (((_c) => {
1867
- return ff_compiler_Resolver.Resolver(ff_core_Map.Map_add(self_.variables_, e_.name_, e_.name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Map.Map_add(self_.variableLocations_, e_.name_, e_.at_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), _c.variants_, _c.types_, _c.typeGenerics_, _c.typeLocations_, _c.asyncTypes_, _c.typeParameters_, _c.traits_, _c.traitLocations_, _c.state_, _c.lspHook_)
1868
- }))(self_);
1869
- if(ff_compiler_LspHook.LspHook_isEnabled(self_.lspHook_)) {
1870
- if((ff_compiler_LspHook.LspHook_isAt(self_.lspHook_, e_.at_) || ff_compiler_LspHook.LspHook_isDefinedAt(self_.lspHook_, e_.at_))) {
1871
- ff_compiler_LspHook.LspHook_emit(self_.lspHook_, ff_compiler_LspHook.ResolveSymbolHook(ff_compiler_LspHook.SymbolHook(e_.name_, e_.at_, e_.at_), ff_core_Option.None()))
1872
- }
1873
- };
1874
- {
1875
- const _1 = e_;
1876
- {
1877
- const _c = _1;
1878
- return ff_compiler_Syntax.ELet(_c.at_, _c.mutable_, _c.name_, ff_compiler_Resolver.Resolver_resolveType(self_, e_.valueType_, topLevel_), ff_compiler_Resolver.Resolver_resolveTerm(self_, e_.value_, topLevel_), ff_compiler_Resolver.Resolver_resolveTerm(self2_, e_.body_, topLevel_))
1879
- return
1880
- }
1881
- }
1882
- return
1883
- }
1884
- }
1885
- {
1886
- if(term_a.ESequential) {
1887
- const at_ = term_a.at_;
1888
- const before_ = term_a.before_;
1889
- const after_ = term_a.after_;
1890
- return ff_compiler_Syntax.ESequential(at_, ff_compiler_Resolver.Resolver_resolveTerm(self_, before_, topLevel_), ff_compiler_Resolver.Resolver_resolveTerm(self_, after_, topLevel_))
1891
- return
1892
- }
1893
- }
1894
- {
1895
- if(term_a.EAssign) {
1896
- const at_ = term_a.at_;
1897
- const operator_ = term_a.operator_;
1898
- const variable_ = term_a.variable_;
1899
- const value_ = term_a.value_;
1900
- return ff_compiler_Syntax.EAssign(at_, operator_, ff_core_Option.Option_else(ff_core_Map.Map_get(self_.variables_, variable_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), (() => {
1901
- throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(at_, ("No such variable: " + variable_)), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
1902
- })), ff_compiler_Resolver.Resolver_resolveTerm(self_, value_, topLevel_))
1903
- return
1904
- }
1905
- }
1906
- {
1907
- if(term_a.EAssignField) {
1908
- const at_ = term_a.at_;
1909
- const operator_ = term_a.operator_;
1910
- const record_ = term_a.record_;
1911
- const field_ = term_a.field_;
1912
- const value_ = term_a.value_;
1913
- return ff_compiler_Syntax.EAssignField(at_, operator_, ff_compiler_Resolver.Resolver_resolveTerm(self_, record_, topLevel_), field_, ff_compiler_Resolver.Resolver_resolveTerm(self_, value_, topLevel_))
1914
- return
1915
- }
1916
- }
1917
- }
1918
- }
1919
-
1920
- export async function Resolver_resolveType$(self_, type_, topLevel_, $task) {
1921
- {
1922
- const self_a = self_;
1923
- const type_a = type_;
1924
- const topLevel_a = topLevel_;
1925
- {
1926
- if(type_a.TVariable) {
1927
- return type_
1928
- return
1929
- }
1930
- }
1931
- {
1932
- if(type_a.TConstructor) {
1933
- const constructor_ = type_a;
1934
- if(ff_compiler_LspHook.LspHook_isEnabled(self_.lspHook_)) {
1935
- const at_ = ff_core_Option.Option_else(ff_core_Map.Map_get(self_.typeLocations_, constructor_.name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), (() => {
1936
- return type_.at_
1937
- }));
1938
- if((ff_compiler_LspHook.LspHook_isAt(self_.lspHook_, type_.at_) || ff_compiler_LspHook.LspHook_isDefinedAt(self_.lspHook_, at_))) {
1939
- ff_compiler_LspHook.LspHook_emit(self_.lspHook_, ff_compiler_LspHook.ResolveTypeHook(self_.types_, self_.typeGenerics_, ff_compiler_LspHook.SymbolHook(constructor_.name_, type_.at_, at_), type_))
1940
- }
1941
- };
1942
- const name_ = (ff_core_String.String_contains(constructor_.name_, "$")
1943
- ? constructor_.name_
1944
- : ff_core_Option.Option_else(ff_core_Map.Map_get(self_.types_, constructor_.name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), (() => {
1945
- if((!ff_compiler_LspHook.LspHook_isEnabled(self_.lspHook_))) {
1946
- throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(constructor_.at_, ("No such type: " + constructor_.name_)), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
1947
- } else {
1948
- return constructor_.name_
1949
- }
1950
- })));
1951
- const isFunctionType_ = ff_core_String.String_startsWith(name_, "Function$", 0);
1952
- const effect_ = ((isFunctionType_ || ff_core_Set.Set_contains(self_.asyncTypes_, constructor_.name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String))
1953
- ? ff_core_List.Link(ff_compiler_Resolver.Resolver_makeEffectArgument(self_, constructor_.at_, topLevel_), ff_core_List.Empty())
1954
- : ff_core_List.Empty());
1955
- const generics_ = ff_core_List.List_map(constructor_.generics_, ((_w1) => {
1956
- return ff_compiler_Resolver.Resolver_resolveType(self_, _w1, topLevel_)
1957
- }));
1958
- if(isFunctionType_) {
1959
- const arguments_ = ff_core_List.List_dropLast(generics_, 1);
1960
- const returnType_ = ff_core_List.List_grabLast(generics_);
1961
- {
1962
- const _1 = constructor_;
1963
- {
1964
- const _c = _1;
1965
- return ff_compiler_Syntax.TConstructor(_c.at_, name_, ff_core_List.List_addAll(effect_, ff_core_List.List_addAll(arguments_, ff_core_List.Link(returnType_, ff_core_List.Empty()))))
1966
- return
1967
- }
1968
- }
1969
- } else {
1970
- {
1971
- const _1 = constructor_;
1972
- {
1973
- const _c = _1;
1974
- return ff_compiler_Syntax.TConstructor(_c.at_, name_, ff_core_List.List_addAll(effect_, generics_))
1975
- return
1976
- }
1977
- }
1978
- }
1979
- return
1980
- }
1981
- }
1982
- }
1983
- }
1984
-
1985
- export async function Resolver_makeEffectArgument$(self_, at_, topLevel_, $task) {
1986
- if(topLevel_) {
1987
- if((!ff_core_Set.Set_contains(self_.typeParameters_, "Q$", ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String))) {
1988
- return ff_compiler_Syntax.TConstructor(at_, "ff:core/Nothing.Nothing", ff_core_List.Empty())
1989
- } else {
1990
- return ff_compiler_Syntax.TConstructor(at_, "Q$", ff_core_List.Empty())
1991
- }
1992
- } else {
1993
- return ff_compiler_Resolver.Resolver_freshUnificationVariable(self_, at_)
1994
- }
1995
- }
1996
-
1997
- export async function Resolver_resolveConstraint$(self_, constraint_, topLevel_, $task) {
1998
- const traitDefinedAt_ = ff_core_Option.Option_else(ff_core_Map.Map_get(self_.traitLocations_, constraint_.name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), (() => {
1999
- return constraint_.at_
2000
- }));
2001
- if((ff_compiler_LspHook.LspHook_isAt(self_.lspHook_, constraint_.at_) || ff_compiler_LspHook.LspHook_isDefinedAt(self_.lspHook_, traitDefinedAt_))) {
2002
- ff_compiler_LspHook.LspHook_emit(self_.lspHook_, ff_compiler_LspHook.ResolveConstraintHook(ff_compiler_LspHook.SymbolHook(constraint_.name_, constraint_.at_, traitDefinedAt_), constraint_))
2003
- };
2004
- const name_ = ff_core_Option.Option_else(ff_core_Map.Map_get(self_.traits_, constraint_.name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), (() => {
2005
- throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(constraint_.at_, ("No such trait: " + constraint_.name_)), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
2006
- }));
2007
- {
2008
- const _1 = constraint_;
2009
- {
2010
- const _c = _1;
2011
- return ff_compiler_Syntax.Constraint(_c.at_, name_, ff_core_List.List_map(constraint_.generics_, ((_w1) => {
2012
- return ff_compiler_Resolver.Resolver_resolveType(self_, _w1, topLevel_)
2013
- })))
2014
- return
2015
- }
2016
- }
2017
- }
2018
-
2019
- export async function Resolver_resolveFunctionDefinition$(self_, definition_, topLevel_, isInstanceMethod_, $task) {
2020
- const signature_ = ff_compiler_Resolver.Resolver_resolveSignature(self_, definition_.signature_, topLevel_, isInstanceMethod_);
2021
- const self2_ = ff_compiler_Resolver.Resolver_withSignature(self_, signature_);
2022
- const body_ = ff_compiler_Syntax.Target_mapFirefly(definition_.body_, ((lambda_) => {
2023
- {
2024
- const _1 = lambda_;
2025
- {
2026
- const _c = _1;
2027
- return ff_compiler_Syntax.Lambda(_c.at_, signature_.effect_, ff_core_List.List_map(lambda_.cases_, ((_w1) => {
2028
- return ff_compiler_Resolver.Resolver_resolveCase(self2_, _w1, false)
2029
- })))
2030
- return
2031
- }
2032
- }
2033
- }));
2034
- return ff_compiler_Syntax.DFunction(definition_.at_, signature_, body_)
2035
- }
2036
-
2037
- export async function Resolver_resolveSignature$(self_, signature_, topLevel_, isInstanceMethod_, $task) {
2038
- if((ff_compiler_LspHook.LspHook_isAt(self_.lspHook_, signature_.at_) || ff_compiler_LspHook.LspHook_isDefinedAt(self_.lspHook_, signature_.at_))) {
2039
- ff_compiler_LspHook.LspHook_emit(self_.lspHook_, ff_compiler_LspHook.ResolveSignatureHook(signature_, isInstanceMethod_))
2040
- };
2041
- const newSignature_ = (topLevel_
2042
- ? (((_c) => {
2043
- return ff_compiler_Syntax.Signature(_c.at_, _c.name_, _c.member_, ff_core_List.Link("Q$", signature_.generics_), _c.constraints_, _c.parameters_, _c.returnType_, ff_compiler_Syntax.TConstructor(signature_.at_, "Q$", ff_core_List.Empty()))
2044
- }))(signature_)
2045
- : (((_c) => {
2046
- return ff_compiler_Syntax.Signature(_c.at_, _c.name_, _c.member_, _c.generics_, _c.constraints_, _c.parameters_, _c.returnType_, ff_compiler_Resolver.Resolver_freshUnificationVariable(self_, signature_.at_))
2047
- }))(signature_));
2048
- ff_core_Option.Option_each(ff_core_List.List_find(newSignature_.generics_, ((name_) => {
2049
- return ff_core_Set.Set_contains(self_.typeParameters_, name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String)
2050
- })), ((name_) => {
2051
- throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(signature_.at_, (("Type parameter " + name_) + " is already in scope")), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
2052
- }));
2053
- const self2_ = ff_compiler_Resolver.Resolver_withSignature(self_, newSignature_);
2054
- {
2055
- const _1 = newSignature_;
2056
- {
2057
- const _c = _1;
2058
- return ff_compiler_Syntax.Signature(_c.at_, _c.name_, _c.member_, _c.generics_, ff_core_List.List_map(newSignature_.constraints_, ((_w1) => {
2059
- return ff_compiler_Resolver.Resolver_resolveConstraint(self2_, _w1, topLevel_)
2060
- })), ff_core_List.List_map(newSignature_.parameters_, ((p_) => {
2061
- {
2062
- const _1 = p_;
2063
- {
2064
- const _c = _1;
2065
- return ff_compiler_Syntax.Parameter(_c.at_, _c.mutable_, _c.name_, ff_compiler_Resolver.Resolver_resolveType(self2_, p_.valueType_, topLevel_), ff_core_Option.Option_map(p_.default_, ((_w1) => {
2066
- return ff_compiler_Resolver.Resolver_resolveTerm(self2_, _w1, topLevel_)
2067
- })))
2068
- return
2069
- }
2070
- }
2071
- })), ff_compiler_Resolver.Resolver_resolveType(self2_, newSignature_.returnType_, topLevel_), _c.effect_)
2072
- return
2073
- }
2074
- }
2075
- }
2076
-
2077
- export async function Resolver_withSignature$(self_, signature_, $task) {
2078
- const variableMap_ = ff_core_List.List_toMap(ff_core_List.List_map(ff_core_List.List_map(signature_.parameters_, ((_w1) => {
2079
- return _w1.name_
2080
- })), ((name_) => {
2081
- return ff_core_Pair.Pair(name_, name_)
2082
- })), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
2083
- const variableLocationMap_ = ff_core_List.List_toMap(ff_core_List.List_map(signature_.parameters_, ((p_) => {
2084
- return ff_core_Pair.Pair(p_.name_, p_.at_)
2085
- })), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
2086
- const typeMap_ = ff_core_List.List_toMap(ff_core_List.List_map(signature_.generics_, ((name_) => {
2087
- return ff_core_Pair.Pair(name_, name_)
2088
- })), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
2089
- {
2090
- const _1 = self_;
2091
- {
2092
- const _c = _1;
2093
- return ff_compiler_Resolver.Resolver(ff_core_Map.Map_addAll(self_.variables_, variableMap_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Map.Map_addAll(self_.variableLocations_, variableLocationMap_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), _c.variants_, ff_core_Map.Map_addAll(self_.types_, typeMap_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), _c.typeGenerics_, _c.typeLocations_, ff_core_Set.Set_removeAll(self_.asyncTypes_, ff_core_List.List_toSet(signature_.generics_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Set.Set_addAll(self_.typeParameters_, ff_core_List.List_toSet(signature_.generics_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), _c.traits_, _c.traitLocations_, _c.state_, _c.lspHook_)
2094
- return
2095
- }
2096
- }
2097
- }
2098
-
2099
- export async function Resolver_resolveCase$(self_, case_, topLevel_, $task) {
2100
- function findVariables_(pattern_) {
2101
- {
2102
- const pattern_a = pattern_;
2103
- {
2104
- if(pattern_a.PString) {
2105
- return ff_core_Map.empty_()
2106
- return
2107
- }
2108
- }
2109
- {
2110
- if(pattern_a.PInt) {
2111
- return ff_core_Map.empty_()
2112
- return
2113
- }
2114
- }
2115
- {
2116
- if(pattern_a.PChar) {
2117
- return ff_core_Map.empty_()
2118
- return
2119
- }
2120
- }
2121
- {
2122
- if(pattern_a.PVariable) {
2123
- const at_ = pattern_a.at_;
2124
- if(pattern_a.name_.Some) {
2125
- const name_ = pattern_a.name_.value_;
2126
- return ff_core_List.List_toMap(ff_core_List.Link(ff_core_Pair.Pair(name_, ff_core_Pair.Pair(at_, name_)), ff_core_List.Empty()), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String)
2127
- return
2128
- }
2129
- }
2130
- }
2131
- {
2132
- if(pattern_a.PVariable) {
2133
- if(pattern_a.name_.None) {
2134
- return ff_core_Map.empty_()
2135
- return
2136
- }
2137
- }
2138
- }
2139
- {
2140
- if(pattern_a.PVariant) {
2141
- const patterns_ = pattern_a.patterns_;
2142
- return ff_core_List.List_foldLeft(ff_core_List.List_map(patterns_, ((pattern_) => {
2143
- return findVariables_(pattern_)
2144
- })), ff_core_Map.empty_(), ((_w1, _w2) => {
2145
- return ff_core_Map.Map_addAll(_w1, _w2, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String)
2146
- }))
2147
- return
2148
- }
2149
- }
2150
- {
2151
- if(pattern_a.PVariantAs) {
2152
- const at_ = pattern_a.at_;
2153
- const variableAt_ = pattern_a.variableAt_;
2154
- const variable_ = pattern_a.variable_;
2155
- return ff_core_List.List_toMap(ff_core_List.List_map(ff_core_Option.Option_toList(variable_), ((x_) => {
2156
- return ff_core_Pair.Pair(x_, ff_core_Pair.Pair(variableAt_, x_))
2157
- })), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String)
2158
- return
2159
- }
2160
- }
2161
- {
2162
- if(pattern_a.PAlias) {
2163
- const at_ = pattern_a.at_;
2164
- const pattern_ = pattern_a.pattern_;
2165
- const variable_ = pattern_a.variable_;
2166
- return ff_core_Map.Map_addAll(ff_core_List.List_toMap(ff_core_List.Link(ff_core_Pair.Pair(variable_, ff_core_Pair.Pair(at_, variable_)), ff_core_List.Empty()), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), findVariables_(pattern_), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String)
2167
- return
2168
- }
2169
- }
2170
- }
2171
- }
2172
- const variableMap_ = ff_core_List.List_foldLeft(ff_core_List.List_map(case_.patterns_, ((pattern_) => {
2173
- return findVariables_(pattern_)
2174
- })), ff_core_Map.empty_(), ((_w1, _w2) => {
2175
- return ff_core_Map.Map_addAll(_w1, _w2, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String)
2176
- }));
2177
- let guards_ = ff_core_List.Empty();
2178
- const variableMap2_ = ff_core_List.List_foldLeft(case_.guards_, variableMap_, ((variableMap1_, g_) => {
2179
- const self2_ = (((_c) => {
2180
- return ff_compiler_Resolver.Resolver(ff_core_Map.Map_addAll(self_.variables_, ff_core_Map.Map_mapValues(variableMap1_, ((_, p_) => {
2181
- return p_.second_
2182
- }), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Map.Map_addAll(self_.variableLocations_, ff_core_Map.Map_mapValues(variableMap1_, ((_, p_) => {
2183
- return p_.first_
2184
- }), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), _c.variants_, _c.types_, _c.typeGenerics_, _c.typeLocations_, _c.asyncTypes_, _c.typeParameters_, _c.traits_, _c.traitLocations_, _c.state_, _c.lspHook_)
2185
- }))(self_);
2186
- const guard_ = (((_c) => {
2187
- return ff_compiler_Syntax.MatchGuard(_c.at_, ff_compiler_Resolver.Resolver_resolveTerm(self2_, g_.term_, topLevel_), ff_compiler_Resolver.Resolver_resolvePattern(self2_, g_.pattern_))
2188
- }))(g_);
2189
- guards_ = ff_core_List.Link(guard_, guards_);
2190
- return ff_core_Map.Map_addAll(variableMap1_, findVariables_(guard_.pattern_), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String)
2191
- }));
2192
- const self3_ = (((_c) => {
2193
- return ff_compiler_Resolver.Resolver(ff_core_Map.Map_addAll(self_.variables_, ff_core_Map.Map_mapValues(variableMap2_, ((_, p_) => {
2194
- return p_.second_
2195
- }), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Map.Map_addAll(self_.variableLocations_, ff_core_Map.Map_mapValues(variableMap2_, ((_, p_) => {
2196
- return p_.first_
2197
- }), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), _c.variants_, _c.types_, _c.typeGenerics_, _c.typeLocations_, _c.asyncTypes_, _c.typeParameters_, _c.traits_, _c.traitLocations_, _c.state_, _c.lspHook_)
2198
- }))(self_);
2199
- return ff_compiler_Syntax.MatchCase(case_.at_, ff_core_List.List_map(case_.patterns_, ((_w1) => {
2200
- return ff_compiler_Resolver.Resolver_resolvePattern(self_, _w1)
2201
- })), ff_core_List.List_reverse(guards_), ff_compiler_Resolver.Resolver_resolveTerm(self3_, case_.body_, topLevel_))
2202
- }
2203
-
2204
- export async function Resolver_resolvePattern$(self_, pattern_, $task) {
2205
- {
2206
- const self_a = self_;
2207
- const pattern_a = pattern_;
2208
- {
2209
- if(pattern_a.PString) {
2210
- return pattern_
2211
- return
2212
- }
2213
- }
2214
- {
2215
- if(pattern_a.PInt) {
2216
- return pattern_
2217
- return
2218
- }
2219
- }
2220
- {
2221
- if(pattern_a.PChar) {
2222
- return pattern_
2223
- return
2224
- }
2225
- }
2226
- {
2227
- if(pattern_a.PVariable) {
2228
- return pattern_
2229
- return
2230
- }
2231
- }
2232
- {
2233
- if(pattern_a.PVariant) {
2234
- const at_ = pattern_a.at_;
2235
- const name_ = pattern_a.name_;
2236
- const patterns_ = pattern_a.patterns_;
2237
- const newName_ = ff_core_Option.Option_else(ff_core_Map.Map_get(self_.variants_, name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), (() => {
2238
- return name_
2239
- }));
2240
- const newPatterns_ = ff_core_List.List_map(patterns_, ((_w1) => {
2241
- return ff_compiler_Resolver.Resolver_resolvePattern(self_, _w1)
2242
- }));
2243
- return ff_compiler_Syntax.PVariant(at_, newName_, newPatterns_)
2244
- return
2245
- }
2246
- }
2247
- {
2248
- if(pattern_a.PVariantAs) {
2249
- const at_ = pattern_a.at_;
2250
- const name_ = pattern_a.name_;
2251
- const variableAt_ = pattern_a.variableAt_;
2252
- const variable_ = pattern_a.variable_;
2253
- const newName_ = ff_core_Option.Option_else(ff_core_Map.Map_get(self_.variants_, name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), (() => {
2254
- return name_
2255
- }));
2256
- return ff_compiler_Syntax.PVariantAs(at_, newName_, variableAt_, variable_)
2257
- return
2258
- }
2259
- }
2260
- {
2261
- if(pattern_a.PAlias) {
2262
- const at_ = pattern_a.at_;
2263
- const pattern_ = pattern_a.pattern_;
2264
- const variable_ = pattern_a.variable_;
2265
- const newPattern_ = ff_compiler_Resolver.Resolver_resolvePattern(self_, pattern_);
2266
- return ff_compiler_Syntax.PAlias(at_, newPattern_, variable_)
2267
- return
2268
- }
2269
- }
2270
- }
2271
- }
2272
-
2273
- export async function Resolver_containsAsyncType$(self_, type_, $task) {
2274
- {
2275
- const self_a = self_;
2276
- const type_a = type_;
2277
- {
2278
- if(type_a.TVariable) {
2279
- return false
2280
- return
2281
- }
2282
- }
2283
- {
2284
- if(type_a.TConstructor) {
2285
- const constructor_ = type_a;
2286
- const name_ = (ff_core_String.String_contains(constructor_.name_, "$")
2287
- ? constructor_.name_
2288
- : ff_core_Option.Option_else(ff_core_Map.Map_get(self_.types_, constructor_.name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), (() => {
2289
- if(ff_compiler_LspHook.LspHook_isEnabled(self_.lspHook_)) {
2290
- return constructor_.name_
2291
- } else {
2292
- throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(constructor_.at_, ("No such type: " + constructor_.name_)), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
2293
- }
2294
- })));
2295
- const isFunctionType_ = ff_core_String.String_startsWith(name_, "Function$", 0);
2296
- return ((isFunctionType_ || ff_core_Set.Set_contains(self_.asyncTypes_, constructor_.name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String)) || ff_core_List.List_any(constructor_.generics_, ((_w1) => {
2297
- return ff_compiler_Resolver.Resolver_containsAsyncType(self_, _w1)
2298
- })))
2299
- return
2300
- }
2301
- }
2302
- }
2303
- }
2304
-
2305
-
2306
-
2307
-
1
+
2
+
3
+ import * as ff_compiler_Resolver from "../../ff/compiler/Resolver.mjs"
4
+
5
+ import * as ff_compiler_LspHook from "../../ff/compiler/LspHook.mjs"
6
+
7
+ import * as ff_compiler_Syntax from "../../ff/compiler/Syntax.mjs"
8
+
9
+ import * as ff_core_Any from "../../ff/core/Any.mjs"
10
+
11
+ import * as ff_core_Array from "../../ff/core/Array.mjs"
12
+
13
+ import * as ff_core_AssetSystem from "../../ff/core/AssetSystem.mjs"
14
+
15
+ import * as ff_core_Atomic from "../../ff/core/Atomic.mjs"
16
+
17
+ import * as ff_core_Bool from "../../ff/core/Bool.mjs"
18
+
19
+ import * as ff_core_Box from "../../ff/core/Box.mjs"
20
+
21
+ import * as ff_core_BrowserSystem from "../../ff/core/BrowserSystem.mjs"
22
+
23
+ import * as ff_core_Buffer from "../../ff/core/Buffer.mjs"
24
+
25
+ import * as ff_core_BuildSystem from "../../ff/core/BuildSystem.mjs"
26
+
27
+ import * as ff_core_Channel from "../../ff/core/Channel.mjs"
28
+
29
+ import * as ff_core_Char from "../../ff/core/Char.mjs"
30
+
31
+ import * as ff_core_Core from "../../ff/core/Core.mjs"
32
+
33
+ import * as ff_core_Duration from "../../ff/core/Duration.mjs"
34
+
35
+ import * as ff_core_Equal from "../../ff/core/Equal.mjs"
36
+
37
+ import * as ff_core_Error from "../../ff/core/Error.mjs"
38
+
39
+ import * as ff_core_FileHandle from "../../ff/core/FileHandle.mjs"
40
+
41
+ import * as ff_core_Float from "../../ff/core/Float.mjs"
42
+
43
+ import * as ff_core_HttpClient from "../../ff/core/HttpClient.mjs"
44
+
45
+ import * as ff_core_Instant from "../../ff/core/Instant.mjs"
46
+
47
+ import * as ff_core_Int from "../../ff/core/Int.mjs"
48
+
49
+ import * as ff_core_IntMap from "../../ff/core/IntMap.mjs"
50
+
51
+ import * as ff_core_JsSystem from "../../ff/core/JsSystem.mjs"
52
+
53
+ import * as ff_core_JsValue from "../../ff/core/JsValue.mjs"
54
+
55
+ import * as ff_core_List from "../../ff/core/List.mjs"
56
+
57
+ import * as ff_core_Lock from "../../ff/core/Lock.mjs"
58
+
59
+ import * as ff_core_Log from "../../ff/core/Log.mjs"
60
+
61
+ import * as ff_core_Map from "../../ff/core/Map.mjs"
62
+
63
+ import * as ff_core_NodeSystem from "../../ff/core/NodeSystem.mjs"
64
+
65
+ import * as ff_core_Nothing from "../../ff/core/Nothing.mjs"
66
+
67
+ import * as ff_core_Option from "../../ff/core/Option.mjs"
68
+
69
+ import * as ff_core_Ordering from "../../ff/core/Ordering.mjs"
70
+
71
+ import * as ff_core_Pair from "../../ff/core/Pair.mjs"
72
+
73
+ import * as ff_core_Path from "../../ff/core/Path.mjs"
74
+
75
+ import * as ff_core_Serializable from "../../ff/core/Serializable.mjs"
76
+
77
+ import * as ff_core_Set from "../../ff/core/Set.mjs"
78
+
79
+ import * as ff_core_Show from "../../ff/core/Show.mjs"
80
+
81
+ import * as ff_core_SourceLocation from "../../ff/core/SourceLocation.mjs"
82
+
83
+ import * as ff_core_Stack from "../../ff/core/Stack.mjs"
84
+
85
+ import * as ff_core_Stream from "../../ff/core/Stream.mjs"
86
+
87
+ import * as ff_core_String from "../../ff/core/String.mjs"
88
+
89
+ import * as ff_core_StringMap from "../../ff/core/StringMap.mjs"
90
+
91
+ import * as ff_core_Task from "../../ff/core/Task.mjs"
92
+
93
+ import * as ff_core_Try from "../../ff/core/Try.mjs"
94
+
95
+ import * as ff_core_Unit from "../../ff/core/Unit.mjs"
96
+
97
+ // type Resolver
98
+ export function Resolver(variables_, variableLocations_, variants_, types_, typeGenerics_, typeLocations_, asyncTypes_, typeParameters_, traits_, traitLocations_, state_, lspHook_) {
99
+ return {variables_, variableLocations_, variants_, types_, typeGenerics_, typeLocations_, asyncTypes_, typeParameters_, traits_, traitLocations_, state_, lspHook_};
100
+ }
101
+
102
+ // type ResolverState
103
+ export function ResolverState(nextUnificationVariableIndex_) {
104
+ return {nextUnificationVariableIndex_};
105
+ }
106
+
107
+
108
+
109
+ export function make_(packagePair_, moduleName_, lspHook_) {
110
+ return ff_compiler_Resolver.Resolver(ff_core_List.List_toMap(ff_core_List.Empty(), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_List.List_toMap(ff_core_List.Empty(), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_List.List_toMap(ff_core_List.Empty(), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_List.List_toMap(ff_core_List.Empty(), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_List.List_toMap(ff_core_List.Empty(), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_List.List_toMap(ff_core_List.Empty(), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_List.List_toSet(ff_core_List.Empty(), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_List.List_toSet(ff_core_List.Empty(), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_List.List_toMap(ff_core_List.Empty(), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_List.List_toMap(ff_core_List.Empty(), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_compiler_Resolver.ResolverState(2), lspHook_)
111
+ }
112
+
113
+ export async function make_$(packagePair_, moduleName_, lspHook_, $task) {
114
+ return ff_compiler_Resolver.Resolver(ff_core_List.List_toMap(ff_core_List.Empty(), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_List.List_toMap(ff_core_List.Empty(), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_List.List_toMap(ff_core_List.Empty(), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_List.List_toMap(ff_core_List.Empty(), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_List.List_toMap(ff_core_List.Empty(), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_List.List_toMap(ff_core_List.Empty(), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_List.List_toSet(ff_core_List.Empty(), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_List.List_toSet(ff_core_List.Empty(), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_List.List_toMap(ff_core_List.Empty(), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_List.List_toMap(ff_core_List.Empty(), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_compiler_Resolver.ResolverState(2), lspHook_)
115
+ }
116
+
117
+ export function Resolver_freshUnificationVariable(self_, at_) {
118
+ const result_ = ff_compiler_Syntax.TVariable(at_, self_.state_.nextUnificationVariableIndex_);
119
+ self_.state_.nextUnificationVariableIndex_ += 3;
120
+ return result_
121
+ }
122
+
123
+ export function Resolver_resolveModule(self_, module_, otherModules_) {
124
+ const moduleNamespace_ = ff_core_String.String_takeWhile(ff_core_String.String_reverse(ff_core_String.String_takeWhile(ff_core_String.String_reverse(ff_core_String.String_replace(module_.file_, "\\", "/")), ((_w1) => {
125
+ return (_w1 !== 47)
126
+ }))), ((_w1) => {
127
+ return (_w1 !== 46)
128
+ }));
129
+ const self2_ = ff_compiler_Resolver.Resolver_processImports(self_, module_.imports_, otherModules_);
130
+ const self3_ = ff_compiler_Resolver.Resolver_processDefinitions(self2_, module_, ff_core_Option.None());
131
+ const module2_ = (((_c) => {
132
+ return ff_compiler_Syntax.Module(_c.file_, _c.packagePair_, _c.imports_, ff_core_List.List_map(module_.types_, ((_w1) => {
133
+ return ff_compiler_Resolver.Resolver_resolveTypeDefinition(self3_, _w1)
134
+ })), ff_core_List.List_map(module_.traits_, ((_w1) => {
135
+ return ff_compiler_Resolver.Resolver_resolveTraitDefinition(self3_, _w1)
136
+ })), ff_core_List.List_map(module_.instances_, ((_w1) => {
137
+ return ff_compiler_Resolver.Resolver_resolveInstanceDefinition(self3_, _w1)
138
+ })), ff_core_List.List_map(module_.extends_, ((_w1) => {
139
+ return ff_compiler_Resolver.Resolver_resolveExtendDefinition(self3_, _w1)
140
+ })), ff_core_List.List_map(module_.lets_, ((_w1) => {
141
+ return ff_compiler_Resolver.Resolver_resolveLetDefinition(self3_, _w1, true)
142
+ })), ff_core_List.List_map(module_.functions_, ((_w1) => {
143
+ return ff_compiler_Resolver.Resolver_resolveFunctionDefinition(self3_, _w1, true, false)
144
+ })))
145
+ }))(module_);
146
+ ff_core_List.List_each(module2_.instances_, ((_w1) => {
147
+ ff_core_List.List_each(_w1.typeArguments_, ((_w1) => {
148
+ ff_compiler_Resolver.Resolver_checkInstanceType(self3_, _w1)
149
+ }))
150
+ }));
151
+ return module2_
152
+ }
153
+
154
+ export function Resolver_checkInstanceType(self_, type_) {
155
+ {
156
+ const _1 = type_;
157
+ {
158
+ if(_1.TConstructor) {
159
+ const name_ = _1.name_;
160
+ const typeArguments_ = _1.generics_;
161
+ if(ff_core_Set.Set_contains(self_.asyncTypes_, name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String)) {
162
+ throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(type_.at_, "Traits must not be instantiated for capability types"), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
163
+ };
164
+ ff_core_List.List_each(typeArguments_, ((_w1) => {
165
+ ff_compiler_Resolver.Resolver_checkInstanceType(self_, _w1)
166
+ }))
167
+ return
168
+ }
169
+ }
170
+ {
171
+
172
+ return
173
+ }
174
+ }
175
+ }
176
+
177
+ export function Resolver_processImports(self_, imports_, modules_) {
178
+ let resolver_ = self_;
179
+ ff_core_List.List_each(imports_, ((import_) => {
180
+ {
181
+ const _1 = ff_core_List.List_find(modules_, ((_w1) => {
182
+ return (ff_core_String.String_dropLast(_w1.file_, 3) === import_.file_)
183
+ }));
184
+ {
185
+ if(_1.Some) {
186
+ const module_ = _1.value_;
187
+ resolver_ = ff_compiler_Resolver.Resolver_processDefinitions(resolver_, module_, ff_core_Option.Some(import_.alias_))
188
+ return
189
+ }
190
+ }
191
+ {
192
+ if(_1.None) {
193
+ throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(import_.at_, ("No such module: " + import_.file_)), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
194
+ return
195
+ }
196
+ }
197
+ }
198
+ }));
199
+ return resolver_
200
+ }
201
+
202
+ export function Resolver_processDefinitions(self_, module_, importAlias_) {
203
+ function entry_(name_, unqualified_) {
204
+ const full_ = ((((ff_compiler_Syntax.PackagePair_groupName(module_.packagePair_, ":") + "/") + ff_core_String.String_dropLast(module_.file_, 3)) + ".") + name_);
205
+ {
206
+ const _1 = importAlias_;
207
+ {
208
+ if(_1.None) {
209
+ return ff_core_List.Link(ff_core_Pair.Pair(name_, full_), ff_core_List.Link(ff_core_Pair.Pair(full_, full_), ff_core_List.Empty()))
210
+ return
211
+ }
212
+ }
213
+ {
214
+ if(_1.Some) {
215
+ const alias_ = _1.value_;
216
+ const _guard1 = unqualified_;
217
+ if(_guard1) {
218
+ return ff_core_List.Link(ff_core_Pair.Pair(((alias_ + ".") + name_), full_), ff_core_List.Link(ff_core_Pair.Pair(name_, full_), ff_core_List.Link(ff_core_Pair.Pair(full_, full_), ff_core_List.Empty())))
219
+ return
220
+ }
221
+ }
222
+ }
223
+ {
224
+ if(_1.Some) {
225
+ const alias_ = _1.value_;
226
+ return ff_core_List.Link(ff_core_Pair.Pair(((alias_ + ".") + name_), full_), ff_core_List.Link(ff_core_Pair.Pair(full_, full_), ff_core_List.Empty()))
227
+ return
228
+ }
229
+ }
230
+ }
231
+ }
232
+ const isCore_ = (((module_.packagePair_.group_ === "ff") && (module_.packagePair_.name_ === "core")) && (module_.file_ === "Core.ff"));
233
+ const lets_ = ff_core_List.List_toMap(ff_core_List.List_flatMap(module_.lets_, ((_w1) => {
234
+ return entry_(_w1.name_, isCore_)
235
+ })), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
236
+ const letLocations_ = ff_core_List.List_toMap(ff_core_List.List_flatMap(module_.lets_, ((d_) => {
237
+ return ff_core_List.List_map(entry_(d_.name_, true), ((_w1) => {
238
+ return ff_core_Pair.Pair_mapSecond(_w1, ((_) => {
239
+ return d_.at_
240
+ }))
241
+ }))
242
+ })), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
243
+ const functions_ = ff_core_List.List_toMap(ff_core_List.List_flatMap(module_.functions_, ((_w1) => {
244
+ return entry_(_w1.signature_.name_, isCore_)
245
+ })), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
246
+ const functionLocations_ = ff_core_List.List_toMap(ff_core_List.List_flatMap(module_.functions_, ((d_) => {
247
+ return ff_core_List.List_map(entry_(d_.signature_.name_, true), ((_w1) => {
248
+ return ff_core_Pair.Pair_mapSecond(_w1, ((_) => {
249
+ return d_.at_
250
+ }))
251
+ }))
252
+ })), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
253
+ const traitMethods_ = ff_core_List.List_toMap(ff_core_List.List_flatMap(ff_core_List.List_flatMap(module_.traits_, ((_w1) => {
254
+ return _w1.methods_
255
+ })), ((_w1) => {
256
+ return entry_(_w1.name_, false)
257
+ })), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
258
+ const traitMethodLocations_ = ff_core_List.List_toMap(ff_core_List.List_flatMap(ff_core_List.List_flatMap(module_.traits_, ((_w1) => {
259
+ return _w1.methods_
260
+ })), ((d_) => {
261
+ return ff_core_List.List_map(entry_(d_.name_, true), ((_w1) => {
262
+ return ff_core_Pair.Pair_mapSecond(_w1, ((_) => {
263
+ return d_.at_
264
+ }))
265
+ }))
266
+ })), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
267
+ const traits_ = ff_core_List.List_toMap(ff_core_List.List_flatMap(module_.traits_, ((_w1) => {
268
+ return entry_(_w1.name_, true)
269
+ })), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
270
+ const traitLocations_ = ff_core_List.List_toMap(ff_core_List.List_flatMap(module_.traits_, ((d_) => {
271
+ return ff_core_List.List_map(entry_(d_.name_, true), ((_w1) => {
272
+ return ff_core_Pair.Pair_mapSecond(_w1, ((_) => {
273
+ return d_.at_
274
+ }))
275
+ }))
276
+ })), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
277
+ const types_ = ff_core_List.List_toMap(ff_core_List.List_flatMap(module_.types_, ((_w1) => {
278
+ return entry_(_w1.name_, true)
279
+ })), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
280
+ const typeGenerics_ = ff_core_List.List_toMap(ff_core_List.List_flatMap(module_.types_, ((d_) => {
281
+ return ff_core_List.List_map(entry_(d_.name_, true), ((p_) => {
282
+ return ff_core_Pair.Pair(p_.first_, d_.generics_)
283
+ }))
284
+ })), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
285
+ const typeLocations_ = ff_core_List.List_toMap(ff_core_List.List_flatMap(module_.types_, ((d_) => {
286
+ return ff_core_List.List_map(entry_(d_.name_, true), ((_w1) => {
287
+ return ff_core_Pair.Pair_mapSecond(_w1, ((_) => {
288
+ return d_.at_
289
+ }))
290
+ }))
291
+ })), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
292
+ const asyncTypes_ = ff_core_List.List_toSet(ff_core_List.List_flatMap(ff_core_List.List_filter(module_.types_, ((_w1) => {
293
+ return ff_core_Option.Option_any(ff_core_List.List_first(_w1.generics_), ((_w1) => {
294
+ return (_w1 === "Q$")
295
+ }))
296
+ })), ((_w1) => {
297
+ return ff_core_List.List_map(entry_(_w1.name_, true), ((_w1) => {
298
+ return _w1.first_
299
+ }))
300
+ })), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
301
+ const variants_ = ff_core_List.List_toMap(ff_core_List.List_flatMap(ff_core_List.List_flatMap(module_.types_, ((_w1) => {
302
+ return _w1.variants_
303
+ })), ((_w1) => {
304
+ return entry_(_w1.name_, true)
305
+ })), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
306
+ {
307
+ const _1 = self_;
308
+ {
309
+ const _c = _1;
310
+ return ff_compiler_Resolver.Resolver(ff_core_Map.Map_addAll(ff_core_Map.Map_addAll(ff_core_Map.Map_addAll(self_.variables_, lets_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), functions_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), traitMethods_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Map.Map_addAll(ff_core_Map.Map_addAll(ff_core_Map.Map_addAll(self_.variableLocations_, letLocations_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), functionLocations_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), traitMethodLocations_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Map.Map_addAll(self_.variants_, variants_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Map.Map_addAll(self_.types_, types_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Map.Map_addAll(self_.typeGenerics_, typeGenerics_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Map.Map_addAll(self_.typeLocations_, typeLocations_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Set.Set_addAll(self_.asyncTypes_, asyncTypes_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_List.List_toSet(ff_core_List.Empty(), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Map.Map_addAll(self_.traits_, traits_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Map.Map_addAll(self_.traitLocations_, traitLocations_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), self_.state_, _c.lspHook_)
311
+ return
312
+ }
313
+ }
314
+ }
315
+
316
+ export function Resolver_resolveTypeDefinition(self_, definition_) {
317
+ if(ff_compiler_LspHook.LspHook_isAt(self_.lspHook_, definition_.at_)) {
318
+ ff_compiler_LspHook.LspHook_emit(self_.lspHook_, ff_compiler_LspHook.ResolveSymbolHook(ff_compiler_LspHook.SymbolHook(definition_.name_, definition_.at_, definition_.at_), ff_core_Option.None()))
319
+ };
320
+ const generics_ = ff_core_List.List_toMap(ff_core_List.List_map(definition_.generics_, ((g_) => {
321
+ return ff_core_Pair.Pair(g_, g_)
322
+ })), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
323
+ const self2_ = (((_c) => {
324
+ return ff_compiler_Resolver.Resolver(_c.variables_, _c.variableLocations_, _c.variants_, ff_core_Map.Map_addAll(self_.types_, generics_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), _c.typeGenerics_, _c.typeLocations_, ff_core_Set.Set_removeAll(self_.asyncTypes_, ff_core_List.List_toSet(definition_.generics_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Set.Set_addAll(self_.typeParameters_, ff_core_List.List_toSet(definition_.generics_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), _c.traits_, _c.traitLocations_, _c.state_, _c.lspHook_)
325
+ }))(self_);
326
+ if((!ff_core_Option.Option_any(ff_core_List.List_first(definition_.generics_), ((_w1) => {
327
+ return (_w1 === "Q$")
328
+ })))) {
329
+ ff_core_List.List_each(ff_core_List.List_addAll(definition_.commonFields_, ff_core_List.List_flatMap(definition_.variants_, ((_w1) => {
330
+ return _w1.fields_
331
+ }))), ((f_) => {
332
+ if(ff_compiler_Resolver.Resolver_containsAsyncType(self2_, f_.valueType_)) {
333
+ throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(f_.at_, "Only capabilities can contain fields of concrete capability types"), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
334
+ }
335
+ }))
336
+ };
337
+ {
338
+ const _1 = definition_;
339
+ {
340
+ const _c = _1;
341
+ return ff_compiler_Syntax.DType(_c.at_, _c.newtype_, _c.data_, _c.name_, _c.generics_, ff_core_List.List_map(definition_.constraints_, ((_w1) => {
342
+ return ff_compiler_Resolver.Resolver_resolveConstraint(self2_, _w1, true)
343
+ })), ff_core_List.List_map(definition_.commonFields_, ((f_) => {
344
+ const valueType_ = ff_compiler_Resolver.Resolver_resolveType(self2_, f_.valueType_, true);
345
+ if((ff_compiler_LspHook.LspHook_isAt(self_.lspHook_, f_.at_) || ff_compiler_LspHook.LspHook_isDefinedAt(self_.lspHook_, f_.at_))) {
346
+ ff_compiler_LspHook.LspHook_emit(self_.lspHook_, ff_compiler_LspHook.ResolveVariantFieldHook(ff_compiler_LspHook.SymbolHook(f_.name_, f_.at_, f_.at_), valueType_, true))
347
+ };
348
+ {
349
+ const _1 = f_;
350
+ {
351
+ const _c = _1;
352
+ return ff_compiler_Syntax.Parameter(_c.at_, _c.mutable_, _c.name_, valueType_, ff_core_Option.Option_map(f_.default_, ((_w1) => {
353
+ return ff_compiler_Resolver.Resolver_resolveTerm(self2_, _w1, true)
354
+ })))
355
+ return
356
+ }
357
+ }
358
+ })), ff_core_List.List_map(definition_.variants_, ((v_) => {
359
+ if(ff_compiler_LspHook.LspHook_isAt(self_.lspHook_, v_.at_)) {
360
+ ff_compiler_LspHook.LspHook_emit(self_.lspHook_, ff_compiler_LspHook.ResolveSymbolHook(ff_compiler_LspHook.SymbolHook(v_.name_, v_.at_, v_.at_), ff_core_Option.None()))
361
+ };
362
+ {
363
+ const _1 = v_;
364
+ {
365
+ const _c = _1;
366
+ return ff_compiler_Syntax.Variant(_c.at_, _c.name_, ff_core_List.List_map(v_.fields_, ((f_) => {
367
+ const valueType_ = ff_compiler_Resolver.Resolver_resolveType(self2_, f_.valueType_, true);
368
+ if((ff_compiler_LspHook.LspHook_isAt(self_.lspHook_, f_.at_) || ff_compiler_LspHook.LspHook_isDefinedAt(self_.lspHook_, f_.at_))) {
369
+ ff_compiler_LspHook.LspHook_emit(self_.lspHook_, ff_compiler_LspHook.ResolveVariantFieldHook(ff_compiler_LspHook.SymbolHook(f_.name_, f_.at_, f_.at_), valueType_, false))
370
+ };
371
+ {
372
+ const _1 = f_;
373
+ {
374
+ const _c = _1;
375
+ return ff_compiler_Syntax.Parameter(_c.at_, _c.mutable_, _c.name_, valueType_, ff_core_Option.Option_map(f_.default_, ((_w1) => {
376
+ return ff_compiler_Resolver.Resolver_resolveTerm(self2_, _w1, true)
377
+ })))
378
+ return
379
+ }
380
+ }
381
+ })))
382
+ return
383
+ }
384
+ }
385
+ })))
386
+ return
387
+ }
388
+ }
389
+ }
390
+
391
+ export function Resolver_resolveTraitDefinition(self_, definition_) {
392
+ if((ff_compiler_LspHook.LspHook_isAt(self_.lspHook_, definition_.at_) || ff_compiler_LspHook.LspHook_isDefinedAt(self_.lspHook_, definition_.at_))) {
393
+ ff_compiler_LspHook.LspHook_emit(self_.lspHook_, ff_compiler_LspHook.ResolveSymbolHook(ff_compiler_LspHook.SymbolHook(definition_.name_, definition_.at_, definition_.at_), ff_core_Option.None()))
394
+ };
395
+ const generics_ = ff_core_List.List_toMap(ff_core_List.List_map(definition_.generics_, ((g_) => {
396
+ return ff_core_Pair.Pair(g_, g_)
397
+ })), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
398
+ const self2_ = (((_c) => {
399
+ return ff_compiler_Resolver.Resolver(_c.variables_, _c.variableLocations_, _c.variants_, ff_core_Map.Map_addAll(self_.types_, generics_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), _c.typeGenerics_, _c.typeLocations_, ff_core_Set.Set_removeAll(self_.asyncTypes_, ff_core_List.List_toSet(definition_.generics_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Set.Set_addAll(self_.typeParameters_, ff_core_List.List_toSet(definition_.generics_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), _c.traits_, _c.traitLocations_, _c.state_, _c.lspHook_)
400
+ }))(self_);
401
+ {
402
+ const _1 = definition_;
403
+ {
404
+ const _c = _1;
405
+ return ff_compiler_Syntax.DTrait(_c.at_, _c.name_, _c.generics_, ff_core_List.List_map(definition_.constraints_, ((_w1) => {
406
+ return ff_compiler_Resolver.Resolver_resolveConstraint(self2_, _w1, true)
407
+ })), _c.generatorParameters_, ff_core_List.List_map(definition_.methods_, ((_w1) => {
408
+ return ff_compiler_Resolver.Resolver_resolveSignature(self2_, _w1, true, false)
409
+ })), ff_core_List.List_map(definition_.methodDefaults_, ((_1) => {
410
+ {
411
+ const name_ = _1.first_;
412
+ const lambda_ = _1.second_;
413
+ const signature_ = ff_core_Option.Option_grab(ff_core_List.List_find(definition_.methods_, ((_w1) => {
414
+ return (_w1.name_ === name_)
415
+ })));
416
+ const function1_ = ff_compiler_Syntax.DFunction(signature_.at_, signature_, ff_compiler_Syntax.FireflyTarget(lambda_));
417
+ const function2_ = ff_compiler_Resolver.Resolver_resolveFunctionDefinition(self2_, function1_, true, false);
418
+ return ff_core_Pair.Pair(name_, (((_1) => {
419
+ {
420
+ if(_1.FireflyTarget) {
421
+ const lambda_ = _1.lambda_;
422
+ return lambda_
423
+ return
424
+ }
425
+ }
426
+ {
427
+ throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(signature_.at_, "Internal error: Expected method default to be a lambda"), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
428
+ return
429
+ }
430
+ }))(function2_.body_))
431
+ return
432
+ }
433
+ })), _c.methodGenerators_)
434
+ return
435
+ }
436
+ }
437
+ }
438
+
439
+ export function Resolver_resolveInstanceDefinition(self_, definition_) {
440
+ const traitDefinedAt_ = ff_core_Option.Option_else(ff_core_Map.Map_get(self_.traitLocations_, definition_.traitName_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), (() => {
441
+ return definition_.at_
442
+ }));
443
+ if((ff_compiler_LspHook.LspHook_isAt(self_.lspHook_, definition_.at_) || ff_compiler_LspHook.LspHook_isDefinedAt(self_.lspHook_, traitDefinedAt_))) {
444
+ ff_compiler_LspHook.LspHook_emit(self_.lspHook_, ff_compiler_LspHook.ResolveSymbolHook(ff_compiler_LspHook.SymbolHook(definition_.traitName_, definition_.at_, traitDefinedAt_), ff_core_Option.None()))
445
+ };
446
+ const generics_ = ff_core_List.List_toMap(ff_core_List.List_map(definition_.generics_, ((g_) => {
447
+ return ff_core_Pair.Pair(g_, g_)
448
+ })), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
449
+ const self2_ = (((_c) => {
450
+ return ff_compiler_Resolver.Resolver(_c.variables_, _c.variableLocations_, _c.variants_, ff_core_Map.Map_addAll(self_.types_, generics_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), _c.typeGenerics_, _c.typeLocations_, ff_core_Set.Set_removeAll(self_.asyncTypes_, ff_core_List.List_toSet(definition_.generics_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Set.Set_addAll(self_.typeParameters_, ff_core_List.List_toSet(definition_.generics_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), _c.traits_, _c.traitLocations_, _c.state_, _c.lspHook_)
451
+ }))(self_);
452
+ const traitName_ = ff_core_Option.Option_else(ff_core_Map.Map_get(self2_.traits_, definition_.traitName_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), (() => {
453
+ throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(definition_.at_, ("No such trait: " + definition_.traitName_)), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
454
+ }));
455
+ {
456
+ const _1 = definition_;
457
+ {
458
+ const _c = _1;
459
+ return ff_compiler_Syntax.DInstance(_c.at_, _c.generics_, ff_core_List.List_map(definition_.constraints_, ((_w1) => {
460
+ return ff_compiler_Resolver.Resolver_resolveConstraint(self2_, _w1, true)
461
+ })), traitName_, ff_core_List.List_map(definition_.typeArguments_, ((_w1) => {
462
+ return ff_compiler_Resolver.Resolver_resolveType(self2_, _w1, true)
463
+ })), _c.generatorArguments_, ff_core_List.List_map(definition_.methods_, ((_w1) => {
464
+ return ff_compiler_Resolver.Resolver_resolveFunctionDefinition(self2_, _w1, true, true)
465
+ })), _c.derived_)
466
+ return
467
+ }
468
+ }
469
+ }
470
+
471
+ export function Resolver_resolveExtendDefinition(self_, definition_) {
472
+ const generics_ = ff_core_List.List_toMap(ff_core_List.List_map(definition_.generics_, ((g_) => {
473
+ return ff_core_Pair.Pair(g_, g_)
474
+ })), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
475
+ const selfWithNoQ_ = (((_c) => {
476
+ return ff_compiler_Resolver.Resolver(ff_core_Map.Map_add(self_.variables_, definition_.name_, definition_.name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Map.Map_add(self_.variableLocations_, definition_.name_, definition_.at_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), _c.variants_, ff_core_Map.Map_addAll(self_.types_, generics_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), _c.typeGenerics_, _c.typeLocations_, ff_core_Set.Set_removeAll(self_.asyncTypes_, ff_core_List.List_toSet(definition_.generics_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Set.Set_addAll(self_.typeParameters_, ff_core_List.List_toSet(definition_.generics_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), _c.traits_, _c.traitLocations_, _c.state_, _c.lspHook_)
477
+ }))(self_);
478
+ const selfWithQ_ = (((_c) => {
479
+ return ff_compiler_Resolver.Resolver(_c.variables_, _c.variableLocations_, _c.variants_, ff_core_Map.Map_add(selfWithNoQ_.types_, "Q$", "Q$", ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), _c.typeGenerics_, _c.typeLocations_, _c.asyncTypes_, ff_core_Set.Set_add(selfWithNoQ_.typeParameters_, "Q$", ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), _c.traits_, _c.traitLocations_, _c.state_, _c.lspHook_)
480
+ }))(selfWithNoQ_);
481
+ {
482
+ const _1 = definition_;
483
+ {
484
+ const _c = _1;
485
+ return ff_compiler_Syntax.DExtend(_c.at_, _c.name_, _c.generics_, ff_core_List.List_map(definition_.constraints_, ((_w1) => {
486
+ return ff_compiler_Resolver.Resolver_resolveConstraint(selfWithQ_, _w1, true)
487
+ })), ff_compiler_Resolver.Resolver_resolveType(selfWithQ_, definition_.type_, true), ff_core_List.List_map(definition_.methods_, ((_w1) => {
488
+ return ff_compiler_Resolver.Resolver_resolveFunctionDefinition(selfWithNoQ_, _w1, true, false)
489
+ })))
490
+ return
491
+ }
492
+ }
493
+ }
494
+
495
+ export function Resolver_resolveLetDefinition(self_, definition_, topLevel_) {
496
+ if((ff_compiler_LspHook.LspHook_isAt(self_.lspHook_, definition_.at_) || ff_compiler_LspHook.LspHook_isDefinedAt(self_.lspHook_, definition_.at_))) {
497
+ ff_compiler_LspHook.LspHook_emit(self_.lspHook_, ff_compiler_LspHook.ResolveSymbolHook(ff_compiler_LspHook.SymbolHook(definition_.name_, definition_.at_, definition_.at_), ff_core_Option.None()))
498
+ };
499
+ {
500
+ const _1 = definition_;
501
+ {
502
+ const _c = _1;
503
+ return ff_compiler_Syntax.DLet(_c.at_, _c.name_, ff_compiler_Resolver.Resolver_resolveType(self_, definition_.variableType_, topLevel_), ff_compiler_Resolver.Resolver_resolveTerm(self_, definition_.value_, true))
504
+ return
505
+ }
506
+ }
507
+ }
508
+
509
+ export function Resolver_resolveTerm(self_, term_, topLevel_) {
510
+ {
511
+ const self_a = self_;
512
+ const term_a = term_;
513
+ const topLevel_a = topLevel_;
514
+ {
515
+ if(term_a.EString) {
516
+ return term_
517
+ return
518
+ }
519
+ }
520
+ {
521
+ if(term_a.EChar) {
522
+ return term_
523
+ return
524
+ }
525
+ }
526
+ {
527
+ if(term_a.EInt) {
528
+ return term_
529
+ return
530
+ }
531
+ }
532
+ {
533
+ if(term_a.EFloat) {
534
+ return term_
535
+ return
536
+ }
537
+ }
538
+ {
539
+ if(term_a.EVariable) {
540
+ const e_ = term_a;
541
+ if(ff_compiler_LspHook.LspHook_isEnabled(self_.lspHook_)) {
542
+ const at_ = ff_core_Option.Option_else(ff_core_Map.Map_get(self_.variableLocations_, e_.name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), (() => {
543
+ return e_.at_
544
+ }));
545
+ if((ff_compiler_LspHook.LspHook_isAt(self_.lspHook_, e_.at_) || ff_compiler_LspHook.LspHook_isDefinedAt(self_.lspHook_, at_))) {
546
+ ff_compiler_LspHook.LspHook_emit(self_.lspHook_, ff_compiler_LspHook.ResolveSymbolHook(ff_compiler_LspHook.SymbolHook(e_.name_, e_.at_, at_), ff_core_Option.None()))
547
+ }
548
+ };
549
+ return ff_core_Option.Option_else(ff_core_Option.Option_map(ff_core_Map.Map_get(self_.variables_, e_.name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ((_w1) => {
550
+ {
551
+ const _1 = e_;
552
+ {
553
+ const _c = _1;
554
+ return ff_compiler_Syntax.EVariable(_c.at_, _w1)
555
+ return
556
+ }
557
+ }
558
+ })), (() => {
559
+ return term_
560
+ }))
561
+ return
562
+ }
563
+ }
564
+ {
565
+ if(term_a.EList) {
566
+ const at_ = term_a.at_;
567
+ const t_ = term_a.elementType_;
568
+ const items_ = term_a.items_;
569
+ return ff_compiler_Syntax.EList(at_, ff_compiler_Resolver.Resolver_resolveType(self_, t_, topLevel_), ff_core_List.List_map(items_, ((_1) => {
570
+ {
571
+ const item_ = _1.first_;
572
+ const spread_ = _1.second_;
573
+ return ff_core_Pair.Pair(ff_compiler_Resolver.Resolver_resolveTerm(self_, item_, topLevel_), spread_)
574
+ return
575
+ }
576
+ })))
577
+ return
578
+ }
579
+ }
580
+ {
581
+ if(term_a.EVariant) {
582
+ const at_ = term_a.at_;
583
+ const name_ = term_a.name_;
584
+ const typeArguments_ = term_a.typeArguments_;
585
+ const arguments_ = term_a.arguments_;
586
+ return ff_compiler_Syntax.EVariant(at_, ff_core_Option.Option_else(ff_core_Map.Map_get(self_.variants_, name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), (() => {
587
+ return name_
588
+ })), ff_core_List.List_map(typeArguments_, ((_w1) => {
589
+ return ff_compiler_Resolver.Resolver_resolveType(self_, _w1, topLevel_)
590
+ })), ff_core_Option.Option_map(arguments_, ((_w1) => {
591
+ return ff_core_List.List_map(_w1, ((a_) => {
592
+ {
593
+ const _1 = a_;
594
+ {
595
+ const _c = _1;
596
+ return ff_compiler_Syntax.Argument(_c.at_, _c.name_, ff_compiler_Resolver.Resolver_resolveTerm(self_, a_.value_, topLevel_))
597
+ return
598
+ }
599
+ }
600
+ }))
601
+ })))
602
+ return
603
+ }
604
+ }
605
+ {
606
+ if(term_a.EVariantIs) {
607
+ const at_ = term_a.at_;
608
+ const name_ = term_a.name_;
609
+ const typeArguments_ = term_a.typeArguments_;
610
+ return ff_compiler_Syntax.EVariantIs(at_, ff_core_Option.Option_else(ff_core_Map.Map_get(self_.variants_, name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), (() => {
611
+ throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(at_, ("No such variant: " + name_)), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
612
+ })), ff_core_List.List_map(typeArguments_, ((_w1) => {
613
+ return ff_compiler_Resolver.Resolver_resolveType(self_, _w1, topLevel_)
614
+ })))
615
+ return
616
+ }
617
+ }
618
+ {
619
+ if(term_a.ECopy) {
620
+ const at_ = term_a.at_;
621
+ const name_ = term_a.name_;
622
+ const record_ = term_a.record_;
623
+ const arguments_ = term_a.arguments_;
624
+ return ff_compiler_Syntax.ECopy(at_, ff_core_Option.Option_else(ff_core_Map.Map_get(self_.variants_, name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), (() => {
625
+ return name_
626
+ })), ff_compiler_Resolver.Resolver_resolveTerm(self_, record_, topLevel_), ff_core_List.List_map(arguments_, ((f_) => {
627
+ {
628
+ const _1 = f_;
629
+ {
630
+ const _c = _1;
631
+ return ff_compiler_Syntax.Field(_c.at_, _c.name_, ff_compiler_Resolver.Resolver_resolveTerm(self_, f_.value_, topLevel_))
632
+ return
633
+ }
634
+ }
635
+ })))
636
+ return
637
+ }
638
+ }
639
+ {
640
+ if(term_a.EField) {
641
+ const e_ = term_a;
642
+ {
643
+ const _1 = e_;
644
+ {
645
+ const _c = _1;
646
+ return ff_compiler_Syntax.EField(_c.at_, _c.newtype_, ff_compiler_Resolver.Resolver_resolveTerm(self_, e_.record_, topLevel_), _c.field_)
647
+ return
648
+ }
649
+ }
650
+ return
651
+ }
652
+ }
653
+ {
654
+ if(term_a.ELambda) {
655
+ const at_ = term_a.at_;
656
+ const lambdaAt_ = term_a.lambda_.at_;
657
+ const cases_ = term_a.lambda_.cases_;
658
+ const effect_ = ff_compiler_Resolver.Resolver_makeEffectArgument(self_, lambdaAt_, topLevel_);
659
+ return ff_compiler_Syntax.ELambda(at_, ff_compiler_Syntax.Lambda(lambdaAt_, effect_, ff_core_List.List_map(cases_, ((_w1) => {
660
+ return ff_compiler_Resolver.Resolver_resolveCase(self_, _w1, topLevel_)
661
+ }))))
662
+ return
663
+ }
664
+ }
665
+ {
666
+ if(term_a.EPipe) {
667
+ const at_ = term_a.at_;
668
+ const value_ = term_a.value_;
669
+ const effect_ = term_a.effect_;
670
+ const function_ = term_a.function_;
671
+ return ff_compiler_Syntax.EPipe(at_, ff_compiler_Resolver.Resolver_resolveTerm(self_, value_, topLevel_), ff_compiler_Resolver.Resolver_resolveType(self_, effect_, topLevel_), ff_compiler_Resolver.Resolver_resolveTerm(self_, function_, topLevel_))
672
+ return
673
+ }
674
+ }
675
+ {
676
+ if(term_a.ECall) {
677
+ const at_ = term_a.at_;
678
+ if(term_a.target_.DynamicCall) {
679
+ const target_ = term_a.target_;
680
+ const effect_ = term_a.effect_;
681
+ const typeArguments_ = term_a.typeArguments_;
682
+ const arguments_ = term_a.arguments_;
683
+ const dictionaries_ = term_a.dictionaries_;
684
+ return ff_compiler_Syntax.ECall(at_, (((_c) => {
685
+ return ff_compiler_Syntax.DynamicCall(ff_compiler_Resolver.Resolver_resolveTerm(self_, target_.function_, topLevel_), _c.tailCall_)
686
+ }))(target_), ff_compiler_Resolver.Resolver_resolveType(self_, effect_, topLevel_), ff_core_List.List_map(typeArguments_, ((_w1) => {
687
+ return ff_compiler_Resolver.Resolver_resolveType(self_, _w1, topLevel_)
688
+ })), ff_core_List.List_map(arguments_, ((a_) => {
689
+ {
690
+ const _1 = a_;
691
+ {
692
+ const _c = _1;
693
+ return ff_compiler_Syntax.Argument(_c.at_, _c.name_, ff_compiler_Resolver.Resolver_resolveTerm(self_, a_.value_, topLevel_))
694
+ return
695
+ }
696
+ }
697
+ })), dictionaries_)
698
+ return
699
+ }
700
+ }
701
+ }
702
+ {
703
+ if(term_a.ECall) {
704
+ const at_ = term_a.at_;
705
+ if(term_a.target_.StaticCall) {
706
+ throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(at_, "Internal error: Static calls not expected in the Resolver phase"), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
707
+ return
708
+ }
709
+ }
710
+ }
711
+ {
712
+ if(term_a.ERecord) {
713
+ const at_ = term_a.at_;
714
+ const fields_ = term_a.fields_;
715
+ return ff_compiler_Syntax.ERecord(at_, ff_core_List.List_map(fields_, ((f_) => {
716
+ {
717
+ const _1 = f_;
718
+ {
719
+ const _c = _1;
720
+ return ff_compiler_Syntax.Field(_c.at_, _c.name_, ff_compiler_Resolver.Resolver_resolveTerm(self_, f_.value_, topLevel_))
721
+ return
722
+ }
723
+ }
724
+ })))
725
+ return
726
+ }
727
+ }
728
+ {
729
+ if(term_a.EWildcard) {
730
+ const e_ = term_a;
731
+ if((e_.index_ === 0)) {
732
+ throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(e_.at_, "Unbound wildcard"), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
733
+ };
734
+ {
735
+ const _1 = e_;
736
+ {
737
+ const _c = _1;
738
+ return ff_compiler_Syntax.EWildcard(_c.at_, _c.index_)
739
+ return
740
+ }
741
+ }
742
+ return
743
+ }
744
+ }
745
+ {
746
+ if(term_a.EFunctions) {
747
+ const at_ = term_a.at_;
748
+ const functions_ = term_a.functions_;
749
+ const body_ = term_a.body_;
750
+ const functionMap_ = ff_core_List.List_toMap(ff_core_List.List_map(ff_core_List.List_map(functions_, ((_w1) => {
751
+ return _w1.signature_.name_
752
+ })), ((name_) => {
753
+ return ff_core_Pair.Pair(name_, name_)
754
+ })), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
755
+ const locationMap_ = ff_core_List.List_toMap(ff_core_List.List_map(ff_core_List.List_map(functions_, ((_w1) => {
756
+ return _w1.signature_
757
+ })), ((s_) => {
758
+ return ff_core_Pair.Pair(s_.name_, s_.at_)
759
+ })), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
760
+ const self2_ = (((_c) => {
761
+ return ff_compiler_Resolver.Resolver(ff_core_Map.Map_addAll(self_.variables_, functionMap_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Map.Map_addAll(self_.variableLocations_, locationMap_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), _c.variants_, _c.types_, _c.typeGenerics_, _c.typeLocations_, _c.asyncTypes_, _c.typeParameters_, _c.traits_, _c.traitLocations_, _c.state_, _c.lspHook_)
762
+ }))(self_);
763
+ return ff_compiler_Syntax.EFunctions(at_, ff_core_List.List_map(functions_, ((_w1) => {
764
+ return ff_compiler_Resolver.Resolver_resolveFunctionDefinition(self2_, _w1, topLevel_, false)
765
+ })), ff_compiler_Resolver.Resolver_resolveTerm(self2_, body_, topLevel_))
766
+ return
767
+ }
768
+ }
769
+ {
770
+ if(term_a.ELet) {
771
+ const e_ = term_a;
772
+ const self2_ = (((_c) => {
773
+ return ff_compiler_Resolver.Resolver(ff_core_Map.Map_add(self_.variables_, e_.name_, e_.name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Map.Map_add(self_.variableLocations_, e_.name_, e_.at_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), _c.variants_, _c.types_, _c.typeGenerics_, _c.typeLocations_, _c.asyncTypes_, _c.typeParameters_, _c.traits_, _c.traitLocations_, _c.state_, _c.lspHook_)
774
+ }))(self_);
775
+ if(ff_compiler_LspHook.LspHook_isEnabled(self_.lspHook_)) {
776
+ if((ff_compiler_LspHook.LspHook_isAt(self_.lspHook_, e_.at_) || ff_compiler_LspHook.LspHook_isDefinedAt(self_.lspHook_, e_.at_))) {
777
+ ff_compiler_LspHook.LspHook_emit(self_.lspHook_, ff_compiler_LspHook.ResolveSymbolHook(ff_compiler_LspHook.SymbolHook(e_.name_, e_.at_, e_.at_), ff_core_Option.None()))
778
+ }
779
+ };
780
+ {
781
+ const _1 = e_;
782
+ {
783
+ const _c = _1;
784
+ return ff_compiler_Syntax.ELet(_c.at_, _c.mutable_, _c.name_, ff_compiler_Resolver.Resolver_resolveType(self_, e_.valueType_, topLevel_), ff_compiler_Resolver.Resolver_resolveTerm(self_, e_.value_, topLevel_), ff_compiler_Resolver.Resolver_resolveTerm(self2_, e_.body_, topLevel_))
785
+ return
786
+ }
787
+ }
788
+ return
789
+ }
790
+ }
791
+ {
792
+ if(term_a.ESequential) {
793
+ const at_ = term_a.at_;
794
+ const before_ = term_a.before_;
795
+ const after_ = term_a.after_;
796
+ return ff_compiler_Syntax.ESequential(at_, ff_compiler_Resolver.Resolver_resolveTerm(self_, before_, topLevel_), ff_compiler_Resolver.Resolver_resolveTerm(self_, after_, topLevel_))
797
+ return
798
+ }
799
+ }
800
+ {
801
+ if(term_a.EAssign) {
802
+ const at_ = term_a.at_;
803
+ const operator_ = term_a.operator_;
804
+ const variable_ = term_a.variable_;
805
+ const value_ = term_a.value_;
806
+ return ff_compiler_Syntax.EAssign(at_, operator_, ff_core_Option.Option_else(ff_core_Map.Map_get(self_.variables_, variable_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), (() => {
807
+ throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(at_, ("No such variable: " + variable_)), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
808
+ })), ff_compiler_Resolver.Resolver_resolveTerm(self_, value_, topLevel_))
809
+ return
810
+ }
811
+ }
812
+ {
813
+ if(term_a.EAssignField) {
814
+ const at_ = term_a.at_;
815
+ const operator_ = term_a.operator_;
816
+ const record_ = term_a.record_;
817
+ const field_ = term_a.field_;
818
+ const value_ = term_a.value_;
819
+ return ff_compiler_Syntax.EAssignField(at_, operator_, ff_compiler_Resolver.Resolver_resolveTerm(self_, record_, topLevel_), field_, ff_compiler_Resolver.Resolver_resolveTerm(self_, value_, topLevel_))
820
+ return
821
+ }
822
+ }
823
+ }
824
+ }
825
+
826
+ export function Resolver_resolveType(self_, type_, topLevel_) {
827
+ {
828
+ const self_a = self_;
829
+ const type_a = type_;
830
+ const topLevel_a = topLevel_;
831
+ {
832
+ if(type_a.TVariable) {
833
+ return type_
834
+ return
835
+ }
836
+ }
837
+ {
838
+ if(type_a.TConstructor) {
839
+ const constructor_ = type_a;
840
+ if(ff_compiler_LspHook.LspHook_isEnabled(self_.lspHook_)) {
841
+ const at_ = ff_core_Option.Option_else(ff_core_Map.Map_get(self_.typeLocations_, constructor_.name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), (() => {
842
+ return type_.at_
843
+ }));
844
+ if((ff_compiler_LspHook.LspHook_isAt(self_.lspHook_, type_.at_) || ff_compiler_LspHook.LspHook_isDefinedAt(self_.lspHook_, at_))) {
845
+ ff_compiler_LspHook.LspHook_emit(self_.lspHook_, ff_compiler_LspHook.ResolveTypeHook(self_.types_, self_.typeGenerics_, ff_compiler_LspHook.SymbolHook(constructor_.name_, type_.at_, at_), type_))
846
+ }
847
+ };
848
+ const name_ = (ff_core_String.String_contains(constructor_.name_, "$")
849
+ ? constructor_.name_
850
+ : ff_core_Option.Option_else(ff_core_Map.Map_get(self_.types_, constructor_.name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), (() => {
851
+ if((!ff_compiler_LspHook.LspHook_isEnabled(self_.lspHook_))) {
852
+ throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(constructor_.at_, ("No such type: " + constructor_.name_)), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
853
+ } else {
854
+ return constructor_.name_
855
+ }
856
+ })));
857
+ const isFunctionType_ = ff_core_String.String_startsWith(name_, "Function$", 0);
858
+ const effect_ = ((isFunctionType_ || ff_core_Set.Set_contains(self_.asyncTypes_, constructor_.name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String))
859
+ ? ff_core_List.Link(ff_compiler_Resolver.Resolver_makeEffectArgument(self_, constructor_.at_, topLevel_), ff_core_List.Empty())
860
+ : ff_core_List.Empty());
861
+ const generics_ = ff_core_List.List_map(constructor_.generics_, ((_w1) => {
862
+ return ff_compiler_Resolver.Resolver_resolveType(self_, _w1, topLevel_)
863
+ }));
864
+ if(isFunctionType_) {
865
+ const arguments_ = ff_core_List.List_dropLast(generics_, 1);
866
+ const returnType_ = ff_core_List.List_grabLast(generics_);
867
+ {
868
+ const _1 = constructor_;
869
+ {
870
+ const _c = _1;
871
+ return ff_compiler_Syntax.TConstructor(_c.at_, name_, ff_core_List.List_addAll(effect_, ff_core_List.List_addAll(arguments_, ff_core_List.Link(returnType_, ff_core_List.Empty()))))
872
+ return
873
+ }
874
+ }
875
+ } else {
876
+ {
877
+ const _1 = constructor_;
878
+ {
879
+ const _c = _1;
880
+ return ff_compiler_Syntax.TConstructor(_c.at_, name_, ff_core_List.List_addAll(effect_, generics_))
881
+ return
882
+ }
883
+ }
884
+ }
885
+ return
886
+ }
887
+ }
888
+ }
889
+ }
890
+
891
+ export function Resolver_makeEffectArgument(self_, at_, topLevel_) {
892
+ if(topLevel_) {
893
+ if((!ff_core_Set.Set_contains(self_.typeParameters_, "Q$", ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String))) {
894
+ return ff_compiler_Syntax.TConstructor(at_, "ff:core/Nothing.Nothing", ff_core_List.Empty())
895
+ } else {
896
+ return ff_compiler_Syntax.TConstructor(at_, "Q$", ff_core_List.Empty())
897
+ }
898
+ } else {
899
+ return ff_compiler_Resolver.Resolver_freshUnificationVariable(self_, at_)
900
+ }
901
+ }
902
+
903
+ export function Resolver_resolveConstraint(self_, constraint_, topLevel_) {
904
+ const traitDefinedAt_ = ff_core_Option.Option_else(ff_core_Map.Map_get(self_.traitLocations_, constraint_.name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), (() => {
905
+ return constraint_.at_
906
+ }));
907
+ if((ff_compiler_LspHook.LspHook_isAt(self_.lspHook_, constraint_.at_) || ff_compiler_LspHook.LspHook_isDefinedAt(self_.lspHook_, traitDefinedAt_))) {
908
+ ff_compiler_LspHook.LspHook_emit(self_.lspHook_, ff_compiler_LspHook.ResolveConstraintHook(ff_compiler_LspHook.SymbolHook(constraint_.name_, constraint_.at_, traitDefinedAt_), constraint_))
909
+ };
910
+ const name_ = ff_core_Option.Option_else(ff_core_Map.Map_get(self_.traits_, constraint_.name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), (() => {
911
+ throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(constraint_.at_, ("No such trait: " + constraint_.name_)), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
912
+ }));
913
+ {
914
+ const _1 = constraint_;
915
+ {
916
+ const _c = _1;
917
+ return ff_compiler_Syntax.Constraint(_c.at_, name_, ff_core_List.List_map(constraint_.generics_, ((_w1) => {
918
+ return ff_compiler_Resolver.Resolver_resolveType(self_, _w1, topLevel_)
919
+ })))
920
+ return
921
+ }
922
+ }
923
+ }
924
+
925
+ export function Resolver_resolveFunctionDefinition(self_, definition_, topLevel_, isInstanceMethod_) {
926
+ const signature_ = ff_compiler_Resolver.Resolver_resolveSignature(self_, definition_.signature_, topLevel_, isInstanceMethod_);
927
+ const self2_ = ff_compiler_Resolver.Resolver_withSignature(self_, signature_);
928
+ const body_ = ff_compiler_Syntax.Target_mapFirefly(definition_.body_, ((lambda_) => {
929
+ {
930
+ const _1 = lambda_;
931
+ {
932
+ const _c = _1;
933
+ return ff_compiler_Syntax.Lambda(_c.at_, signature_.effect_, ff_core_List.List_map(lambda_.cases_, ((_w1) => {
934
+ return ff_compiler_Resolver.Resolver_resolveCase(self2_, _w1, false)
935
+ })))
936
+ return
937
+ }
938
+ }
939
+ }));
940
+ return ff_compiler_Syntax.DFunction(definition_.at_, signature_, body_)
941
+ }
942
+
943
+ export function Resolver_resolveSignature(self_, signature_, topLevel_, isInstanceMethod_) {
944
+ if((ff_compiler_LspHook.LspHook_isAt(self_.lspHook_, signature_.at_) || ff_compiler_LspHook.LspHook_isDefinedAt(self_.lspHook_, signature_.at_))) {
945
+ ff_compiler_LspHook.LspHook_emit(self_.lspHook_, ff_compiler_LspHook.ResolveSignatureHook(signature_, isInstanceMethod_))
946
+ };
947
+ const newSignature_ = (topLevel_
948
+ ? (((_c) => {
949
+ return ff_compiler_Syntax.Signature(_c.at_, _c.name_, _c.member_, ff_core_List.Link("Q$", signature_.generics_), _c.constraints_, _c.parameters_, _c.returnType_, ff_compiler_Syntax.TConstructor(signature_.at_, "Q$", ff_core_List.Empty()))
950
+ }))(signature_)
951
+ : (((_c) => {
952
+ return ff_compiler_Syntax.Signature(_c.at_, _c.name_, _c.member_, _c.generics_, _c.constraints_, _c.parameters_, _c.returnType_, ff_compiler_Resolver.Resolver_freshUnificationVariable(self_, signature_.at_))
953
+ }))(signature_));
954
+ ff_core_Option.Option_each(ff_core_List.List_find(newSignature_.generics_, ((name_) => {
955
+ return ff_core_Set.Set_contains(self_.typeParameters_, name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String)
956
+ })), ((name_) => {
957
+ throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(signature_.at_, (("Type parameter " + name_) + " is already in scope")), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
958
+ }));
959
+ const self2_ = ff_compiler_Resolver.Resolver_withSignature(self_, newSignature_);
960
+ {
961
+ const _1 = newSignature_;
962
+ {
963
+ const _c = _1;
964
+ return ff_compiler_Syntax.Signature(_c.at_, _c.name_, _c.member_, _c.generics_, ff_core_List.List_map(newSignature_.constraints_, ((_w1) => {
965
+ return ff_compiler_Resolver.Resolver_resolveConstraint(self2_, _w1, topLevel_)
966
+ })), ff_core_List.List_map(newSignature_.parameters_, ((p_) => {
967
+ {
968
+ const _1 = p_;
969
+ {
970
+ const _c = _1;
971
+ return ff_compiler_Syntax.Parameter(_c.at_, _c.mutable_, _c.name_, ff_compiler_Resolver.Resolver_resolveType(self2_, p_.valueType_, topLevel_), ff_core_Option.Option_map(p_.default_, ((_w1) => {
972
+ return ff_compiler_Resolver.Resolver_resolveTerm(self2_, _w1, topLevel_)
973
+ })))
974
+ return
975
+ }
976
+ }
977
+ })), ff_compiler_Resolver.Resolver_resolveType(self2_, newSignature_.returnType_, topLevel_), _c.effect_)
978
+ return
979
+ }
980
+ }
981
+ }
982
+
983
+ export function Resolver_withSignature(self_, signature_) {
984
+ const variableMap_ = ff_core_List.List_toMap(ff_core_List.List_map(ff_core_List.List_map(signature_.parameters_, ((_w1) => {
985
+ return _w1.name_
986
+ })), ((name_) => {
987
+ return ff_core_Pair.Pair(name_, name_)
988
+ })), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
989
+ const variableLocationMap_ = ff_core_List.List_toMap(ff_core_List.List_map(signature_.parameters_, ((p_) => {
990
+ return ff_core_Pair.Pair(p_.name_, p_.at_)
991
+ })), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
992
+ const typeMap_ = ff_core_List.List_toMap(ff_core_List.List_map(signature_.generics_, ((name_) => {
993
+ return ff_core_Pair.Pair(name_, name_)
994
+ })), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
995
+ {
996
+ const _1 = self_;
997
+ {
998
+ const _c = _1;
999
+ return ff_compiler_Resolver.Resolver(ff_core_Map.Map_addAll(self_.variables_, variableMap_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Map.Map_addAll(self_.variableLocations_, variableLocationMap_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), _c.variants_, ff_core_Map.Map_addAll(self_.types_, typeMap_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), _c.typeGenerics_, _c.typeLocations_, ff_core_Set.Set_removeAll(self_.asyncTypes_, ff_core_List.List_toSet(signature_.generics_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Set.Set_addAll(self_.typeParameters_, ff_core_List.List_toSet(signature_.generics_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), _c.traits_, _c.traitLocations_, _c.state_, _c.lspHook_)
1000
+ return
1001
+ }
1002
+ }
1003
+ }
1004
+
1005
+ export function Resolver_resolveCase(self_, case_, topLevel_) {
1006
+ function findVariables_(pattern_) {
1007
+ {
1008
+ const pattern_a = pattern_;
1009
+ {
1010
+ if(pattern_a.PString) {
1011
+ return ff_core_Map.empty_()
1012
+ return
1013
+ }
1014
+ }
1015
+ {
1016
+ if(pattern_a.PInt) {
1017
+ return ff_core_Map.empty_()
1018
+ return
1019
+ }
1020
+ }
1021
+ {
1022
+ if(pattern_a.PChar) {
1023
+ return ff_core_Map.empty_()
1024
+ return
1025
+ }
1026
+ }
1027
+ {
1028
+ if(pattern_a.PVariable) {
1029
+ const at_ = pattern_a.at_;
1030
+ if(pattern_a.name_.Some) {
1031
+ const name_ = pattern_a.name_.value_;
1032
+ return ff_core_List.List_toMap(ff_core_List.Link(ff_core_Pair.Pair(name_, ff_core_Pair.Pair(at_, name_)), ff_core_List.Empty()), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String)
1033
+ return
1034
+ }
1035
+ }
1036
+ }
1037
+ {
1038
+ if(pattern_a.PVariable) {
1039
+ if(pattern_a.name_.None) {
1040
+ return ff_core_Map.empty_()
1041
+ return
1042
+ }
1043
+ }
1044
+ }
1045
+ {
1046
+ if(pattern_a.PVariant) {
1047
+ const patterns_ = pattern_a.patterns_;
1048
+ return ff_core_List.List_foldLeft(ff_core_List.List_map(patterns_, ((pattern_) => {
1049
+ return findVariables_(pattern_)
1050
+ })), ff_core_Map.empty_(), ((_w1, _w2) => {
1051
+ return ff_core_Map.Map_addAll(_w1, _w2, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String)
1052
+ }))
1053
+ return
1054
+ }
1055
+ }
1056
+ {
1057
+ if(pattern_a.PVariantAs) {
1058
+ const at_ = pattern_a.at_;
1059
+ const variableAt_ = pattern_a.variableAt_;
1060
+ const variable_ = pattern_a.variable_;
1061
+ return ff_core_List.List_toMap(ff_core_List.List_map(ff_core_Option.Option_toList(variable_), ((x_) => {
1062
+ return ff_core_Pair.Pair(x_, ff_core_Pair.Pair(variableAt_, x_))
1063
+ })), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String)
1064
+ return
1065
+ }
1066
+ }
1067
+ {
1068
+ if(pattern_a.PAlias) {
1069
+ const at_ = pattern_a.at_;
1070
+ const pattern_ = pattern_a.pattern_;
1071
+ const variable_ = pattern_a.variable_;
1072
+ return ff_core_Map.Map_addAll(ff_core_List.List_toMap(ff_core_List.Link(ff_core_Pair.Pair(variable_, ff_core_Pair.Pair(at_, variable_)), ff_core_List.Empty()), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), findVariables_(pattern_), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String)
1073
+ return
1074
+ }
1075
+ }
1076
+ }
1077
+ }
1078
+ const variableMap_ = ff_core_List.List_foldLeft(ff_core_List.List_map(case_.patterns_, ((pattern_) => {
1079
+ return findVariables_(pattern_)
1080
+ })), ff_core_Map.empty_(), ((_w1, _w2) => {
1081
+ return ff_core_Map.Map_addAll(_w1, _w2, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String)
1082
+ }));
1083
+ let guards_ = ff_core_List.Empty();
1084
+ const variableMap2_ = ff_core_List.List_foldLeft(case_.guards_, variableMap_, ((variableMap1_, g_) => {
1085
+ const self2_ = (((_c) => {
1086
+ return ff_compiler_Resolver.Resolver(ff_core_Map.Map_addAll(self_.variables_, ff_core_Map.Map_mapValues(variableMap1_, ((_, p_) => {
1087
+ return p_.second_
1088
+ }), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Map.Map_addAll(self_.variableLocations_, ff_core_Map.Map_mapValues(variableMap1_, ((_, p_) => {
1089
+ return p_.first_
1090
+ }), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), _c.variants_, _c.types_, _c.typeGenerics_, _c.typeLocations_, _c.asyncTypes_, _c.typeParameters_, _c.traits_, _c.traitLocations_, _c.state_, _c.lspHook_)
1091
+ }))(self_);
1092
+ const guard_ = (((_c) => {
1093
+ return ff_compiler_Syntax.MatchGuard(_c.at_, ff_compiler_Resolver.Resolver_resolveTerm(self2_, g_.term_, topLevel_), ff_compiler_Resolver.Resolver_resolvePattern(self2_, g_.pattern_))
1094
+ }))(g_);
1095
+ guards_ = ff_core_List.Link(guard_, guards_);
1096
+ return ff_core_Map.Map_addAll(variableMap1_, findVariables_(guard_.pattern_), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String)
1097
+ }));
1098
+ const self3_ = (((_c) => {
1099
+ return ff_compiler_Resolver.Resolver(ff_core_Map.Map_addAll(self_.variables_, ff_core_Map.Map_mapValues(variableMap2_, ((_, p_) => {
1100
+ return p_.second_
1101
+ }), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Map.Map_addAll(self_.variableLocations_, ff_core_Map.Map_mapValues(variableMap2_, ((_, p_) => {
1102
+ return p_.first_
1103
+ }), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), _c.variants_, _c.types_, _c.typeGenerics_, _c.typeLocations_, _c.asyncTypes_, _c.typeParameters_, _c.traits_, _c.traitLocations_, _c.state_, _c.lspHook_)
1104
+ }))(self_);
1105
+ return ff_compiler_Syntax.MatchCase(case_.at_, ff_core_List.List_map(case_.patterns_, ((_w1) => {
1106
+ return ff_compiler_Resolver.Resolver_resolvePattern(self_, _w1)
1107
+ })), ff_core_List.List_reverse(guards_), ff_compiler_Resolver.Resolver_resolveTerm(self3_, case_.body_, topLevel_))
1108
+ }
1109
+
1110
+ export function Resolver_resolvePattern(self_, pattern_) {
1111
+ {
1112
+ const self_a = self_;
1113
+ const pattern_a = pattern_;
1114
+ {
1115
+ if(pattern_a.PString) {
1116
+ return pattern_
1117
+ return
1118
+ }
1119
+ }
1120
+ {
1121
+ if(pattern_a.PInt) {
1122
+ return pattern_
1123
+ return
1124
+ }
1125
+ }
1126
+ {
1127
+ if(pattern_a.PChar) {
1128
+ return pattern_
1129
+ return
1130
+ }
1131
+ }
1132
+ {
1133
+ if(pattern_a.PVariable) {
1134
+ return pattern_
1135
+ return
1136
+ }
1137
+ }
1138
+ {
1139
+ if(pattern_a.PVariant) {
1140
+ const at_ = pattern_a.at_;
1141
+ const name_ = pattern_a.name_;
1142
+ const patterns_ = pattern_a.patterns_;
1143
+ const newName_ = ff_core_Option.Option_else(ff_core_Map.Map_get(self_.variants_, name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), (() => {
1144
+ return name_
1145
+ }));
1146
+ const newPatterns_ = ff_core_List.List_map(patterns_, ((_w1) => {
1147
+ return ff_compiler_Resolver.Resolver_resolvePattern(self_, _w1)
1148
+ }));
1149
+ return ff_compiler_Syntax.PVariant(at_, newName_, newPatterns_)
1150
+ return
1151
+ }
1152
+ }
1153
+ {
1154
+ if(pattern_a.PVariantAs) {
1155
+ const at_ = pattern_a.at_;
1156
+ const name_ = pattern_a.name_;
1157
+ const variableAt_ = pattern_a.variableAt_;
1158
+ const variable_ = pattern_a.variable_;
1159
+ const newName_ = ff_core_Option.Option_else(ff_core_Map.Map_get(self_.variants_, name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), (() => {
1160
+ return name_
1161
+ }));
1162
+ return ff_compiler_Syntax.PVariantAs(at_, newName_, variableAt_, variable_)
1163
+ return
1164
+ }
1165
+ }
1166
+ {
1167
+ if(pattern_a.PAlias) {
1168
+ const at_ = pattern_a.at_;
1169
+ const pattern_ = pattern_a.pattern_;
1170
+ const variable_ = pattern_a.variable_;
1171
+ const newPattern_ = ff_compiler_Resolver.Resolver_resolvePattern(self_, pattern_);
1172
+ return ff_compiler_Syntax.PAlias(at_, newPattern_, variable_)
1173
+ return
1174
+ }
1175
+ }
1176
+ }
1177
+ }
1178
+
1179
+ export function Resolver_containsAsyncType(self_, type_) {
1180
+ {
1181
+ const self_a = self_;
1182
+ const type_a = type_;
1183
+ {
1184
+ if(type_a.TVariable) {
1185
+ return false
1186
+ return
1187
+ }
1188
+ }
1189
+ {
1190
+ if(type_a.TConstructor) {
1191
+ const constructor_ = type_a;
1192
+ const name_ = (ff_core_String.String_contains(constructor_.name_, "$")
1193
+ ? constructor_.name_
1194
+ : ff_core_Option.Option_else(ff_core_Map.Map_get(self_.types_, constructor_.name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), (() => {
1195
+ if(ff_compiler_LspHook.LspHook_isEnabled(self_.lspHook_)) {
1196
+ return constructor_.name_
1197
+ } else {
1198
+ throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(constructor_.at_, ("No such type: " + constructor_.name_)), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
1199
+ }
1200
+ })));
1201
+ const isFunctionType_ = ff_core_String.String_startsWith(name_, "Function$", 0);
1202
+ return ((isFunctionType_ || ff_core_Set.Set_contains(self_.asyncTypes_, constructor_.name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String)) || ff_core_List.List_any(constructor_.generics_, ((_w1) => {
1203
+ return ff_compiler_Resolver.Resolver_containsAsyncType(self_, _w1)
1204
+ })))
1205
+ return
1206
+ }
1207
+ }
1208
+ }
1209
+ }
1210
+
1211
+ export async function Resolver_freshUnificationVariable$(self_, at_, $task) {
1212
+ const result_ = ff_compiler_Syntax.TVariable(at_, self_.state_.nextUnificationVariableIndex_);
1213
+ self_.state_.nextUnificationVariableIndex_ += 3;
1214
+ return result_
1215
+ }
1216
+
1217
+ export async function Resolver_resolveModule$(self_, module_, otherModules_, $task) {
1218
+ const moduleNamespace_ = ff_core_String.String_takeWhile(ff_core_String.String_reverse(ff_core_String.String_takeWhile(ff_core_String.String_reverse(ff_core_String.String_replace(module_.file_, "\\", "/")), ((_w1) => {
1219
+ return (_w1 !== 47)
1220
+ }))), ((_w1) => {
1221
+ return (_w1 !== 46)
1222
+ }));
1223
+ const self2_ = ff_compiler_Resolver.Resolver_processImports(self_, module_.imports_, otherModules_);
1224
+ const self3_ = ff_compiler_Resolver.Resolver_processDefinitions(self2_, module_, ff_core_Option.None());
1225
+ const module2_ = (((_c) => {
1226
+ return ff_compiler_Syntax.Module(_c.file_, _c.packagePair_, _c.imports_, ff_core_List.List_map(module_.types_, ((_w1) => {
1227
+ return ff_compiler_Resolver.Resolver_resolveTypeDefinition(self3_, _w1)
1228
+ })), ff_core_List.List_map(module_.traits_, ((_w1) => {
1229
+ return ff_compiler_Resolver.Resolver_resolveTraitDefinition(self3_, _w1)
1230
+ })), ff_core_List.List_map(module_.instances_, ((_w1) => {
1231
+ return ff_compiler_Resolver.Resolver_resolveInstanceDefinition(self3_, _w1)
1232
+ })), ff_core_List.List_map(module_.extends_, ((_w1) => {
1233
+ return ff_compiler_Resolver.Resolver_resolveExtendDefinition(self3_, _w1)
1234
+ })), ff_core_List.List_map(module_.lets_, ((_w1) => {
1235
+ return ff_compiler_Resolver.Resolver_resolveLetDefinition(self3_, _w1, true)
1236
+ })), ff_core_List.List_map(module_.functions_, ((_w1) => {
1237
+ return ff_compiler_Resolver.Resolver_resolveFunctionDefinition(self3_, _w1, true, false)
1238
+ })))
1239
+ }))(module_);
1240
+ ff_core_List.List_each(module2_.instances_, ((_w1) => {
1241
+ ff_core_List.List_each(_w1.typeArguments_, ((_w1) => {
1242
+ ff_compiler_Resolver.Resolver_checkInstanceType(self3_, _w1)
1243
+ }))
1244
+ }));
1245
+ return module2_
1246
+ }
1247
+
1248
+ export async function Resolver_checkInstanceType$(self_, type_, $task) {
1249
+ {
1250
+ const _1 = type_;
1251
+ {
1252
+ if(_1.TConstructor) {
1253
+ const name_ = _1.name_;
1254
+ const typeArguments_ = _1.generics_;
1255
+ if(ff_core_Set.Set_contains(self_.asyncTypes_, name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String)) {
1256
+ throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(type_.at_, "Traits must not be instantiated for capability types"), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
1257
+ };
1258
+ ff_core_List.List_each(typeArguments_, ((_w1) => {
1259
+ ff_compiler_Resolver.Resolver_checkInstanceType(self_, _w1)
1260
+ }))
1261
+ return
1262
+ }
1263
+ }
1264
+ {
1265
+
1266
+ return
1267
+ }
1268
+ }
1269
+ }
1270
+
1271
+ export async function Resolver_processImports$(self_, imports_, modules_, $task) {
1272
+ let resolver_ = self_;
1273
+ ff_core_List.List_each(imports_, ((import_) => {
1274
+ {
1275
+ const _1 = ff_core_List.List_find(modules_, ((_w1) => {
1276
+ return (ff_core_String.String_dropLast(_w1.file_, 3) === import_.file_)
1277
+ }));
1278
+ {
1279
+ if(_1.Some) {
1280
+ const module_ = _1.value_;
1281
+ resolver_ = ff_compiler_Resolver.Resolver_processDefinitions(resolver_, module_, ff_core_Option.Some(import_.alias_))
1282
+ return
1283
+ }
1284
+ }
1285
+ {
1286
+ if(_1.None) {
1287
+ throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(import_.at_, ("No such module: " + import_.file_)), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
1288
+ return
1289
+ }
1290
+ }
1291
+ }
1292
+ }));
1293
+ return resolver_
1294
+ }
1295
+
1296
+ export async function Resolver_processDefinitions$(self_, module_, importAlias_, $task) {
1297
+ function entry_(name_, unqualified_) {
1298
+ const full_ = ((((ff_compiler_Syntax.PackagePair_groupName(module_.packagePair_, ":") + "/") + ff_core_String.String_dropLast(module_.file_, 3)) + ".") + name_);
1299
+ {
1300
+ const _1 = importAlias_;
1301
+ {
1302
+ if(_1.None) {
1303
+ return ff_core_List.Link(ff_core_Pair.Pair(name_, full_), ff_core_List.Link(ff_core_Pair.Pair(full_, full_), ff_core_List.Empty()))
1304
+ return
1305
+ }
1306
+ }
1307
+ {
1308
+ if(_1.Some) {
1309
+ const alias_ = _1.value_;
1310
+ const _guard1 = unqualified_;
1311
+ if(_guard1) {
1312
+ return ff_core_List.Link(ff_core_Pair.Pair(((alias_ + ".") + name_), full_), ff_core_List.Link(ff_core_Pair.Pair(name_, full_), ff_core_List.Link(ff_core_Pair.Pair(full_, full_), ff_core_List.Empty())))
1313
+ return
1314
+ }
1315
+ }
1316
+ }
1317
+ {
1318
+ if(_1.Some) {
1319
+ const alias_ = _1.value_;
1320
+ return ff_core_List.Link(ff_core_Pair.Pair(((alias_ + ".") + name_), full_), ff_core_List.Link(ff_core_Pair.Pair(full_, full_), ff_core_List.Empty()))
1321
+ return
1322
+ }
1323
+ }
1324
+ }
1325
+ }
1326
+ const isCore_ = (((module_.packagePair_.group_ === "ff") && (module_.packagePair_.name_ === "core")) && (module_.file_ === "Core.ff"));
1327
+ const lets_ = ff_core_List.List_toMap(ff_core_List.List_flatMap(module_.lets_, ((_w1) => {
1328
+ return entry_(_w1.name_, isCore_)
1329
+ })), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
1330
+ const letLocations_ = ff_core_List.List_toMap(ff_core_List.List_flatMap(module_.lets_, ((d_) => {
1331
+ return ff_core_List.List_map(entry_(d_.name_, true), ((_w1) => {
1332
+ return ff_core_Pair.Pair_mapSecond(_w1, ((_) => {
1333
+ return d_.at_
1334
+ }))
1335
+ }))
1336
+ })), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
1337
+ const functions_ = ff_core_List.List_toMap(ff_core_List.List_flatMap(module_.functions_, ((_w1) => {
1338
+ return entry_(_w1.signature_.name_, isCore_)
1339
+ })), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
1340
+ const functionLocations_ = ff_core_List.List_toMap(ff_core_List.List_flatMap(module_.functions_, ((d_) => {
1341
+ return ff_core_List.List_map(entry_(d_.signature_.name_, true), ((_w1) => {
1342
+ return ff_core_Pair.Pair_mapSecond(_w1, ((_) => {
1343
+ return d_.at_
1344
+ }))
1345
+ }))
1346
+ })), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
1347
+ const traitMethods_ = ff_core_List.List_toMap(ff_core_List.List_flatMap(ff_core_List.List_flatMap(module_.traits_, ((_w1) => {
1348
+ return _w1.methods_
1349
+ })), ((_w1) => {
1350
+ return entry_(_w1.name_, false)
1351
+ })), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
1352
+ const traitMethodLocations_ = ff_core_List.List_toMap(ff_core_List.List_flatMap(ff_core_List.List_flatMap(module_.traits_, ((_w1) => {
1353
+ return _w1.methods_
1354
+ })), ((d_) => {
1355
+ return ff_core_List.List_map(entry_(d_.name_, true), ((_w1) => {
1356
+ return ff_core_Pair.Pair_mapSecond(_w1, ((_) => {
1357
+ return d_.at_
1358
+ }))
1359
+ }))
1360
+ })), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
1361
+ const traits_ = ff_core_List.List_toMap(ff_core_List.List_flatMap(module_.traits_, ((_w1) => {
1362
+ return entry_(_w1.name_, true)
1363
+ })), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
1364
+ const traitLocations_ = ff_core_List.List_toMap(ff_core_List.List_flatMap(module_.traits_, ((d_) => {
1365
+ return ff_core_List.List_map(entry_(d_.name_, true), ((_w1) => {
1366
+ return ff_core_Pair.Pair_mapSecond(_w1, ((_) => {
1367
+ return d_.at_
1368
+ }))
1369
+ }))
1370
+ })), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
1371
+ const types_ = ff_core_List.List_toMap(ff_core_List.List_flatMap(module_.types_, ((_w1) => {
1372
+ return entry_(_w1.name_, true)
1373
+ })), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
1374
+ const typeGenerics_ = ff_core_List.List_toMap(ff_core_List.List_flatMap(module_.types_, ((d_) => {
1375
+ return ff_core_List.List_map(entry_(d_.name_, true), ((p_) => {
1376
+ return ff_core_Pair.Pair(p_.first_, d_.generics_)
1377
+ }))
1378
+ })), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
1379
+ const typeLocations_ = ff_core_List.List_toMap(ff_core_List.List_flatMap(module_.types_, ((d_) => {
1380
+ return ff_core_List.List_map(entry_(d_.name_, true), ((_w1) => {
1381
+ return ff_core_Pair.Pair_mapSecond(_w1, ((_) => {
1382
+ return d_.at_
1383
+ }))
1384
+ }))
1385
+ })), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
1386
+ const asyncTypes_ = ff_core_List.List_toSet(ff_core_List.List_flatMap(ff_core_List.List_filter(module_.types_, ((_w1) => {
1387
+ return ff_core_Option.Option_any(ff_core_List.List_first(_w1.generics_), ((_w1) => {
1388
+ return (_w1 === "Q$")
1389
+ }))
1390
+ })), ((_w1) => {
1391
+ return ff_core_List.List_map(entry_(_w1.name_, true), ((_w1) => {
1392
+ return _w1.first_
1393
+ }))
1394
+ })), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
1395
+ const variants_ = ff_core_List.List_toMap(ff_core_List.List_flatMap(ff_core_List.List_flatMap(module_.types_, ((_w1) => {
1396
+ return _w1.variants_
1397
+ })), ((_w1) => {
1398
+ return entry_(_w1.name_, true)
1399
+ })), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
1400
+ {
1401
+ const _1 = self_;
1402
+ {
1403
+ const _c = _1;
1404
+ return ff_compiler_Resolver.Resolver(ff_core_Map.Map_addAll(ff_core_Map.Map_addAll(ff_core_Map.Map_addAll(self_.variables_, lets_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), functions_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), traitMethods_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Map.Map_addAll(ff_core_Map.Map_addAll(ff_core_Map.Map_addAll(self_.variableLocations_, letLocations_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), functionLocations_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), traitMethodLocations_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Map.Map_addAll(self_.variants_, variants_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Map.Map_addAll(self_.types_, types_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Map.Map_addAll(self_.typeGenerics_, typeGenerics_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Map.Map_addAll(self_.typeLocations_, typeLocations_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Set.Set_addAll(self_.asyncTypes_, asyncTypes_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_List.List_toSet(ff_core_List.Empty(), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Map.Map_addAll(self_.traits_, traits_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Map.Map_addAll(self_.traitLocations_, traitLocations_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), self_.state_, _c.lspHook_)
1405
+ return
1406
+ }
1407
+ }
1408
+ }
1409
+
1410
+ export async function Resolver_resolveTypeDefinition$(self_, definition_, $task) {
1411
+ if(ff_compiler_LspHook.LspHook_isAt(self_.lspHook_, definition_.at_)) {
1412
+ ff_compiler_LspHook.LspHook_emit(self_.lspHook_, ff_compiler_LspHook.ResolveSymbolHook(ff_compiler_LspHook.SymbolHook(definition_.name_, definition_.at_, definition_.at_), ff_core_Option.None()))
1413
+ };
1414
+ const generics_ = ff_core_List.List_toMap(ff_core_List.List_map(definition_.generics_, ((g_) => {
1415
+ return ff_core_Pair.Pair(g_, g_)
1416
+ })), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
1417
+ const self2_ = (((_c) => {
1418
+ return ff_compiler_Resolver.Resolver(_c.variables_, _c.variableLocations_, _c.variants_, ff_core_Map.Map_addAll(self_.types_, generics_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), _c.typeGenerics_, _c.typeLocations_, ff_core_Set.Set_removeAll(self_.asyncTypes_, ff_core_List.List_toSet(definition_.generics_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Set.Set_addAll(self_.typeParameters_, ff_core_List.List_toSet(definition_.generics_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), _c.traits_, _c.traitLocations_, _c.state_, _c.lspHook_)
1419
+ }))(self_);
1420
+ if((!ff_core_Option.Option_any(ff_core_List.List_first(definition_.generics_), ((_w1) => {
1421
+ return (_w1 === "Q$")
1422
+ })))) {
1423
+ ff_core_List.List_each(ff_core_List.List_addAll(definition_.commonFields_, ff_core_List.List_flatMap(definition_.variants_, ((_w1) => {
1424
+ return _w1.fields_
1425
+ }))), ((f_) => {
1426
+ if(ff_compiler_Resolver.Resolver_containsAsyncType(self2_, f_.valueType_)) {
1427
+ throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(f_.at_, "Only capabilities can contain fields of concrete capability types"), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
1428
+ }
1429
+ }))
1430
+ };
1431
+ {
1432
+ const _1 = definition_;
1433
+ {
1434
+ const _c = _1;
1435
+ return ff_compiler_Syntax.DType(_c.at_, _c.newtype_, _c.data_, _c.name_, _c.generics_, ff_core_List.List_map(definition_.constraints_, ((_w1) => {
1436
+ return ff_compiler_Resolver.Resolver_resolveConstraint(self2_, _w1, true)
1437
+ })), ff_core_List.List_map(definition_.commonFields_, ((f_) => {
1438
+ const valueType_ = ff_compiler_Resolver.Resolver_resolveType(self2_, f_.valueType_, true);
1439
+ if((ff_compiler_LspHook.LspHook_isAt(self_.lspHook_, f_.at_) || ff_compiler_LspHook.LspHook_isDefinedAt(self_.lspHook_, f_.at_))) {
1440
+ ff_compiler_LspHook.LspHook_emit(self_.lspHook_, ff_compiler_LspHook.ResolveVariantFieldHook(ff_compiler_LspHook.SymbolHook(f_.name_, f_.at_, f_.at_), valueType_, true))
1441
+ };
1442
+ {
1443
+ const _1 = f_;
1444
+ {
1445
+ const _c = _1;
1446
+ return ff_compiler_Syntax.Parameter(_c.at_, _c.mutable_, _c.name_, valueType_, ff_core_Option.Option_map(f_.default_, ((_w1) => {
1447
+ return ff_compiler_Resolver.Resolver_resolveTerm(self2_, _w1, true)
1448
+ })))
1449
+ return
1450
+ }
1451
+ }
1452
+ })), ff_core_List.List_map(definition_.variants_, ((v_) => {
1453
+ if(ff_compiler_LspHook.LspHook_isAt(self_.lspHook_, v_.at_)) {
1454
+ ff_compiler_LspHook.LspHook_emit(self_.lspHook_, ff_compiler_LspHook.ResolveSymbolHook(ff_compiler_LspHook.SymbolHook(v_.name_, v_.at_, v_.at_), ff_core_Option.None()))
1455
+ };
1456
+ {
1457
+ const _1 = v_;
1458
+ {
1459
+ const _c = _1;
1460
+ return ff_compiler_Syntax.Variant(_c.at_, _c.name_, ff_core_List.List_map(v_.fields_, ((f_) => {
1461
+ const valueType_ = ff_compiler_Resolver.Resolver_resolveType(self2_, f_.valueType_, true);
1462
+ if((ff_compiler_LspHook.LspHook_isAt(self_.lspHook_, f_.at_) || ff_compiler_LspHook.LspHook_isDefinedAt(self_.lspHook_, f_.at_))) {
1463
+ ff_compiler_LspHook.LspHook_emit(self_.lspHook_, ff_compiler_LspHook.ResolveVariantFieldHook(ff_compiler_LspHook.SymbolHook(f_.name_, f_.at_, f_.at_), valueType_, false))
1464
+ };
1465
+ {
1466
+ const _1 = f_;
1467
+ {
1468
+ const _c = _1;
1469
+ return ff_compiler_Syntax.Parameter(_c.at_, _c.mutable_, _c.name_, valueType_, ff_core_Option.Option_map(f_.default_, ((_w1) => {
1470
+ return ff_compiler_Resolver.Resolver_resolveTerm(self2_, _w1, true)
1471
+ })))
1472
+ return
1473
+ }
1474
+ }
1475
+ })))
1476
+ return
1477
+ }
1478
+ }
1479
+ })))
1480
+ return
1481
+ }
1482
+ }
1483
+ }
1484
+
1485
+ export async function Resolver_resolveTraitDefinition$(self_, definition_, $task) {
1486
+ if((ff_compiler_LspHook.LspHook_isAt(self_.lspHook_, definition_.at_) || ff_compiler_LspHook.LspHook_isDefinedAt(self_.lspHook_, definition_.at_))) {
1487
+ ff_compiler_LspHook.LspHook_emit(self_.lspHook_, ff_compiler_LspHook.ResolveSymbolHook(ff_compiler_LspHook.SymbolHook(definition_.name_, definition_.at_, definition_.at_), ff_core_Option.None()))
1488
+ };
1489
+ const generics_ = ff_core_List.List_toMap(ff_core_List.List_map(definition_.generics_, ((g_) => {
1490
+ return ff_core_Pair.Pair(g_, g_)
1491
+ })), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
1492
+ const self2_ = (((_c) => {
1493
+ return ff_compiler_Resolver.Resolver(_c.variables_, _c.variableLocations_, _c.variants_, ff_core_Map.Map_addAll(self_.types_, generics_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), _c.typeGenerics_, _c.typeLocations_, ff_core_Set.Set_removeAll(self_.asyncTypes_, ff_core_List.List_toSet(definition_.generics_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Set.Set_addAll(self_.typeParameters_, ff_core_List.List_toSet(definition_.generics_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), _c.traits_, _c.traitLocations_, _c.state_, _c.lspHook_)
1494
+ }))(self_);
1495
+ {
1496
+ const _1 = definition_;
1497
+ {
1498
+ const _c = _1;
1499
+ return ff_compiler_Syntax.DTrait(_c.at_, _c.name_, _c.generics_, ff_core_List.List_map(definition_.constraints_, ((_w1) => {
1500
+ return ff_compiler_Resolver.Resolver_resolveConstraint(self2_, _w1, true)
1501
+ })), _c.generatorParameters_, ff_core_List.List_map(definition_.methods_, ((_w1) => {
1502
+ return ff_compiler_Resolver.Resolver_resolveSignature(self2_, _w1, true, false)
1503
+ })), ff_core_List.List_map(definition_.methodDefaults_, ((_1) => {
1504
+ {
1505
+ const name_ = _1.first_;
1506
+ const lambda_ = _1.second_;
1507
+ const signature_ = ff_core_Option.Option_grab(ff_core_List.List_find(definition_.methods_, ((_w1) => {
1508
+ return (_w1.name_ === name_)
1509
+ })));
1510
+ const function1_ = ff_compiler_Syntax.DFunction(signature_.at_, signature_, ff_compiler_Syntax.FireflyTarget(lambda_));
1511
+ const function2_ = ff_compiler_Resolver.Resolver_resolveFunctionDefinition(self2_, function1_, true, false);
1512
+ return ff_core_Pair.Pair(name_, (((_1) => {
1513
+ {
1514
+ if(_1.FireflyTarget) {
1515
+ const lambda_ = _1.lambda_;
1516
+ return lambda_
1517
+ return
1518
+ }
1519
+ }
1520
+ {
1521
+ throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(signature_.at_, "Internal error: Expected method default to be a lambda"), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
1522
+ return
1523
+ }
1524
+ }))(function2_.body_))
1525
+ return
1526
+ }
1527
+ })), _c.methodGenerators_)
1528
+ return
1529
+ }
1530
+ }
1531
+ }
1532
+
1533
+ export async function Resolver_resolveInstanceDefinition$(self_, definition_, $task) {
1534
+ const traitDefinedAt_ = ff_core_Option.Option_else(ff_core_Map.Map_get(self_.traitLocations_, definition_.traitName_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), (() => {
1535
+ return definition_.at_
1536
+ }));
1537
+ if((ff_compiler_LspHook.LspHook_isAt(self_.lspHook_, definition_.at_) || ff_compiler_LspHook.LspHook_isDefinedAt(self_.lspHook_, traitDefinedAt_))) {
1538
+ ff_compiler_LspHook.LspHook_emit(self_.lspHook_, ff_compiler_LspHook.ResolveSymbolHook(ff_compiler_LspHook.SymbolHook(definition_.traitName_, definition_.at_, traitDefinedAt_), ff_core_Option.None()))
1539
+ };
1540
+ const generics_ = ff_core_List.List_toMap(ff_core_List.List_map(definition_.generics_, ((g_) => {
1541
+ return ff_core_Pair.Pair(g_, g_)
1542
+ })), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
1543
+ const self2_ = (((_c) => {
1544
+ return ff_compiler_Resolver.Resolver(_c.variables_, _c.variableLocations_, _c.variants_, ff_core_Map.Map_addAll(self_.types_, generics_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), _c.typeGenerics_, _c.typeLocations_, ff_core_Set.Set_removeAll(self_.asyncTypes_, ff_core_List.List_toSet(definition_.generics_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Set.Set_addAll(self_.typeParameters_, ff_core_List.List_toSet(definition_.generics_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), _c.traits_, _c.traitLocations_, _c.state_, _c.lspHook_)
1545
+ }))(self_);
1546
+ const traitName_ = ff_core_Option.Option_else(ff_core_Map.Map_get(self2_.traits_, definition_.traitName_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), (() => {
1547
+ throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(definition_.at_, ("No such trait: " + definition_.traitName_)), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
1548
+ }));
1549
+ {
1550
+ const _1 = definition_;
1551
+ {
1552
+ const _c = _1;
1553
+ return ff_compiler_Syntax.DInstance(_c.at_, _c.generics_, ff_core_List.List_map(definition_.constraints_, ((_w1) => {
1554
+ return ff_compiler_Resolver.Resolver_resolveConstraint(self2_, _w1, true)
1555
+ })), traitName_, ff_core_List.List_map(definition_.typeArguments_, ((_w1) => {
1556
+ return ff_compiler_Resolver.Resolver_resolveType(self2_, _w1, true)
1557
+ })), _c.generatorArguments_, ff_core_List.List_map(definition_.methods_, ((_w1) => {
1558
+ return ff_compiler_Resolver.Resolver_resolveFunctionDefinition(self2_, _w1, true, true)
1559
+ })), _c.derived_)
1560
+ return
1561
+ }
1562
+ }
1563
+ }
1564
+
1565
+ export async function Resolver_resolveExtendDefinition$(self_, definition_, $task) {
1566
+ const generics_ = ff_core_List.List_toMap(ff_core_List.List_map(definition_.generics_, ((g_) => {
1567
+ return ff_core_Pair.Pair(g_, g_)
1568
+ })), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
1569
+ const selfWithNoQ_ = (((_c) => {
1570
+ return ff_compiler_Resolver.Resolver(ff_core_Map.Map_add(self_.variables_, definition_.name_, definition_.name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Map.Map_add(self_.variableLocations_, definition_.name_, definition_.at_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), _c.variants_, ff_core_Map.Map_addAll(self_.types_, generics_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), _c.typeGenerics_, _c.typeLocations_, ff_core_Set.Set_removeAll(self_.asyncTypes_, ff_core_List.List_toSet(definition_.generics_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Set.Set_addAll(self_.typeParameters_, ff_core_List.List_toSet(definition_.generics_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), _c.traits_, _c.traitLocations_, _c.state_, _c.lspHook_)
1571
+ }))(self_);
1572
+ const selfWithQ_ = (((_c) => {
1573
+ return ff_compiler_Resolver.Resolver(_c.variables_, _c.variableLocations_, _c.variants_, ff_core_Map.Map_add(selfWithNoQ_.types_, "Q$", "Q$", ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), _c.typeGenerics_, _c.typeLocations_, _c.asyncTypes_, ff_core_Set.Set_add(selfWithNoQ_.typeParameters_, "Q$", ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), _c.traits_, _c.traitLocations_, _c.state_, _c.lspHook_)
1574
+ }))(selfWithNoQ_);
1575
+ {
1576
+ const _1 = definition_;
1577
+ {
1578
+ const _c = _1;
1579
+ return ff_compiler_Syntax.DExtend(_c.at_, _c.name_, _c.generics_, ff_core_List.List_map(definition_.constraints_, ((_w1) => {
1580
+ return ff_compiler_Resolver.Resolver_resolveConstraint(selfWithQ_, _w1, true)
1581
+ })), ff_compiler_Resolver.Resolver_resolveType(selfWithQ_, definition_.type_, true), ff_core_List.List_map(definition_.methods_, ((_w1) => {
1582
+ return ff_compiler_Resolver.Resolver_resolveFunctionDefinition(selfWithNoQ_, _w1, true, false)
1583
+ })))
1584
+ return
1585
+ }
1586
+ }
1587
+ }
1588
+
1589
+ export async function Resolver_resolveLetDefinition$(self_, definition_, topLevel_, $task) {
1590
+ if((ff_compiler_LspHook.LspHook_isAt(self_.lspHook_, definition_.at_) || ff_compiler_LspHook.LspHook_isDefinedAt(self_.lspHook_, definition_.at_))) {
1591
+ ff_compiler_LspHook.LspHook_emit(self_.lspHook_, ff_compiler_LspHook.ResolveSymbolHook(ff_compiler_LspHook.SymbolHook(definition_.name_, definition_.at_, definition_.at_), ff_core_Option.None()))
1592
+ };
1593
+ {
1594
+ const _1 = definition_;
1595
+ {
1596
+ const _c = _1;
1597
+ return ff_compiler_Syntax.DLet(_c.at_, _c.name_, ff_compiler_Resolver.Resolver_resolveType(self_, definition_.variableType_, topLevel_), ff_compiler_Resolver.Resolver_resolveTerm(self_, definition_.value_, true))
1598
+ return
1599
+ }
1600
+ }
1601
+ }
1602
+
1603
+ export async function Resolver_resolveTerm$(self_, term_, topLevel_, $task) {
1604
+ {
1605
+ const self_a = self_;
1606
+ const term_a = term_;
1607
+ const topLevel_a = topLevel_;
1608
+ {
1609
+ if(term_a.EString) {
1610
+ return term_
1611
+ return
1612
+ }
1613
+ }
1614
+ {
1615
+ if(term_a.EChar) {
1616
+ return term_
1617
+ return
1618
+ }
1619
+ }
1620
+ {
1621
+ if(term_a.EInt) {
1622
+ return term_
1623
+ return
1624
+ }
1625
+ }
1626
+ {
1627
+ if(term_a.EFloat) {
1628
+ return term_
1629
+ return
1630
+ }
1631
+ }
1632
+ {
1633
+ if(term_a.EVariable) {
1634
+ const e_ = term_a;
1635
+ if(ff_compiler_LspHook.LspHook_isEnabled(self_.lspHook_)) {
1636
+ const at_ = ff_core_Option.Option_else(ff_core_Map.Map_get(self_.variableLocations_, e_.name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), (() => {
1637
+ return e_.at_
1638
+ }));
1639
+ if((ff_compiler_LspHook.LspHook_isAt(self_.lspHook_, e_.at_) || ff_compiler_LspHook.LspHook_isDefinedAt(self_.lspHook_, at_))) {
1640
+ ff_compiler_LspHook.LspHook_emit(self_.lspHook_, ff_compiler_LspHook.ResolveSymbolHook(ff_compiler_LspHook.SymbolHook(e_.name_, e_.at_, at_), ff_core_Option.None()))
1641
+ }
1642
+ };
1643
+ return ff_core_Option.Option_else(ff_core_Option.Option_map(ff_core_Map.Map_get(self_.variables_, e_.name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ((_w1) => {
1644
+ {
1645
+ const _1 = e_;
1646
+ {
1647
+ const _c = _1;
1648
+ return ff_compiler_Syntax.EVariable(_c.at_, _w1)
1649
+ return
1650
+ }
1651
+ }
1652
+ })), (() => {
1653
+ return term_
1654
+ }))
1655
+ return
1656
+ }
1657
+ }
1658
+ {
1659
+ if(term_a.EList) {
1660
+ const at_ = term_a.at_;
1661
+ const t_ = term_a.elementType_;
1662
+ const items_ = term_a.items_;
1663
+ return ff_compiler_Syntax.EList(at_, ff_compiler_Resolver.Resolver_resolveType(self_, t_, topLevel_), ff_core_List.List_map(items_, ((_1) => {
1664
+ {
1665
+ const item_ = _1.first_;
1666
+ const spread_ = _1.second_;
1667
+ return ff_core_Pair.Pair(ff_compiler_Resolver.Resolver_resolveTerm(self_, item_, topLevel_), spread_)
1668
+ return
1669
+ }
1670
+ })))
1671
+ return
1672
+ }
1673
+ }
1674
+ {
1675
+ if(term_a.EVariant) {
1676
+ const at_ = term_a.at_;
1677
+ const name_ = term_a.name_;
1678
+ const typeArguments_ = term_a.typeArguments_;
1679
+ const arguments_ = term_a.arguments_;
1680
+ return ff_compiler_Syntax.EVariant(at_, ff_core_Option.Option_else(ff_core_Map.Map_get(self_.variants_, name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), (() => {
1681
+ return name_
1682
+ })), ff_core_List.List_map(typeArguments_, ((_w1) => {
1683
+ return ff_compiler_Resolver.Resolver_resolveType(self_, _w1, topLevel_)
1684
+ })), ff_core_Option.Option_map(arguments_, ((_w1) => {
1685
+ return ff_core_List.List_map(_w1, ((a_) => {
1686
+ {
1687
+ const _1 = a_;
1688
+ {
1689
+ const _c = _1;
1690
+ return ff_compiler_Syntax.Argument(_c.at_, _c.name_, ff_compiler_Resolver.Resolver_resolveTerm(self_, a_.value_, topLevel_))
1691
+ return
1692
+ }
1693
+ }
1694
+ }))
1695
+ })))
1696
+ return
1697
+ }
1698
+ }
1699
+ {
1700
+ if(term_a.EVariantIs) {
1701
+ const at_ = term_a.at_;
1702
+ const name_ = term_a.name_;
1703
+ const typeArguments_ = term_a.typeArguments_;
1704
+ return ff_compiler_Syntax.EVariantIs(at_, ff_core_Option.Option_else(ff_core_Map.Map_get(self_.variants_, name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), (() => {
1705
+ throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(at_, ("No such variant: " + name_)), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
1706
+ })), ff_core_List.List_map(typeArguments_, ((_w1) => {
1707
+ return ff_compiler_Resolver.Resolver_resolveType(self_, _w1, topLevel_)
1708
+ })))
1709
+ return
1710
+ }
1711
+ }
1712
+ {
1713
+ if(term_a.ECopy) {
1714
+ const at_ = term_a.at_;
1715
+ const name_ = term_a.name_;
1716
+ const record_ = term_a.record_;
1717
+ const arguments_ = term_a.arguments_;
1718
+ return ff_compiler_Syntax.ECopy(at_, ff_core_Option.Option_else(ff_core_Map.Map_get(self_.variants_, name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), (() => {
1719
+ return name_
1720
+ })), ff_compiler_Resolver.Resolver_resolveTerm(self_, record_, topLevel_), ff_core_List.List_map(arguments_, ((f_) => {
1721
+ {
1722
+ const _1 = f_;
1723
+ {
1724
+ const _c = _1;
1725
+ return ff_compiler_Syntax.Field(_c.at_, _c.name_, ff_compiler_Resolver.Resolver_resolveTerm(self_, f_.value_, topLevel_))
1726
+ return
1727
+ }
1728
+ }
1729
+ })))
1730
+ return
1731
+ }
1732
+ }
1733
+ {
1734
+ if(term_a.EField) {
1735
+ const e_ = term_a;
1736
+ {
1737
+ const _1 = e_;
1738
+ {
1739
+ const _c = _1;
1740
+ return ff_compiler_Syntax.EField(_c.at_, _c.newtype_, ff_compiler_Resolver.Resolver_resolveTerm(self_, e_.record_, topLevel_), _c.field_)
1741
+ return
1742
+ }
1743
+ }
1744
+ return
1745
+ }
1746
+ }
1747
+ {
1748
+ if(term_a.ELambda) {
1749
+ const at_ = term_a.at_;
1750
+ const lambdaAt_ = term_a.lambda_.at_;
1751
+ const cases_ = term_a.lambda_.cases_;
1752
+ const effect_ = ff_compiler_Resolver.Resolver_makeEffectArgument(self_, lambdaAt_, topLevel_);
1753
+ return ff_compiler_Syntax.ELambda(at_, ff_compiler_Syntax.Lambda(lambdaAt_, effect_, ff_core_List.List_map(cases_, ((_w1) => {
1754
+ return ff_compiler_Resolver.Resolver_resolveCase(self_, _w1, topLevel_)
1755
+ }))))
1756
+ return
1757
+ }
1758
+ }
1759
+ {
1760
+ if(term_a.EPipe) {
1761
+ const at_ = term_a.at_;
1762
+ const value_ = term_a.value_;
1763
+ const effect_ = term_a.effect_;
1764
+ const function_ = term_a.function_;
1765
+ return ff_compiler_Syntax.EPipe(at_, ff_compiler_Resolver.Resolver_resolveTerm(self_, value_, topLevel_), ff_compiler_Resolver.Resolver_resolveType(self_, effect_, topLevel_), ff_compiler_Resolver.Resolver_resolveTerm(self_, function_, topLevel_))
1766
+ return
1767
+ }
1768
+ }
1769
+ {
1770
+ if(term_a.ECall) {
1771
+ const at_ = term_a.at_;
1772
+ if(term_a.target_.DynamicCall) {
1773
+ const target_ = term_a.target_;
1774
+ const effect_ = term_a.effect_;
1775
+ const typeArguments_ = term_a.typeArguments_;
1776
+ const arguments_ = term_a.arguments_;
1777
+ const dictionaries_ = term_a.dictionaries_;
1778
+ return ff_compiler_Syntax.ECall(at_, (((_c) => {
1779
+ return ff_compiler_Syntax.DynamicCall(ff_compiler_Resolver.Resolver_resolveTerm(self_, target_.function_, topLevel_), _c.tailCall_)
1780
+ }))(target_), ff_compiler_Resolver.Resolver_resolveType(self_, effect_, topLevel_), ff_core_List.List_map(typeArguments_, ((_w1) => {
1781
+ return ff_compiler_Resolver.Resolver_resolveType(self_, _w1, topLevel_)
1782
+ })), ff_core_List.List_map(arguments_, ((a_) => {
1783
+ {
1784
+ const _1 = a_;
1785
+ {
1786
+ const _c = _1;
1787
+ return ff_compiler_Syntax.Argument(_c.at_, _c.name_, ff_compiler_Resolver.Resolver_resolveTerm(self_, a_.value_, topLevel_))
1788
+ return
1789
+ }
1790
+ }
1791
+ })), dictionaries_)
1792
+ return
1793
+ }
1794
+ }
1795
+ }
1796
+ {
1797
+ if(term_a.ECall) {
1798
+ const at_ = term_a.at_;
1799
+ if(term_a.target_.StaticCall) {
1800
+ throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(at_, "Internal error: Static calls not expected in the Resolver phase"), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
1801
+ return
1802
+ }
1803
+ }
1804
+ }
1805
+ {
1806
+ if(term_a.ERecord) {
1807
+ const at_ = term_a.at_;
1808
+ const fields_ = term_a.fields_;
1809
+ return ff_compiler_Syntax.ERecord(at_, ff_core_List.List_map(fields_, ((f_) => {
1810
+ {
1811
+ const _1 = f_;
1812
+ {
1813
+ const _c = _1;
1814
+ return ff_compiler_Syntax.Field(_c.at_, _c.name_, ff_compiler_Resolver.Resolver_resolveTerm(self_, f_.value_, topLevel_))
1815
+ return
1816
+ }
1817
+ }
1818
+ })))
1819
+ return
1820
+ }
1821
+ }
1822
+ {
1823
+ if(term_a.EWildcard) {
1824
+ const e_ = term_a;
1825
+ if((e_.index_ === 0)) {
1826
+ throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(e_.at_, "Unbound wildcard"), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
1827
+ };
1828
+ {
1829
+ const _1 = e_;
1830
+ {
1831
+ const _c = _1;
1832
+ return ff_compiler_Syntax.EWildcard(_c.at_, _c.index_)
1833
+ return
1834
+ }
1835
+ }
1836
+ return
1837
+ }
1838
+ }
1839
+ {
1840
+ if(term_a.EFunctions) {
1841
+ const at_ = term_a.at_;
1842
+ const functions_ = term_a.functions_;
1843
+ const body_ = term_a.body_;
1844
+ const functionMap_ = ff_core_List.List_toMap(ff_core_List.List_map(ff_core_List.List_map(functions_, ((_w1) => {
1845
+ return _w1.signature_.name_
1846
+ })), ((name_) => {
1847
+ return ff_core_Pair.Pair(name_, name_)
1848
+ })), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
1849
+ const locationMap_ = ff_core_List.List_toMap(ff_core_List.List_map(ff_core_List.List_map(functions_, ((_w1) => {
1850
+ return _w1.signature_
1851
+ })), ((s_) => {
1852
+ return ff_core_Pair.Pair(s_.name_, s_.at_)
1853
+ })), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
1854
+ const self2_ = (((_c) => {
1855
+ return ff_compiler_Resolver.Resolver(ff_core_Map.Map_addAll(self_.variables_, functionMap_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Map.Map_addAll(self_.variableLocations_, locationMap_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), _c.variants_, _c.types_, _c.typeGenerics_, _c.typeLocations_, _c.asyncTypes_, _c.typeParameters_, _c.traits_, _c.traitLocations_, _c.state_, _c.lspHook_)
1856
+ }))(self_);
1857
+ return ff_compiler_Syntax.EFunctions(at_, ff_core_List.List_map(functions_, ((_w1) => {
1858
+ return ff_compiler_Resolver.Resolver_resolveFunctionDefinition(self2_, _w1, topLevel_, false)
1859
+ })), ff_compiler_Resolver.Resolver_resolveTerm(self2_, body_, topLevel_))
1860
+ return
1861
+ }
1862
+ }
1863
+ {
1864
+ if(term_a.ELet) {
1865
+ const e_ = term_a;
1866
+ const self2_ = (((_c) => {
1867
+ return ff_compiler_Resolver.Resolver(ff_core_Map.Map_add(self_.variables_, e_.name_, e_.name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Map.Map_add(self_.variableLocations_, e_.name_, e_.at_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), _c.variants_, _c.types_, _c.typeGenerics_, _c.typeLocations_, _c.asyncTypes_, _c.typeParameters_, _c.traits_, _c.traitLocations_, _c.state_, _c.lspHook_)
1868
+ }))(self_);
1869
+ if(ff_compiler_LspHook.LspHook_isEnabled(self_.lspHook_)) {
1870
+ if((ff_compiler_LspHook.LspHook_isAt(self_.lspHook_, e_.at_) || ff_compiler_LspHook.LspHook_isDefinedAt(self_.lspHook_, e_.at_))) {
1871
+ ff_compiler_LspHook.LspHook_emit(self_.lspHook_, ff_compiler_LspHook.ResolveSymbolHook(ff_compiler_LspHook.SymbolHook(e_.name_, e_.at_, e_.at_), ff_core_Option.None()))
1872
+ }
1873
+ };
1874
+ {
1875
+ const _1 = e_;
1876
+ {
1877
+ const _c = _1;
1878
+ return ff_compiler_Syntax.ELet(_c.at_, _c.mutable_, _c.name_, ff_compiler_Resolver.Resolver_resolveType(self_, e_.valueType_, topLevel_), ff_compiler_Resolver.Resolver_resolveTerm(self_, e_.value_, topLevel_), ff_compiler_Resolver.Resolver_resolveTerm(self2_, e_.body_, topLevel_))
1879
+ return
1880
+ }
1881
+ }
1882
+ return
1883
+ }
1884
+ }
1885
+ {
1886
+ if(term_a.ESequential) {
1887
+ const at_ = term_a.at_;
1888
+ const before_ = term_a.before_;
1889
+ const after_ = term_a.after_;
1890
+ return ff_compiler_Syntax.ESequential(at_, ff_compiler_Resolver.Resolver_resolveTerm(self_, before_, topLevel_), ff_compiler_Resolver.Resolver_resolveTerm(self_, after_, topLevel_))
1891
+ return
1892
+ }
1893
+ }
1894
+ {
1895
+ if(term_a.EAssign) {
1896
+ const at_ = term_a.at_;
1897
+ const operator_ = term_a.operator_;
1898
+ const variable_ = term_a.variable_;
1899
+ const value_ = term_a.value_;
1900
+ return ff_compiler_Syntax.EAssign(at_, operator_, ff_core_Option.Option_else(ff_core_Map.Map_get(self_.variables_, variable_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), (() => {
1901
+ throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(at_, ("No such variable: " + variable_)), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
1902
+ })), ff_compiler_Resolver.Resolver_resolveTerm(self_, value_, topLevel_))
1903
+ return
1904
+ }
1905
+ }
1906
+ {
1907
+ if(term_a.EAssignField) {
1908
+ const at_ = term_a.at_;
1909
+ const operator_ = term_a.operator_;
1910
+ const record_ = term_a.record_;
1911
+ const field_ = term_a.field_;
1912
+ const value_ = term_a.value_;
1913
+ return ff_compiler_Syntax.EAssignField(at_, operator_, ff_compiler_Resolver.Resolver_resolveTerm(self_, record_, topLevel_), field_, ff_compiler_Resolver.Resolver_resolveTerm(self_, value_, topLevel_))
1914
+ return
1915
+ }
1916
+ }
1917
+ }
1918
+ }
1919
+
1920
+ export async function Resolver_resolveType$(self_, type_, topLevel_, $task) {
1921
+ {
1922
+ const self_a = self_;
1923
+ const type_a = type_;
1924
+ const topLevel_a = topLevel_;
1925
+ {
1926
+ if(type_a.TVariable) {
1927
+ return type_
1928
+ return
1929
+ }
1930
+ }
1931
+ {
1932
+ if(type_a.TConstructor) {
1933
+ const constructor_ = type_a;
1934
+ if(ff_compiler_LspHook.LspHook_isEnabled(self_.lspHook_)) {
1935
+ const at_ = ff_core_Option.Option_else(ff_core_Map.Map_get(self_.typeLocations_, constructor_.name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), (() => {
1936
+ return type_.at_
1937
+ }));
1938
+ if((ff_compiler_LspHook.LspHook_isAt(self_.lspHook_, type_.at_) || ff_compiler_LspHook.LspHook_isDefinedAt(self_.lspHook_, at_))) {
1939
+ ff_compiler_LspHook.LspHook_emit(self_.lspHook_, ff_compiler_LspHook.ResolveTypeHook(self_.types_, self_.typeGenerics_, ff_compiler_LspHook.SymbolHook(constructor_.name_, type_.at_, at_), type_))
1940
+ }
1941
+ };
1942
+ const name_ = (ff_core_String.String_contains(constructor_.name_, "$")
1943
+ ? constructor_.name_
1944
+ : ff_core_Option.Option_else(ff_core_Map.Map_get(self_.types_, constructor_.name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), (() => {
1945
+ if((!ff_compiler_LspHook.LspHook_isEnabled(self_.lspHook_))) {
1946
+ throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(constructor_.at_, ("No such type: " + constructor_.name_)), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
1947
+ } else {
1948
+ return constructor_.name_
1949
+ }
1950
+ })));
1951
+ const isFunctionType_ = ff_core_String.String_startsWith(name_, "Function$", 0);
1952
+ const effect_ = ((isFunctionType_ || ff_core_Set.Set_contains(self_.asyncTypes_, constructor_.name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String))
1953
+ ? ff_core_List.Link(ff_compiler_Resolver.Resolver_makeEffectArgument(self_, constructor_.at_, topLevel_), ff_core_List.Empty())
1954
+ : ff_core_List.Empty());
1955
+ const generics_ = ff_core_List.List_map(constructor_.generics_, ((_w1) => {
1956
+ return ff_compiler_Resolver.Resolver_resolveType(self_, _w1, topLevel_)
1957
+ }));
1958
+ if(isFunctionType_) {
1959
+ const arguments_ = ff_core_List.List_dropLast(generics_, 1);
1960
+ const returnType_ = ff_core_List.List_grabLast(generics_);
1961
+ {
1962
+ const _1 = constructor_;
1963
+ {
1964
+ const _c = _1;
1965
+ return ff_compiler_Syntax.TConstructor(_c.at_, name_, ff_core_List.List_addAll(effect_, ff_core_List.List_addAll(arguments_, ff_core_List.Link(returnType_, ff_core_List.Empty()))))
1966
+ return
1967
+ }
1968
+ }
1969
+ } else {
1970
+ {
1971
+ const _1 = constructor_;
1972
+ {
1973
+ const _c = _1;
1974
+ return ff_compiler_Syntax.TConstructor(_c.at_, name_, ff_core_List.List_addAll(effect_, generics_))
1975
+ return
1976
+ }
1977
+ }
1978
+ }
1979
+ return
1980
+ }
1981
+ }
1982
+ }
1983
+ }
1984
+
1985
+ export async function Resolver_makeEffectArgument$(self_, at_, topLevel_, $task) {
1986
+ if(topLevel_) {
1987
+ if((!ff_core_Set.Set_contains(self_.typeParameters_, "Q$", ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String))) {
1988
+ return ff_compiler_Syntax.TConstructor(at_, "ff:core/Nothing.Nothing", ff_core_List.Empty())
1989
+ } else {
1990
+ return ff_compiler_Syntax.TConstructor(at_, "Q$", ff_core_List.Empty())
1991
+ }
1992
+ } else {
1993
+ return ff_compiler_Resolver.Resolver_freshUnificationVariable(self_, at_)
1994
+ }
1995
+ }
1996
+
1997
+ export async function Resolver_resolveConstraint$(self_, constraint_, topLevel_, $task) {
1998
+ const traitDefinedAt_ = ff_core_Option.Option_else(ff_core_Map.Map_get(self_.traitLocations_, constraint_.name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), (() => {
1999
+ return constraint_.at_
2000
+ }));
2001
+ if((ff_compiler_LspHook.LspHook_isAt(self_.lspHook_, constraint_.at_) || ff_compiler_LspHook.LspHook_isDefinedAt(self_.lspHook_, traitDefinedAt_))) {
2002
+ ff_compiler_LspHook.LspHook_emit(self_.lspHook_, ff_compiler_LspHook.ResolveConstraintHook(ff_compiler_LspHook.SymbolHook(constraint_.name_, constraint_.at_, traitDefinedAt_), constraint_))
2003
+ };
2004
+ const name_ = ff_core_Option.Option_else(ff_core_Map.Map_get(self_.traits_, constraint_.name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), (() => {
2005
+ throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(constraint_.at_, ("No such trait: " + constraint_.name_)), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
2006
+ }));
2007
+ {
2008
+ const _1 = constraint_;
2009
+ {
2010
+ const _c = _1;
2011
+ return ff_compiler_Syntax.Constraint(_c.at_, name_, ff_core_List.List_map(constraint_.generics_, ((_w1) => {
2012
+ return ff_compiler_Resolver.Resolver_resolveType(self_, _w1, topLevel_)
2013
+ })))
2014
+ return
2015
+ }
2016
+ }
2017
+ }
2018
+
2019
+ export async function Resolver_resolveFunctionDefinition$(self_, definition_, topLevel_, isInstanceMethod_, $task) {
2020
+ const signature_ = ff_compiler_Resolver.Resolver_resolveSignature(self_, definition_.signature_, topLevel_, isInstanceMethod_);
2021
+ const self2_ = ff_compiler_Resolver.Resolver_withSignature(self_, signature_);
2022
+ const body_ = ff_compiler_Syntax.Target_mapFirefly(definition_.body_, ((lambda_) => {
2023
+ {
2024
+ const _1 = lambda_;
2025
+ {
2026
+ const _c = _1;
2027
+ return ff_compiler_Syntax.Lambda(_c.at_, signature_.effect_, ff_core_List.List_map(lambda_.cases_, ((_w1) => {
2028
+ return ff_compiler_Resolver.Resolver_resolveCase(self2_, _w1, false)
2029
+ })))
2030
+ return
2031
+ }
2032
+ }
2033
+ }));
2034
+ return ff_compiler_Syntax.DFunction(definition_.at_, signature_, body_)
2035
+ }
2036
+
2037
+ export async function Resolver_resolveSignature$(self_, signature_, topLevel_, isInstanceMethod_, $task) {
2038
+ if((ff_compiler_LspHook.LspHook_isAt(self_.lspHook_, signature_.at_) || ff_compiler_LspHook.LspHook_isDefinedAt(self_.lspHook_, signature_.at_))) {
2039
+ ff_compiler_LspHook.LspHook_emit(self_.lspHook_, ff_compiler_LspHook.ResolveSignatureHook(signature_, isInstanceMethod_))
2040
+ };
2041
+ const newSignature_ = (topLevel_
2042
+ ? (((_c) => {
2043
+ return ff_compiler_Syntax.Signature(_c.at_, _c.name_, _c.member_, ff_core_List.Link("Q$", signature_.generics_), _c.constraints_, _c.parameters_, _c.returnType_, ff_compiler_Syntax.TConstructor(signature_.at_, "Q$", ff_core_List.Empty()))
2044
+ }))(signature_)
2045
+ : (((_c) => {
2046
+ return ff_compiler_Syntax.Signature(_c.at_, _c.name_, _c.member_, _c.generics_, _c.constraints_, _c.parameters_, _c.returnType_, ff_compiler_Resolver.Resolver_freshUnificationVariable(self_, signature_.at_))
2047
+ }))(signature_));
2048
+ ff_core_Option.Option_each(ff_core_List.List_find(newSignature_.generics_, ((name_) => {
2049
+ return ff_core_Set.Set_contains(self_.typeParameters_, name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String)
2050
+ })), ((name_) => {
2051
+ throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(signature_.at_, (("Type parameter " + name_) + " is already in scope")), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
2052
+ }));
2053
+ const self2_ = ff_compiler_Resolver.Resolver_withSignature(self_, newSignature_);
2054
+ {
2055
+ const _1 = newSignature_;
2056
+ {
2057
+ const _c = _1;
2058
+ return ff_compiler_Syntax.Signature(_c.at_, _c.name_, _c.member_, _c.generics_, ff_core_List.List_map(newSignature_.constraints_, ((_w1) => {
2059
+ return ff_compiler_Resolver.Resolver_resolveConstraint(self2_, _w1, topLevel_)
2060
+ })), ff_core_List.List_map(newSignature_.parameters_, ((p_) => {
2061
+ {
2062
+ const _1 = p_;
2063
+ {
2064
+ const _c = _1;
2065
+ return ff_compiler_Syntax.Parameter(_c.at_, _c.mutable_, _c.name_, ff_compiler_Resolver.Resolver_resolveType(self2_, p_.valueType_, topLevel_), ff_core_Option.Option_map(p_.default_, ((_w1) => {
2066
+ return ff_compiler_Resolver.Resolver_resolveTerm(self2_, _w1, topLevel_)
2067
+ })))
2068
+ return
2069
+ }
2070
+ }
2071
+ })), ff_compiler_Resolver.Resolver_resolveType(self2_, newSignature_.returnType_, topLevel_), _c.effect_)
2072
+ return
2073
+ }
2074
+ }
2075
+ }
2076
+
2077
+ export async function Resolver_withSignature$(self_, signature_, $task) {
2078
+ const variableMap_ = ff_core_List.List_toMap(ff_core_List.List_map(ff_core_List.List_map(signature_.parameters_, ((_w1) => {
2079
+ return _w1.name_
2080
+ })), ((name_) => {
2081
+ return ff_core_Pair.Pair(name_, name_)
2082
+ })), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
2083
+ const variableLocationMap_ = ff_core_List.List_toMap(ff_core_List.List_map(signature_.parameters_, ((p_) => {
2084
+ return ff_core_Pair.Pair(p_.name_, p_.at_)
2085
+ })), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
2086
+ const typeMap_ = ff_core_List.List_toMap(ff_core_List.List_map(signature_.generics_, ((name_) => {
2087
+ return ff_core_Pair.Pair(name_, name_)
2088
+ })), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
2089
+ {
2090
+ const _1 = self_;
2091
+ {
2092
+ const _c = _1;
2093
+ return ff_compiler_Resolver.Resolver(ff_core_Map.Map_addAll(self_.variables_, variableMap_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Map.Map_addAll(self_.variableLocations_, variableLocationMap_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), _c.variants_, ff_core_Map.Map_addAll(self_.types_, typeMap_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), _c.typeGenerics_, _c.typeLocations_, ff_core_Set.Set_removeAll(self_.asyncTypes_, ff_core_List.List_toSet(signature_.generics_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Set.Set_addAll(self_.typeParameters_, ff_core_List.List_toSet(signature_.generics_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), _c.traits_, _c.traitLocations_, _c.state_, _c.lspHook_)
2094
+ return
2095
+ }
2096
+ }
2097
+ }
2098
+
2099
+ export async function Resolver_resolveCase$(self_, case_, topLevel_, $task) {
2100
+ function findVariables_(pattern_) {
2101
+ {
2102
+ const pattern_a = pattern_;
2103
+ {
2104
+ if(pattern_a.PString) {
2105
+ return ff_core_Map.empty_()
2106
+ return
2107
+ }
2108
+ }
2109
+ {
2110
+ if(pattern_a.PInt) {
2111
+ return ff_core_Map.empty_()
2112
+ return
2113
+ }
2114
+ }
2115
+ {
2116
+ if(pattern_a.PChar) {
2117
+ return ff_core_Map.empty_()
2118
+ return
2119
+ }
2120
+ }
2121
+ {
2122
+ if(pattern_a.PVariable) {
2123
+ const at_ = pattern_a.at_;
2124
+ if(pattern_a.name_.Some) {
2125
+ const name_ = pattern_a.name_.value_;
2126
+ return ff_core_List.List_toMap(ff_core_List.Link(ff_core_Pair.Pair(name_, ff_core_Pair.Pair(at_, name_)), ff_core_List.Empty()), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String)
2127
+ return
2128
+ }
2129
+ }
2130
+ }
2131
+ {
2132
+ if(pattern_a.PVariable) {
2133
+ if(pattern_a.name_.None) {
2134
+ return ff_core_Map.empty_()
2135
+ return
2136
+ }
2137
+ }
2138
+ }
2139
+ {
2140
+ if(pattern_a.PVariant) {
2141
+ const patterns_ = pattern_a.patterns_;
2142
+ return ff_core_List.List_foldLeft(ff_core_List.List_map(patterns_, ((pattern_) => {
2143
+ return findVariables_(pattern_)
2144
+ })), ff_core_Map.empty_(), ((_w1, _w2) => {
2145
+ return ff_core_Map.Map_addAll(_w1, _w2, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String)
2146
+ }))
2147
+ return
2148
+ }
2149
+ }
2150
+ {
2151
+ if(pattern_a.PVariantAs) {
2152
+ const at_ = pattern_a.at_;
2153
+ const variableAt_ = pattern_a.variableAt_;
2154
+ const variable_ = pattern_a.variable_;
2155
+ return ff_core_List.List_toMap(ff_core_List.List_map(ff_core_Option.Option_toList(variable_), ((x_) => {
2156
+ return ff_core_Pair.Pair(x_, ff_core_Pair.Pair(variableAt_, x_))
2157
+ })), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String)
2158
+ return
2159
+ }
2160
+ }
2161
+ {
2162
+ if(pattern_a.PAlias) {
2163
+ const at_ = pattern_a.at_;
2164
+ const pattern_ = pattern_a.pattern_;
2165
+ const variable_ = pattern_a.variable_;
2166
+ return ff_core_Map.Map_addAll(ff_core_List.List_toMap(ff_core_List.Link(ff_core_Pair.Pair(variable_, ff_core_Pair.Pair(at_, variable_)), ff_core_List.Empty()), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), findVariables_(pattern_), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String)
2167
+ return
2168
+ }
2169
+ }
2170
+ }
2171
+ }
2172
+ const variableMap_ = ff_core_List.List_foldLeft(ff_core_List.List_map(case_.patterns_, ((pattern_) => {
2173
+ return findVariables_(pattern_)
2174
+ })), ff_core_Map.empty_(), ((_w1, _w2) => {
2175
+ return ff_core_Map.Map_addAll(_w1, _w2, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String)
2176
+ }));
2177
+ let guards_ = ff_core_List.Empty();
2178
+ const variableMap2_ = ff_core_List.List_foldLeft(case_.guards_, variableMap_, ((variableMap1_, g_) => {
2179
+ const self2_ = (((_c) => {
2180
+ return ff_compiler_Resolver.Resolver(ff_core_Map.Map_addAll(self_.variables_, ff_core_Map.Map_mapValues(variableMap1_, ((_, p_) => {
2181
+ return p_.second_
2182
+ }), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Map.Map_addAll(self_.variableLocations_, ff_core_Map.Map_mapValues(variableMap1_, ((_, p_) => {
2183
+ return p_.first_
2184
+ }), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), _c.variants_, _c.types_, _c.typeGenerics_, _c.typeLocations_, _c.asyncTypes_, _c.typeParameters_, _c.traits_, _c.traitLocations_, _c.state_, _c.lspHook_)
2185
+ }))(self_);
2186
+ const guard_ = (((_c) => {
2187
+ return ff_compiler_Syntax.MatchGuard(_c.at_, ff_compiler_Resolver.Resolver_resolveTerm(self2_, g_.term_, topLevel_), ff_compiler_Resolver.Resolver_resolvePattern(self2_, g_.pattern_))
2188
+ }))(g_);
2189
+ guards_ = ff_core_List.Link(guard_, guards_);
2190
+ return ff_core_Map.Map_addAll(variableMap1_, findVariables_(guard_.pattern_), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String)
2191
+ }));
2192
+ const self3_ = (((_c) => {
2193
+ return ff_compiler_Resolver.Resolver(ff_core_Map.Map_addAll(self_.variables_, ff_core_Map.Map_mapValues(variableMap2_, ((_, p_) => {
2194
+ return p_.second_
2195
+ }), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Map.Map_addAll(self_.variableLocations_, ff_core_Map.Map_mapValues(variableMap2_, ((_, p_) => {
2196
+ return p_.first_
2197
+ }), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), _c.variants_, _c.types_, _c.typeGenerics_, _c.typeLocations_, _c.asyncTypes_, _c.typeParameters_, _c.traits_, _c.traitLocations_, _c.state_, _c.lspHook_)
2198
+ }))(self_);
2199
+ return ff_compiler_Syntax.MatchCase(case_.at_, ff_core_List.List_map(case_.patterns_, ((_w1) => {
2200
+ return ff_compiler_Resolver.Resolver_resolvePattern(self_, _w1)
2201
+ })), ff_core_List.List_reverse(guards_), ff_compiler_Resolver.Resolver_resolveTerm(self3_, case_.body_, topLevel_))
2202
+ }
2203
+
2204
+ export async function Resolver_resolvePattern$(self_, pattern_, $task) {
2205
+ {
2206
+ const self_a = self_;
2207
+ const pattern_a = pattern_;
2208
+ {
2209
+ if(pattern_a.PString) {
2210
+ return pattern_
2211
+ return
2212
+ }
2213
+ }
2214
+ {
2215
+ if(pattern_a.PInt) {
2216
+ return pattern_
2217
+ return
2218
+ }
2219
+ }
2220
+ {
2221
+ if(pattern_a.PChar) {
2222
+ return pattern_
2223
+ return
2224
+ }
2225
+ }
2226
+ {
2227
+ if(pattern_a.PVariable) {
2228
+ return pattern_
2229
+ return
2230
+ }
2231
+ }
2232
+ {
2233
+ if(pattern_a.PVariant) {
2234
+ const at_ = pattern_a.at_;
2235
+ const name_ = pattern_a.name_;
2236
+ const patterns_ = pattern_a.patterns_;
2237
+ const newName_ = ff_core_Option.Option_else(ff_core_Map.Map_get(self_.variants_, name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), (() => {
2238
+ return name_
2239
+ }));
2240
+ const newPatterns_ = ff_core_List.List_map(patterns_, ((_w1) => {
2241
+ return ff_compiler_Resolver.Resolver_resolvePattern(self_, _w1)
2242
+ }));
2243
+ return ff_compiler_Syntax.PVariant(at_, newName_, newPatterns_)
2244
+ return
2245
+ }
2246
+ }
2247
+ {
2248
+ if(pattern_a.PVariantAs) {
2249
+ const at_ = pattern_a.at_;
2250
+ const name_ = pattern_a.name_;
2251
+ const variableAt_ = pattern_a.variableAt_;
2252
+ const variable_ = pattern_a.variable_;
2253
+ const newName_ = ff_core_Option.Option_else(ff_core_Map.Map_get(self_.variants_, name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), (() => {
2254
+ return name_
2255
+ }));
2256
+ return ff_compiler_Syntax.PVariantAs(at_, newName_, variableAt_, variable_)
2257
+ return
2258
+ }
2259
+ }
2260
+ {
2261
+ if(pattern_a.PAlias) {
2262
+ const at_ = pattern_a.at_;
2263
+ const pattern_ = pattern_a.pattern_;
2264
+ const variable_ = pattern_a.variable_;
2265
+ const newPattern_ = ff_compiler_Resolver.Resolver_resolvePattern(self_, pattern_);
2266
+ return ff_compiler_Syntax.PAlias(at_, newPattern_, variable_)
2267
+ return
2268
+ }
2269
+ }
2270
+ }
2271
+ }
2272
+
2273
+ export async function Resolver_containsAsyncType$(self_, type_, $task) {
2274
+ {
2275
+ const self_a = self_;
2276
+ const type_a = type_;
2277
+ {
2278
+ if(type_a.TVariable) {
2279
+ return false
2280
+ return
2281
+ }
2282
+ }
2283
+ {
2284
+ if(type_a.TConstructor) {
2285
+ const constructor_ = type_a;
2286
+ const name_ = (ff_core_String.String_contains(constructor_.name_, "$")
2287
+ ? constructor_.name_
2288
+ : ff_core_Option.Option_else(ff_core_Map.Map_get(self_.types_, constructor_.name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), (() => {
2289
+ if(ff_compiler_LspHook.LspHook_isEnabled(self_.lspHook_)) {
2290
+ return constructor_.name_
2291
+ } else {
2292
+ throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(constructor_.at_, ("No such type: " + constructor_.name_)), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
2293
+ }
2294
+ })));
2295
+ const isFunctionType_ = ff_core_String.String_startsWith(name_, "Function$", 0);
2296
+ return ((isFunctionType_ || ff_core_Set.Set_contains(self_.asyncTypes_, constructor_.name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String)) || ff_core_List.List_any(constructor_.generics_, ((_w1) => {
2297
+ return ff_compiler_Resolver.Resolver_containsAsyncType(self_, _w1)
2298
+ })))
2299
+ return
2300
+ }
2301
+ }
2302
+ }
2303
+ }
2304
+
2305
+
2306
+
2307
+