firefly-compiler 0.4.5 → 0.4.6

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 (78) hide show
  1. package/.hintrc +4 -4
  2. package/README.md +1 -1
  3. package/core/HttpClient.ff +1 -1
  4. package/lsp/LanguageServer.ff +32 -7
  5. package/lsp/stderr.txt +1 -0
  6. package/lsp/stdin.txt +11 -0
  7. package/lsp/stdout.txt +41 -0
  8. package/lux/Main.ff +56 -2
  9. package/meetup/AutoCompletion.ff +6 -0
  10. package/output/js/ff/compiler/Builder.mjs +444 -444
  11. package/output/js/ff/compiler/Compiler.mjs +416 -416
  12. package/output/js/ff/compiler/Dependencies.mjs +389 -389
  13. package/output/js/ff/compiler/Deriver.mjs +1170 -1170
  14. package/output/js/ff/compiler/Dictionaries.mjs +1309 -1309
  15. package/output/js/ff/compiler/Environment.mjs +1015 -1015
  16. package/output/js/ff/compiler/Inference.mjs +4268 -4268
  17. package/output/js/ff/compiler/JsEmitter.mjs +5391 -5391
  18. package/output/js/ff/compiler/JsImporter.mjs +266 -266
  19. package/output/js/ff/compiler/LspHook.mjs +793 -793
  20. package/output/js/ff/compiler/Main.mjs +1675 -1675
  21. package/output/js/ff/compiler/Parser.mjs +4008 -4008
  22. package/output/js/ff/compiler/Patterns.mjs +927 -927
  23. package/output/js/ff/compiler/Resolver.mjs +2307 -2307
  24. package/output/js/ff/compiler/Substitution.mjs +1150 -1150
  25. package/output/js/ff/compiler/Syntax.mjs +12434 -12434
  26. package/output/js/ff/compiler/Token.mjs +3096 -3096
  27. package/output/js/ff/compiler/Tokenizer.mjs +593 -593
  28. package/output/js/ff/compiler/Unification.mjs +1752 -1752
  29. package/output/js/ff/compiler/Wildcards.mjs +608 -608
  30. package/output/js/ff/compiler/Workspace.mjs +687 -687
  31. package/output/js/ff/core/Any.mjs +143 -143
  32. package/output/js/ff/core/Array.mjs +547 -547
  33. package/output/js/ff/core/AssetSystem.mjs +274 -274
  34. package/output/js/ff/core/Atomic.mjs +154 -154
  35. package/output/js/ff/core/Bool.mjs +152 -152
  36. package/output/js/ff/core/Box.mjs +112 -112
  37. package/output/js/ff/core/BrowserSystem.mjs +126 -126
  38. package/output/js/ff/core/Buffer.mjs +395 -395
  39. package/output/js/ff/core/BuildSystem.mjs +296 -296
  40. package/output/js/ff/core/Channel.mjs +189 -189
  41. package/output/js/ff/core/Char.mjs +149 -149
  42. package/output/js/ff/core/Core.mjs +300 -300
  43. package/output/js/ff/core/Duration.mjs +116 -116
  44. package/output/js/ff/core/Equal.mjs +179 -179
  45. package/output/js/ff/core/Error.mjs +142 -142
  46. package/output/js/ff/core/FileHandle.mjs +150 -150
  47. package/output/js/ff/core/Float.mjs +225 -225
  48. package/output/js/ff/core/HttpClient.mjs +190 -190
  49. package/output/js/ff/core/Instant.mjs +109 -109
  50. package/output/js/ff/core/Int.mjs +265 -265
  51. package/output/js/ff/core/IntMap.mjs +280 -280
  52. package/output/js/ff/core/JsSystem.mjs +238 -238
  53. package/output/js/ff/core/JsValue.mjs +708 -708
  54. package/output/js/ff/core/List.mjs +2334 -2334
  55. package/output/js/ff/core/Lock.mjs +229 -229
  56. package/output/js/ff/core/Log.mjs +163 -163
  57. package/output/js/ff/core/Map.mjs +362 -362
  58. package/output/js/ff/core/NodeSystem.mjs +294 -294
  59. package/output/js/ff/core/Nothing.mjs +104 -104
  60. package/output/js/ff/core/Option.mjs +1015 -1015
  61. package/output/js/ff/core/Ordering.mjs +730 -730
  62. package/output/js/ff/core/Pair.mjs +331 -331
  63. package/output/js/ff/core/Path.mjs +545 -545
  64. package/output/js/ff/core/RbMap.mjs +1940 -1940
  65. package/output/js/ff/core/Serializable.mjs +428 -428
  66. package/output/js/ff/core/Set.mjs +254 -254
  67. package/output/js/ff/core/Show.mjs +205 -205
  68. package/output/js/ff/core/SourceLocation.mjs +229 -229
  69. package/output/js/ff/core/Stack.mjs +529 -529
  70. package/output/js/ff/core/Stream.mjs +1304 -1304
  71. package/output/js/ff/core/String.mjs +365 -365
  72. package/output/js/ff/core/StringMap.mjs +280 -280
  73. package/output/js/ff/core/Task.mjs +320 -320
  74. package/output/js/ff/core/Try.mjs +507 -507
  75. package/output/js/ff/core/Unit.mjs +151 -151
  76. package/package.json +29 -29
  77. package/vscode/package-lock.json +5 -5
  78. package/vscode/package.json +1 -1
@@ -1,1309 +1,1309 @@
1
-
2
-
3
- import * as ff_compiler_Dictionaries from "../../ff/compiler/Dictionaries.mjs"
4
-
5
- import * as ff_compiler_Environment from "../../ff/compiler/Environment.mjs"
6
-
7
- import * as ff_compiler_Syntax from "../../ff/compiler/Syntax.mjs"
8
-
9
- import * as ff_compiler_Unification from "../../ff/compiler/Unification.mjs"
10
-
11
- import * as ff_core_Any from "../../ff/core/Any.mjs"
12
-
13
- import * as ff_core_Array from "../../ff/core/Array.mjs"
14
-
15
- import * as ff_core_AssetSystem from "../../ff/core/AssetSystem.mjs"
16
-
17
- import * as ff_core_Atomic from "../../ff/core/Atomic.mjs"
18
-
19
- import * as ff_core_Bool from "../../ff/core/Bool.mjs"
20
-
21
- import * as ff_core_Box from "../../ff/core/Box.mjs"
22
-
23
- import * as ff_core_BrowserSystem from "../../ff/core/BrowserSystem.mjs"
24
-
25
- import * as ff_core_Buffer from "../../ff/core/Buffer.mjs"
26
-
27
- import * as ff_core_BuildSystem from "../../ff/core/BuildSystem.mjs"
28
-
29
- import * as ff_core_Channel from "../../ff/core/Channel.mjs"
30
-
31
- import * as ff_core_Char from "../../ff/core/Char.mjs"
32
-
33
- import * as ff_core_Core from "../../ff/core/Core.mjs"
34
-
35
- import * as ff_core_Duration from "../../ff/core/Duration.mjs"
36
-
37
- import * as ff_core_Equal from "../../ff/core/Equal.mjs"
38
-
39
- import * as ff_core_Error from "../../ff/core/Error.mjs"
40
-
41
- import * as ff_core_FileHandle from "../../ff/core/FileHandle.mjs"
42
-
43
- import * as ff_core_Float from "../../ff/core/Float.mjs"
44
-
45
- import * as ff_core_HttpClient from "../../ff/core/HttpClient.mjs"
46
-
47
- import * as ff_core_Instant from "../../ff/core/Instant.mjs"
48
-
49
- import * as ff_core_Int from "../../ff/core/Int.mjs"
50
-
51
- import * as ff_core_IntMap from "../../ff/core/IntMap.mjs"
52
-
53
- import * as ff_core_JsSystem from "../../ff/core/JsSystem.mjs"
54
-
55
- import * as ff_core_JsValue from "../../ff/core/JsValue.mjs"
56
-
57
- import * as ff_core_List from "../../ff/core/List.mjs"
58
-
59
- import * as ff_core_Lock from "../../ff/core/Lock.mjs"
60
-
61
- import * as ff_core_Log from "../../ff/core/Log.mjs"
62
-
63
- import * as ff_core_Map from "../../ff/core/Map.mjs"
64
-
65
- import * as ff_core_NodeSystem from "../../ff/core/NodeSystem.mjs"
66
-
67
- import * as ff_core_Nothing from "../../ff/core/Nothing.mjs"
68
-
69
- import * as ff_core_Option from "../../ff/core/Option.mjs"
70
-
71
- import * as ff_core_Ordering from "../../ff/core/Ordering.mjs"
72
-
73
- import * as ff_core_Pair from "../../ff/core/Pair.mjs"
74
-
75
- import * as ff_core_Path from "../../ff/core/Path.mjs"
76
-
77
- import * as ff_core_Serializable from "../../ff/core/Serializable.mjs"
78
-
79
- import * as ff_core_Set from "../../ff/core/Set.mjs"
80
-
81
- import * as ff_core_Show from "../../ff/core/Show.mjs"
82
-
83
- import * as ff_core_SourceLocation from "../../ff/core/SourceLocation.mjs"
84
-
85
- import * as ff_core_Stack from "../../ff/core/Stack.mjs"
86
-
87
- import * as ff_core_Stream from "../../ff/core/Stream.mjs"
88
-
89
- import * as ff_core_String from "../../ff/core/String.mjs"
90
-
91
- import * as ff_core_StringMap from "../../ff/core/StringMap.mjs"
92
-
93
- import * as ff_core_Task from "../../ff/core/Task.mjs"
94
-
95
- import * as ff_core_Try from "../../ff/core/Try.mjs"
96
-
97
- import * as ff_core_Unit from "../../ff/core/Unit.mjs"
98
-
99
- // type Dictionaries
100
- export function Dictionaries(instances_) {
101
- return {instances_};
102
- }
103
-
104
-
105
-
106
- export function make_(modules_) {
107
- return ff_compiler_Dictionaries.Dictionaries(ff_compiler_Unification.make_(modules_, false).instances_)
108
- }
109
-
110
- export function fail_(at_, message_) {
111
- return ff_core_Core.panic_(((message_ + " ") + ff_compiler_Syntax.Location_show(at_)))
112
- }
113
-
114
- export function constraintsToInstances_(constraints_) {
115
- return ff_core_List.List_toMap(ff_core_List.List_map(constraints_, ((c_) => {
116
- const typeName_ = (((_1) => {
117
- {
118
- if(_1.TConstructor) {
119
- const name_ = _1.name_;
120
- return name_
121
- return
122
- }
123
- }
124
- {
125
- if(_1.TVariable) {
126
- const i_ = _1.index_;
127
- return ff_compiler_Dictionaries.fail_(c_.at_, ("Unexpected unification variable: $" + i_))
128
- return
129
- }
130
- }
131
- }))(ff_core_List.List_grabFirst(c_.generics_));
132
- return ff_core_Pair.Pair(ff_compiler_Unification.InstanceKey(c_.name_, typeName_), ff_compiler_Unification.InstanceValue(ff_core_List.Empty(), ff_core_List.Empty(), ff_compiler_Syntax.PackagePair("", ""), "", c_.name_, c_.generics_))
133
- })), ff_compiler_Unification.ff_core_Ordering_Order$ff_compiler_Unification_InstanceKey)
134
- }
135
-
136
- export async function make_$(modules_, $task) {
137
- return ff_compiler_Dictionaries.Dictionaries(ff_compiler_Unification.make_(modules_, false).instances_)
138
- }
139
-
140
- export async function fail_$(at_, message_, $task) {
141
- return ff_core_Core.panic_(((message_ + " ") + ff_compiler_Syntax.Location_show(at_)))
142
- }
143
-
144
- export async function constraintsToInstances_$(constraints_, $task) {
145
- return ff_core_List.List_toMap(ff_core_List.List_map(constraints_, ((c_) => {
146
- const typeName_ = (((_1) => {
147
- {
148
- if(_1.TConstructor) {
149
- const name_ = _1.name_;
150
- return name_
151
- return
152
- }
153
- }
154
- {
155
- if(_1.TVariable) {
156
- const i_ = _1.index_;
157
- return ff_compiler_Dictionaries.fail_(c_.at_, ("Unexpected unification variable: $" + i_))
158
- return
159
- }
160
- }
161
- }))(ff_core_List.List_grabFirst(c_.generics_));
162
- return ff_core_Pair.Pair(ff_compiler_Unification.InstanceKey(c_.name_, typeName_), ff_compiler_Unification.InstanceValue(ff_core_List.Empty(), ff_core_List.Empty(), ff_compiler_Syntax.PackagePair("", ""), "", c_.name_, c_.generics_))
163
- })), ff_compiler_Unification.ff_core_Ordering_Order$ff_compiler_Unification_InstanceKey)
164
- }
165
-
166
- export function Dictionaries_processModule(self_, module_, otherModules_) {
167
- const environment_ = ff_compiler_Environment.make_(module_, otherModules_, true);
168
- const functionSignatures_ = ff_core_List.List_toMap(ff_core_List.List_collect(ff_core_Map.Map_pairs(environment_.symbols_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ((_1) => {
169
- {
170
- const name_ = _1.first_;
171
- const s_ = _1.second_;
172
- const _guard1 = (!s_.isVariable_);
173
- if(_guard1) {
174
- return ff_core_Option.Some(ff_core_Pair.Pair(name_, s_.signature_))
175
- return
176
- }
177
- }
178
- {
179
- return ff_core_Option.None()
180
- return
181
- }
182
- })), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
183
- const lets_ = ff_core_List.List_map(module_.lets_, ((_w1) => {
184
- return ff_compiler_Dictionaries.Dictionaries_processLetDefinition(self_, functionSignatures_, _w1)
185
- }));
186
- const functions_ = ff_core_List.List_map(module_.functions_, ((_w1) => {
187
- return ff_compiler_Dictionaries.Dictionaries_processFunctionDefinition(self_, functionSignatures_, _w1)
188
- }));
189
- const extends_ = ff_core_List.List_map(module_.extends_, ((_w1) => {
190
- return ff_compiler_Dictionaries.Dictionaries_processExtendDefinition(self_, functionSignatures_, _w1)
191
- }));
192
- const instances_ = ff_core_List.List_map(module_.instances_, ((_w1) => {
193
- return ff_compiler_Dictionaries.Dictionaries_processInstanceDefinition(self_, functionSignatures_, _w1)
194
- }));
195
- {
196
- const _1 = module_;
197
- {
198
- const _c = _1;
199
- return ff_compiler_Syntax.Module(_c.file_, _c.packagePair_, _c.imports_, _c.types_, _c.traits_, instances_, extends_, lets_, functions_)
200
- return
201
- }
202
- }
203
- }
204
-
205
- export function Dictionaries_processLetDefinition(self_, functions_, definition_) {
206
- {
207
- const _1 = definition_;
208
- {
209
- const _c = _1;
210
- return ff_compiler_Syntax.DLet(_c.at_, _c.name_, _c.variableType_, ff_compiler_Dictionaries.Dictionaries_processTerm(self_, functions_, definition_.value_))
211
- return
212
- }
213
- }
214
- }
215
-
216
- export function Dictionaries_processExtendDefinition(self_, functions_, definition_) {
217
- {
218
- const _1 = definition_;
219
- {
220
- const _c = _1;
221
- return ff_compiler_Syntax.DExtend(_c.at_, _c.name_, _c.generics_, _c.constraints_, _c.type_, ff_core_List.List_map(definition_.methods_, ((_w1) => {
222
- return ff_compiler_Dictionaries.Dictionaries_processFunctionDefinition(self_, functions_, _w1)
223
- })))
224
- return
225
- }
226
- }
227
- }
228
-
229
- export function Dictionaries_processFunctionDefinition(self_, functions_, definition_) {
230
- const instances_ = ff_compiler_Dictionaries.constraintsToInstances_(definition_.signature_.constraints_);
231
- const self2_ = (((_c) => {
232
- return ff_compiler_Dictionaries.Dictionaries(ff_core_Map.Map_addAll(self_.instances_, instances_, ff_compiler_Unification.ff_core_Ordering_Order$ff_compiler_Unification_InstanceKey))
233
- }))(self_);
234
- {
235
- const _1 = definition_;
236
- {
237
- const _c = _1;
238
- return ff_compiler_Syntax.DFunction(_c.at_, _c.signature_, ff_compiler_Syntax.Target_mapFirefly(definition_.body_, ((_w1) => {
239
- return ff_compiler_Dictionaries.Dictionaries_processLambda(self2_, functions_, _w1)
240
- })))
241
- return
242
- }
243
- }
244
- }
245
-
246
- export function Dictionaries_processInstanceDefinition(self_, functions_, definition_) {
247
- const instances_ = ff_compiler_Dictionaries.constraintsToInstances_(definition_.constraints_);
248
- const self2_ = (((_c) => {
249
- return ff_compiler_Dictionaries.Dictionaries(ff_core_Map.Map_addAll(self_.instances_, instances_, ff_compiler_Unification.ff_core_Ordering_Order$ff_compiler_Unification_InstanceKey))
250
- }))(self_);
251
- {
252
- const _1 = definition_;
253
- {
254
- const _c = _1;
255
- return ff_compiler_Syntax.DInstance(_c.at_, _c.generics_, _c.constraints_, _c.traitName_, _c.typeArguments_, _c.generatorArguments_, ff_core_List.List_map(definition_.methods_, ((_w1) => {
256
- return ff_compiler_Dictionaries.Dictionaries_processFunctionDefinition(self2_, functions_, _w1)
257
- })), _c.derived_)
258
- return
259
- }
260
- }
261
- }
262
-
263
- export function Dictionaries_processLambda(self_, functions_, definition_) {
264
- {
265
- const _1 = definition_;
266
- {
267
- const _c = _1;
268
- return ff_compiler_Syntax.Lambda(_c.at_, _c.effect_, ff_core_List.List_map(definition_.cases_, ((case_) => {
269
- {
270
- const _1 = case_;
271
- {
272
- const _c = _1;
273
- return ff_compiler_Syntax.MatchCase(_c.at_, _c.patterns_, ff_core_List.List_map(case_.guards_, ((g_) => {
274
- {
275
- const _1 = g_;
276
- {
277
- const _c = _1;
278
- return ff_compiler_Syntax.MatchGuard(_c.at_, ff_compiler_Dictionaries.Dictionaries_processTerm(self_, functions_, g_.term_), _c.pattern_)
279
- return
280
- }
281
- }
282
- })), ff_compiler_Dictionaries.Dictionaries_processTerm(self_, functions_, case_.body_))
283
- return
284
- }
285
- }
286
- })))
287
- return
288
- }
289
- }
290
- }
291
-
292
- export function Dictionaries_processTerm(self_, functions_, term_) {
293
- {
294
- const _1 = term_;
295
- {
296
- if(_1.EString) {
297
- return term_
298
- return
299
- }
300
- }
301
- {
302
- if(_1.EChar) {
303
- return term_
304
- return
305
- }
306
- }
307
- {
308
- if(_1.EInt) {
309
- return term_
310
- return
311
- }
312
- }
313
- {
314
- if(_1.EFloat) {
315
- return term_
316
- return
317
- }
318
- }
319
- {
320
- if(_1.EVariable) {
321
- return term_
322
- return
323
- }
324
- }
325
- {
326
- if(_1.EField) {
327
- const e_ = _1;
328
- {
329
- const _1 = e_;
330
- {
331
- const _c = _1;
332
- return ff_compiler_Syntax.EField(_c.at_, _c.newtype_, ff_compiler_Dictionaries.Dictionaries_processTerm(self_, functions_, e_.record_), _c.field_)
333
- return
334
- }
335
- }
336
- return
337
- }
338
- }
339
- {
340
- if(_1.EWildcard) {
341
- const e_ = _1;
342
- return term_
343
- return
344
- }
345
- }
346
- {
347
- if(_1.EList) {
348
- const e_ = _1;
349
- {
350
- const _1 = e_;
351
- {
352
- const _c = _1;
353
- return ff_compiler_Syntax.EList(_c.at_, _c.elementType_, ff_core_List.List_map(e_.items_, ((_1) => {
354
- {
355
- const item_ = _1.first_;
356
- const b_ = _1.second_;
357
- return ff_core_Pair.Pair(ff_compiler_Dictionaries.Dictionaries_processTerm(self_, functions_, item_), b_)
358
- return
359
- }
360
- })))
361
- return
362
- }
363
- }
364
- return
365
- }
366
- }
367
- {
368
- if(_1.ESequential) {
369
- const e_ = _1;
370
- {
371
- const _1 = e_;
372
- {
373
- const _c = _1;
374
- return ff_compiler_Syntax.ESequential(_c.at_, ff_compiler_Dictionaries.Dictionaries_processTerm(self_, functions_, e_.before_), ff_compiler_Dictionaries.Dictionaries_processTerm(self_, functions_, e_.after_))
375
- return
376
- }
377
- }
378
- return
379
- }
380
- }
381
- {
382
- if(_1.ELet) {
383
- const e_ = _1;
384
- const newFunctions_ = ff_core_Map.Map_remove(functions_, e_.name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
385
- {
386
- const _1 = e_;
387
- {
388
- const _c = _1;
389
- return ff_compiler_Syntax.ELet(_c.at_, _c.mutable_, _c.name_, _c.valueType_, ff_compiler_Dictionaries.Dictionaries_processTerm(self_, functions_, e_.value_), ff_compiler_Dictionaries.Dictionaries_processTerm(self_, newFunctions_, e_.body_))
390
- return
391
- }
392
- }
393
- return
394
- }
395
- }
396
- {
397
- if(_1.ELambda) {
398
- const e_ = _1;
399
- {
400
- const _1 = e_;
401
- {
402
- const _c = _1;
403
- return ff_compiler_Syntax.ELambda(_c.at_, ff_compiler_Dictionaries.Dictionaries_processLambda(self_, functions_, e_.lambda_))
404
- return
405
- }
406
- }
407
- return
408
- }
409
- }
410
- {
411
- if(_1.EVariant) {
412
- const e_ = _1;
413
- {
414
- const _1 = e_;
415
- {
416
- const _c = _1;
417
- return ff_compiler_Syntax.EVariant(_c.at_, _c.name_, _c.typeArguments_, ff_core_Option.Option_map(e_.arguments_, ((_w1) => {
418
- return ff_core_List.List_map(_w1, ((_w1) => {
419
- return ff_compiler_Dictionaries.Dictionaries_processArgument(self_, functions_, _w1)
420
- }))
421
- })))
422
- return
423
- }
424
- }
425
- return
426
- }
427
- }
428
- {
429
- if(_1.EVariantIs) {
430
- const e_ = _1;
431
- return term_
432
- return
433
- }
434
- }
435
- {
436
- if(_1.ECopy) {
437
- const e_ = _1;
438
- {
439
- const _1 = e_;
440
- {
441
- const _c = _1;
442
- return ff_compiler_Syntax.ECopy(_c.at_, _c.name_, ff_compiler_Dictionaries.Dictionaries_processTerm(self_, functions_, e_.record_), ff_core_List.List_map(e_.arguments_, ((_w1) => {
443
- return ff_compiler_Dictionaries.Dictionaries_processField(self_, functions_, _w1)
444
- })))
445
- return
446
- }
447
- }
448
- return
449
- }
450
- }
451
- {
452
- if(_1.EPipe) {
453
- const e_ = _1;
454
- {
455
- const _1 = e_;
456
- {
457
- const _c = _1;
458
- return ff_compiler_Syntax.EPipe(_c.at_, ff_compiler_Dictionaries.Dictionaries_processTerm(self_, functions_, e_.value_), _c.effect_, ff_compiler_Dictionaries.Dictionaries_processTerm(self_, functions_, e_.function_))
459
- return
460
- }
461
- }
462
- return
463
- }
464
- }
465
- {
466
- if(_1.ECall) {
467
- const at_ = _1.at_;
468
- if(_1.target_.StaticCall) {
469
- const target_ = _1.target_;
470
- const effect_ = _1.effect_;
471
- const typeArguments_ = _1.typeArguments_;
472
- const arguments_ = _1.arguments_;
473
- const _guard1 = ff_core_Map.Map_get(functions_, target_.name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
474
- if(_guard1.Some) {
475
- const signature_ = _guard1.value_;
476
- const dictionaries_ = ff_core_List.List_map(signature_.constraints_, ((_w1) => {
477
- return ff_compiler_Dictionaries.Dictionaries_makeDictionary(self_, at_, signature_.generics_, typeArguments_, _w1)
478
- }));
479
- return ff_compiler_Syntax.ECall(at_, (((_c) => {
480
- return ff_compiler_Syntax.StaticCall(_c.name_, _c.tailCall_, _c.instanceCall_)
481
- }))(target_), effect_, typeArguments_, ff_core_List.List_map(arguments_, ((_w1) => {
482
- return ff_compiler_Dictionaries.Dictionaries_processArgument(self_, functions_, _w1)
483
- })), dictionaries_)
484
- return
485
- }
486
- }
487
- }
488
- }
489
- {
490
- if(_1.ECall) {
491
- const e_ = _1;
492
- const target_ = (((_1) => {
493
- {
494
- if(_1.DynamicCall) {
495
- const call_ = _1;
496
- {
497
- const _1 = call_;
498
- {
499
- const _c = _1;
500
- return ff_compiler_Syntax.DynamicCall(ff_compiler_Dictionaries.Dictionaries_processTerm(self_, functions_, call_.function_), _c.tailCall_)
501
- return
502
- }
503
- }
504
- return
505
- }
506
- }
507
- {
508
- if(_1.StaticCall) {
509
- return e_.target_
510
- return
511
- }
512
- }
513
- }))(e_.target_);
514
- {
515
- const _1 = e_;
516
- {
517
- const _c = _1;
518
- return ff_compiler_Syntax.ECall(_c.at_, target_, _c.effect_, _c.typeArguments_, ff_core_List.List_map(e_.arguments_, ((_w1) => {
519
- return ff_compiler_Dictionaries.Dictionaries_processArgument(self_, functions_, _w1)
520
- })), _c.dictionaries_)
521
- return
522
- }
523
- }
524
- return
525
- }
526
- }
527
- {
528
- if(_1.ERecord) {
529
- const e_ = _1;
530
- {
531
- const _1 = e_;
532
- {
533
- const _c = _1;
534
- return ff_compiler_Syntax.ERecord(_c.at_, ff_core_List.List_map(e_.fields_, ((_w1) => {
535
- return ff_compiler_Dictionaries.Dictionaries_processField(self_, functions_, _w1)
536
- })))
537
- return
538
- }
539
- }
540
- return
541
- }
542
- }
543
- {
544
- if(_1.EFunctions) {
545
- const e_ = _1;
546
- const newFunctions_ = ff_core_Map.Map_addAll(functions_, ff_core_List.List_toMap(ff_core_List.List_map(e_.functions_, ((f_) => {
547
- return ff_core_Pair.Pair(f_.signature_.name_, f_.signature_)
548
- })), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
549
- {
550
- const _1 = e_;
551
- {
552
- const _c = _1;
553
- return ff_compiler_Syntax.EFunctions(_c.at_, ff_core_List.List_map(e_.functions_, ((_w1) => {
554
- return ff_compiler_Dictionaries.Dictionaries_processFunctionDefinition(self_, newFunctions_, _w1)
555
- })), ff_compiler_Dictionaries.Dictionaries_processTerm(self_, newFunctions_, e_.body_))
556
- return
557
- }
558
- }
559
- return
560
- }
561
- }
562
- {
563
- if(_1.EAssign) {
564
- const e_ = _1;
565
- {
566
- const _1 = e_;
567
- {
568
- const _c = _1;
569
- return ff_compiler_Syntax.EAssign(_c.at_, _c.operator_, _c.variable_, ff_compiler_Dictionaries.Dictionaries_processTerm(self_, functions_, e_.value_))
570
- return
571
- }
572
- }
573
- return
574
- }
575
- }
576
- {
577
- if(_1.EAssignField) {
578
- const e_ = _1;
579
- {
580
- const _1 = e_;
581
- {
582
- const _c = _1;
583
- return ff_compiler_Syntax.EAssignField(_c.at_, _c.operator_, ff_compiler_Dictionaries.Dictionaries_processTerm(self_, functions_, e_.record_), _c.field_, ff_compiler_Dictionaries.Dictionaries_processTerm(self_, functions_, e_.value_))
584
- return
585
- }
586
- }
587
- return
588
- }
589
- }
590
- }
591
- }
592
-
593
- export function Dictionaries_processArgument(self_, functions_, argument_) {
594
- {
595
- const _1 = argument_;
596
- {
597
- const _c = _1;
598
- return ff_compiler_Syntax.Argument(_c.at_, _c.name_, ff_compiler_Dictionaries.Dictionaries_processTerm(self_, functions_, argument_.value_))
599
- return
600
- }
601
- }
602
- }
603
-
604
- export function Dictionaries_processField(self_, functions_, field_) {
605
- {
606
- const _1 = field_;
607
- {
608
- const _c = _1;
609
- return ff_compiler_Syntax.Field(_c.at_, _c.name_, ff_compiler_Dictionaries.Dictionaries_processTerm(self_, functions_, field_.value_))
610
- return
611
- }
612
- }
613
- }
614
-
615
- export function Dictionaries_makeDictionary(self_, at_, typeParameters_, typeArguments_, constraint_) {
616
- const instantiationMap_ = ff_core_List.List_toMap(ff_core_List.List_zip(typeParameters_, typeArguments_), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
617
- const unification_ = ff_compiler_Unification.make_(ff_core_List.Empty(), false);
618
- const newGenerics_ = ff_core_List.List_map(constraint_.generics_, ((_w1) => {
619
- return ff_compiler_Unification.Unification_instantiate(unification_, instantiationMap_, _w1)
620
- }));
621
- const firstType_ = (((_1) => {
622
- {
623
- if(_1.TConstructor) {
624
- const t_ = _1;
625
- return t_
626
- return
627
- }
628
- }
629
- {
630
- if(_1.TVariable) {
631
- const t_ = _1;
632
- return ff_compiler_Dictionaries.fail_(t_.at_, " is still a unification variable")
633
- return
634
- }
635
- }
636
- }))(ff_core_List.List_grabFirst(newGenerics_));
637
- const instance_ = ff_core_Option.Option_else(ff_core_Map.Map_get(self_.instances_, ff_compiler_Unification.InstanceKey(constraint_.name_, firstType_.name_), ff_compiler_Unification.ff_core_Ordering_Order$ff_compiler_Unification_InstanceKey), (() => {
638
- throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(at_, ((("Missing instance " + firstType_.name_) + ": ") + constraint_.name_)), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
639
- }));
640
- const dictionaries_ = ff_core_List.List_map(instance_.constraints_, ((c_) => {
641
- return ff_compiler_Dictionaries.Dictionaries_makeDictionary(self_, at_, instance_.generics_, firstType_.generics_, c_)
642
- }));
643
- return ff_compiler_Syntax.Dictionary(instance_.packagePair_, instance_.moduleName_, constraint_.name_, firstType_.name_, dictionaries_)
644
- }
645
-
646
- export async function Dictionaries_processModule$(self_, module_, otherModules_, $task) {
647
- const environment_ = ff_compiler_Environment.make_(module_, otherModules_, true);
648
- const functionSignatures_ = ff_core_List.List_toMap(ff_core_List.List_collect(ff_core_Map.Map_pairs(environment_.symbols_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ((_1) => {
649
- {
650
- const name_ = _1.first_;
651
- const s_ = _1.second_;
652
- const _guard1 = (!s_.isVariable_);
653
- if(_guard1) {
654
- return ff_core_Option.Some(ff_core_Pair.Pair(name_, s_.signature_))
655
- return
656
- }
657
- }
658
- {
659
- return ff_core_Option.None()
660
- return
661
- }
662
- })), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
663
- const lets_ = ff_core_List.List_map(module_.lets_, ((_w1) => {
664
- return ff_compiler_Dictionaries.Dictionaries_processLetDefinition(self_, functionSignatures_, _w1)
665
- }));
666
- const functions_ = ff_core_List.List_map(module_.functions_, ((_w1) => {
667
- return ff_compiler_Dictionaries.Dictionaries_processFunctionDefinition(self_, functionSignatures_, _w1)
668
- }));
669
- const extends_ = ff_core_List.List_map(module_.extends_, ((_w1) => {
670
- return ff_compiler_Dictionaries.Dictionaries_processExtendDefinition(self_, functionSignatures_, _w1)
671
- }));
672
- const instances_ = ff_core_List.List_map(module_.instances_, ((_w1) => {
673
- return ff_compiler_Dictionaries.Dictionaries_processInstanceDefinition(self_, functionSignatures_, _w1)
674
- }));
675
- {
676
- const _1 = module_;
677
- {
678
- const _c = _1;
679
- return ff_compiler_Syntax.Module(_c.file_, _c.packagePair_, _c.imports_, _c.types_, _c.traits_, instances_, extends_, lets_, functions_)
680
- return
681
- }
682
- }
683
- }
684
-
685
- export async function Dictionaries_processLetDefinition$(self_, functions_, definition_, $task) {
686
- {
687
- const _1 = definition_;
688
- {
689
- const _c = _1;
690
- return ff_compiler_Syntax.DLet(_c.at_, _c.name_, _c.variableType_, ff_compiler_Dictionaries.Dictionaries_processTerm(self_, functions_, definition_.value_))
691
- return
692
- }
693
- }
694
- }
695
-
696
- export async function Dictionaries_processExtendDefinition$(self_, functions_, definition_, $task) {
697
- {
698
- const _1 = definition_;
699
- {
700
- const _c = _1;
701
- return ff_compiler_Syntax.DExtend(_c.at_, _c.name_, _c.generics_, _c.constraints_, _c.type_, ff_core_List.List_map(definition_.methods_, ((_w1) => {
702
- return ff_compiler_Dictionaries.Dictionaries_processFunctionDefinition(self_, functions_, _w1)
703
- })))
704
- return
705
- }
706
- }
707
- }
708
-
709
- export async function Dictionaries_processFunctionDefinition$(self_, functions_, definition_, $task) {
710
- const instances_ = ff_compiler_Dictionaries.constraintsToInstances_(definition_.signature_.constraints_);
711
- const self2_ = (((_c) => {
712
- return ff_compiler_Dictionaries.Dictionaries(ff_core_Map.Map_addAll(self_.instances_, instances_, ff_compiler_Unification.ff_core_Ordering_Order$ff_compiler_Unification_InstanceKey))
713
- }))(self_);
714
- {
715
- const _1 = definition_;
716
- {
717
- const _c = _1;
718
- return ff_compiler_Syntax.DFunction(_c.at_, _c.signature_, ff_compiler_Syntax.Target_mapFirefly(definition_.body_, ((_w1) => {
719
- return ff_compiler_Dictionaries.Dictionaries_processLambda(self2_, functions_, _w1)
720
- })))
721
- return
722
- }
723
- }
724
- }
725
-
726
- export async function Dictionaries_processInstanceDefinition$(self_, functions_, definition_, $task) {
727
- const instances_ = ff_compiler_Dictionaries.constraintsToInstances_(definition_.constraints_);
728
- const self2_ = (((_c) => {
729
- return ff_compiler_Dictionaries.Dictionaries(ff_core_Map.Map_addAll(self_.instances_, instances_, ff_compiler_Unification.ff_core_Ordering_Order$ff_compiler_Unification_InstanceKey))
730
- }))(self_);
731
- {
732
- const _1 = definition_;
733
- {
734
- const _c = _1;
735
- return ff_compiler_Syntax.DInstance(_c.at_, _c.generics_, _c.constraints_, _c.traitName_, _c.typeArguments_, _c.generatorArguments_, ff_core_List.List_map(definition_.methods_, ((_w1) => {
736
- return ff_compiler_Dictionaries.Dictionaries_processFunctionDefinition(self2_, functions_, _w1)
737
- })), _c.derived_)
738
- return
739
- }
740
- }
741
- }
742
-
743
- export async function Dictionaries_processLambda$(self_, functions_, definition_, $task) {
744
- {
745
- const _1 = definition_;
746
- {
747
- const _c = _1;
748
- return ff_compiler_Syntax.Lambda(_c.at_, _c.effect_, ff_core_List.List_map(definition_.cases_, ((case_) => {
749
- {
750
- const _1 = case_;
751
- {
752
- const _c = _1;
753
- return ff_compiler_Syntax.MatchCase(_c.at_, _c.patterns_, ff_core_List.List_map(case_.guards_, ((g_) => {
754
- {
755
- const _1 = g_;
756
- {
757
- const _c = _1;
758
- return ff_compiler_Syntax.MatchGuard(_c.at_, ff_compiler_Dictionaries.Dictionaries_processTerm(self_, functions_, g_.term_), _c.pattern_)
759
- return
760
- }
761
- }
762
- })), ff_compiler_Dictionaries.Dictionaries_processTerm(self_, functions_, case_.body_))
763
- return
764
- }
765
- }
766
- })))
767
- return
768
- }
769
- }
770
- }
771
-
772
- export async function Dictionaries_processTerm$(self_, functions_, term_, $task) {
773
- {
774
- const _1 = term_;
775
- {
776
- if(_1.EString) {
777
- return term_
778
- return
779
- }
780
- }
781
- {
782
- if(_1.EChar) {
783
- return term_
784
- return
785
- }
786
- }
787
- {
788
- if(_1.EInt) {
789
- return term_
790
- return
791
- }
792
- }
793
- {
794
- if(_1.EFloat) {
795
- return term_
796
- return
797
- }
798
- }
799
- {
800
- if(_1.EVariable) {
801
- return term_
802
- return
803
- }
804
- }
805
- {
806
- if(_1.EField) {
807
- const e_ = _1;
808
- {
809
- const _1 = e_;
810
- {
811
- const _c = _1;
812
- return ff_compiler_Syntax.EField(_c.at_, _c.newtype_, ff_compiler_Dictionaries.Dictionaries_processTerm(self_, functions_, e_.record_), _c.field_)
813
- return
814
- }
815
- }
816
- return
817
- }
818
- }
819
- {
820
- if(_1.EWildcard) {
821
- const e_ = _1;
822
- return term_
823
- return
824
- }
825
- }
826
- {
827
- if(_1.EList) {
828
- const e_ = _1;
829
- {
830
- const _1 = e_;
831
- {
832
- const _c = _1;
833
- return ff_compiler_Syntax.EList(_c.at_, _c.elementType_, ff_core_List.List_map(e_.items_, ((_1) => {
834
- {
835
- const item_ = _1.first_;
836
- const b_ = _1.second_;
837
- return ff_core_Pair.Pair(ff_compiler_Dictionaries.Dictionaries_processTerm(self_, functions_, item_), b_)
838
- return
839
- }
840
- })))
841
- return
842
- }
843
- }
844
- return
845
- }
846
- }
847
- {
848
- if(_1.ESequential) {
849
- const e_ = _1;
850
- {
851
- const _1 = e_;
852
- {
853
- const _c = _1;
854
- return ff_compiler_Syntax.ESequential(_c.at_, ff_compiler_Dictionaries.Dictionaries_processTerm(self_, functions_, e_.before_), ff_compiler_Dictionaries.Dictionaries_processTerm(self_, functions_, e_.after_))
855
- return
856
- }
857
- }
858
- return
859
- }
860
- }
861
- {
862
- if(_1.ELet) {
863
- const e_ = _1;
864
- const newFunctions_ = ff_core_Map.Map_remove(functions_, e_.name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
865
- {
866
- const _1 = e_;
867
- {
868
- const _c = _1;
869
- return ff_compiler_Syntax.ELet(_c.at_, _c.mutable_, _c.name_, _c.valueType_, ff_compiler_Dictionaries.Dictionaries_processTerm(self_, functions_, e_.value_), ff_compiler_Dictionaries.Dictionaries_processTerm(self_, newFunctions_, e_.body_))
870
- return
871
- }
872
- }
873
- return
874
- }
875
- }
876
- {
877
- if(_1.ELambda) {
878
- const e_ = _1;
879
- {
880
- const _1 = e_;
881
- {
882
- const _c = _1;
883
- return ff_compiler_Syntax.ELambda(_c.at_, ff_compiler_Dictionaries.Dictionaries_processLambda(self_, functions_, e_.lambda_))
884
- return
885
- }
886
- }
887
- return
888
- }
889
- }
890
- {
891
- if(_1.EVariant) {
892
- const e_ = _1;
893
- {
894
- const _1 = e_;
895
- {
896
- const _c = _1;
897
- return ff_compiler_Syntax.EVariant(_c.at_, _c.name_, _c.typeArguments_, ff_core_Option.Option_map(e_.arguments_, ((_w1) => {
898
- return ff_core_List.List_map(_w1, ((_w1) => {
899
- return ff_compiler_Dictionaries.Dictionaries_processArgument(self_, functions_, _w1)
900
- }))
901
- })))
902
- return
903
- }
904
- }
905
- return
906
- }
907
- }
908
- {
909
- if(_1.EVariantIs) {
910
- const e_ = _1;
911
- return term_
912
- return
913
- }
914
- }
915
- {
916
- if(_1.ECopy) {
917
- const e_ = _1;
918
- {
919
- const _1 = e_;
920
- {
921
- const _c = _1;
922
- return ff_compiler_Syntax.ECopy(_c.at_, _c.name_, ff_compiler_Dictionaries.Dictionaries_processTerm(self_, functions_, e_.record_), ff_core_List.List_map(e_.arguments_, ((_w1) => {
923
- return ff_compiler_Dictionaries.Dictionaries_processField(self_, functions_, _w1)
924
- })))
925
- return
926
- }
927
- }
928
- return
929
- }
930
- }
931
- {
932
- if(_1.EPipe) {
933
- const e_ = _1;
934
- {
935
- const _1 = e_;
936
- {
937
- const _c = _1;
938
- return ff_compiler_Syntax.EPipe(_c.at_, ff_compiler_Dictionaries.Dictionaries_processTerm(self_, functions_, e_.value_), _c.effect_, ff_compiler_Dictionaries.Dictionaries_processTerm(self_, functions_, e_.function_))
939
- return
940
- }
941
- }
942
- return
943
- }
944
- }
945
- {
946
- if(_1.ECall) {
947
- const at_ = _1.at_;
948
- if(_1.target_.StaticCall) {
949
- const target_ = _1.target_;
950
- const effect_ = _1.effect_;
951
- const typeArguments_ = _1.typeArguments_;
952
- const arguments_ = _1.arguments_;
953
- const _guard1 = ff_core_Map.Map_get(functions_, target_.name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
954
- if(_guard1.Some) {
955
- const signature_ = _guard1.value_;
956
- const dictionaries_ = ff_core_List.List_map(signature_.constraints_, ((_w1) => {
957
- return ff_compiler_Dictionaries.Dictionaries_makeDictionary(self_, at_, signature_.generics_, typeArguments_, _w1)
958
- }));
959
- return ff_compiler_Syntax.ECall(at_, (((_c) => {
960
- return ff_compiler_Syntax.StaticCall(_c.name_, _c.tailCall_, _c.instanceCall_)
961
- }))(target_), effect_, typeArguments_, ff_core_List.List_map(arguments_, ((_w1) => {
962
- return ff_compiler_Dictionaries.Dictionaries_processArgument(self_, functions_, _w1)
963
- })), dictionaries_)
964
- return
965
- }
966
- }
967
- }
968
- }
969
- {
970
- if(_1.ECall) {
971
- const e_ = _1;
972
- const target_ = (((_1) => {
973
- {
974
- if(_1.DynamicCall) {
975
- const call_ = _1;
976
- {
977
- const _1 = call_;
978
- {
979
- const _c = _1;
980
- return ff_compiler_Syntax.DynamicCall(ff_compiler_Dictionaries.Dictionaries_processTerm(self_, functions_, call_.function_), _c.tailCall_)
981
- return
982
- }
983
- }
984
- return
985
- }
986
- }
987
- {
988
- if(_1.StaticCall) {
989
- return e_.target_
990
- return
991
- }
992
- }
993
- }))(e_.target_);
994
- {
995
- const _1 = e_;
996
- {
997
- const _c = _1;
998
- return ff_compiler_Syntax.ECall(_c.at_, target_, _c.effect_, _c.typeArguments_, ff_core_List.List_map(e_.arguments_, ((_w1) => {
999
- return ff_compiler_Dictionaries.Dictionaries_processArgument(self_, functions_, _w1)
1000
- })), _c.dictionaries_)
1001
- return
1002
- }
1003
- }
1004
- return
1005
- }
1006
- }
1007
- {
1008
- if(_1.ERecord) {
1009
- const e_ = _1;
1010
- {
1011
- const _1 = e_;
1012
- {
1013
- const _c = _1;
1014
- return ff_compiler_Syntax.ERecord(_c.at_, ff_core_List.List_map(e_.fields_, ((_w1) => {
1015
- return ff_compiler_Dictionaries.Dictionaries_processField(self_, functions_, _w1)
1016
- })))
1017
- return
1018
- }
1019
- }
1020
- return
1021
- }
1022
- }
1023
- {
1024
- if(_1.EFunctions) {
1025
- const e_ = _1;
1026
- const newFunctions_ = ff_core_Map.Map_addAll(functions_, ff_core_List.List_toMap(ff_core_List.List_map(e_.functions_, ((f_) => {
1027
- return ff_core_Pair.Pair(f_.signature_.name_, f_.signature_)
1028
- })), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
1029
- {
1030
- const _1 = e_;
1031
- {
1032
- const _c = _1;
1033
- return ff_compiler_Syntax.EFunctions(_c.at_, ff_core_List.List_map(e_.functions_, ((_w1) => {
1034
- return ff_compiler_Dictionaries.Dictionaries_processFunctionDefinition(self_, newFunctions_, _w1)
1035
- })), ff_compiler_Dictionaries.Dictionaries_processTerm(self_, newFunctions_, e_.body_))
1036
- return
1037
- }
1038
- }
1039
- return
1040
- }
1041
- }
1042
- {
1043
- if(_1.EAssign) {
1044
- const e_ = _1;
1045
- {
1046
- const _1 = e_;
1047
- {
1048
- const _c = _1;
1049
- return ff_compiler_Syntax.EAssign(_c.at_, _c.operator_, _c.variable_, ff_compiler_Dictionaries.Dictionaries_processTerm(self_, functions_, e_.value_))
1050
- return
1051
- }
1052
- }
1053
- return
1054
- }
1055
- }
1056
- {
1057
- if(_1.EAssignField) {
1058
- const e_ = _1;
1059
- {
1060
- const _1 = e_;
1061
- {
1062
- const _c = _1;
1063
- return ff_compiler_Syntax.EAssignField(_c.at_, _c.operator_, ff_compiler_Dictionaries.Dictionaries_processTerm(self_, functions_, e_.record_), _c.field_, ff_compiler_Dictionaries.Dictionaries_processTerm(self_, functions_, e_.value_))
1064
- return
1065
- }
1066
- }
1067
- return
1068
- }
1069
- }
1070
- }
1071
- }
1072
-
1073
- export async function Dictionaries_processArgument$(self_, functions_, argument_, $task) {
1074
- {
1075
- const _1 = argument_;
1076
- {
1077
- const _c = _1;
1078
- return ff_compiler_Syntax.Argument(_c.at_, _c.name_, ff_compiler_Dictionaries.Dictionaries_processTerm(self_, functions_, argument_.value_))
1079
- return
1080
- }
1081
- }
1082
- }
1083
-
1084
- export async function Dictionaries_processField$(self_, functions_, field_, $task) {
1085
- {
1086
- const _1 = field_;
1087
- {
1088
- const _c = _1;
1089
- return ff_compiler_Syntax.Field(_c.at_, _c.name_, ff_compiler_Dictionaries.Dictionaries_processTerm(self_, functions_, field_.value_))
1090
- return
1091
- }
1092
- }
1093
- }
1094
-
1095
- export async function Dictionaries_makeDictionary$(self_, at_, typeParameters_, typeArguments_, constraint_, $task) {
1096
- const instantiationMap_ = ff_core_List.List_toMap(ff_core_List.List_zip(typeParameters_, typeArguments_), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
1097
- const unification_ = ff_compiler_Unification.make_(ff_core_List.Empty(), false);
1098
- const newGenerics_ = ff_core_List.List_map(constraint_.generics_, ((_w1) => {
1099
- return ff_compiler_Unification.Unification_instantiate(unification_, instantiationMap_, _w1)
1100
- }));
1101
- const firstType_ = (((_1) => {
1102
- {
1103
- if(_1.TConstructor) {
1104
- const t_ = _1;
1105
- return t_
1106
- return
1107
- }
1108
- }
1109
- {
1110
- if(_1.TVariable) {
1111
- const t_ = _1;
1112
- return ff_compiler_Dictionaries.fail_(t_.at_, " is still a unification variable")
1113
- return
1114
- }
1115
- }
1116
- }))(ff_core_List.List_grabFirst(newGenerics_));
1117
- const instance_ = ff_core_Option.Option_else(ff_core_Map.Map_get(self_.instances_, ff_compiler_Unification.InstanceKey(constraint_.name_, firstType_.name_), ff_compiler_Unification.ff_core_Ordering_Order$ff_compiler_Unification_InstanceKey), (() => {
1118
- throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(at_, ((("Missing instance " + firstType_.name_) + ": ") + constraint_.name_)), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
1119
- }));
1120
- const dictionaries_ = ff_core_List.List_map(instance_.constraints_, ((c_) => {
1121
- return ff_compiler_Dictionaries.Dictionaries_makeDictionary(self_, at_, instance_.generics_, firstType_.generics_, c_)
1122
- }));
1123
- return ff_compiler_Syntax.Dictionary(instance_.packagePair_, instance_.moduleName_, constraint_.name_, firstType_.name_, dictionaries_)
1124
- }
1125
-
1126
- export const ff_core_Any_HasAnyTag$ff_compiler_Dictionaries_Dictionaries = {
1127
- anyTag_() {
1128
- return ff_core_Any.internalAnyTag_((("ff:compiler/Dictionaries.Dictionaries" + "[") + "]"))
1129
- },
1130
- async anyTag_$($task) {
1131
- return ff_core_Any.internalAnyTag_((("ff:compiler/Dictionaries.Dictionaries" + "[") + "]"))
1132
- }
1133
- };
1134
-
1135
- export const ff_core_Show_Show$ff_compiler_Dictionaries_Dictionaries = {
1136
- show_(value_) {
1137
- {
1138
- const value_a = value_;
1139
- {
1140
- const z_ = value_a;
1141
- return ((("Dictionaries" + "(") + ff_core_Map.ff_core_Show_Show$ff_core_Map_Map(ff_compiler_Unification.ff_core_Show_Show$ff_compiler_Unification_InstanceKey, ff_compiler_Unification.ff_core_Ordering_Order$ff_compiler_Unification_InstanceKey, ff_compiler_Unification.ff_core_Show_Show$ff_compiler_Unification_InstanceValue).show_(z_.instances_)) + ")")
1142
- return
1143
- }
1144
- }
1145
- },
1146
- async show_$(value_, $task) {
1147
- {
1148
- const value_a = value_;
1149
- {
1150
- const z_ = value_a;
1151
- return ((("Dictionaries" + "(") + ff_core_Map.ff_core_Show_Show$ff_core_Map_Map(ff_compiler_Unification.ff_core_Show_Show$ff_compiler_Unification_InstanceKey, ff_compiler_Unification.ff_core_Ordering_Order$ff_compiler_Unification_InstanceKey, ff_compiler_Unification.ff_core_Show_Show$ff_compiler_Unification_InstanceValue).show_(z_.instances_)) + ")")
1152
- return
1153
- }
1154
- }
1155
- }
1156
- };
1157
-
1158
- export const ff_core_Equal_Equal$ff_compiler_Dictionaries_Dictionaries = {
1159
- equals_(x_, y_) {
1160
- {
1161
- const x_a = x_;
1162
- const y_a = y_;
1163
- {
1164
- const _guard1 = (x_ === y_);
1165
- if(_guard1) {
1166
- return true
1167
- return
1168
- }
1169
- }
1170
- {
1171
- return ff_core_Map.ff_core_Equal_Equal$ff_core_Map_Map(ff_compiler_Unification.ff_core_Equal_Equal$ff_compiler_Unification_InstanceKey, ff_compiler_Unification.ff_core_Ordering_Order$ff_compiler_Unification_InstanceKey, ff_compiler_Unification.ff_core_Equal_Equal$ff_compiler_Unification_InstanceValue).equals_(x_.instances_, y_.instances_)
1172
- return
1173
- }
1174
- }
1175
- },
1176
- async equals_$(x_, y_, $task) {
1177
- {
1178
- const x_a = x_;
1179
- const y_a = y_;
1180
- {
1181
- const _guard1 = (x_ === y_);
1182
- if(_guard1) {
1183
- return true
1184
- return
1185
- }
1186
- }
1187
- {
1188
- return ff_core_Map.ff_core_Equal_Equal$ff_core_Map_Map(ff_compiler_Unification.ff_core_Equal_Equal$ff_compiler_Unification_InstanceKey, ff_compiler_Unification.ff_core_Ordering_Order$ff_compiler_Unification_InstanceKey, ff_compiler_Unification.ff_core_Equal_Equal$ff_compiler_Unification_InstanceValue).equals_(x_.instances_, y_.instances_)
1189
- return
1190
- }
1191
- }
1192
- }
1193
- };
1194
-
1195
- export const ff_core_Ordering_Order$ff_compiler_Dictionaries_Dictionaries = {
1196
- compare_(x_, y_) {
1197
- {
1198
- const x_a = x_;
1199
- const y_a = y_;
1200
- {
1201
- const _guard1 = (x_ === y_);
1202
- if(_guard1) {
1203
- return ff_core_Ordering.OrderingSame()
1204
- return
1205
- }
1206
- }
1207
- {
1208
- const instancesOrdering_ = ff_core_Map.ff_core_Ordering_Order$ff_core_Map_Map(ff_compiler_Unification.ff_core_Ordering_Order$ff_compiler_Unification_InstanceKey, ff_compiler_Unification.ff_core_Ordering_Order$ff_compiler_Unification_InstanceValue).compare_(x_.instances_, y_.instances_);
1209
- if((instancesOrdering_ !== ff_core_Ordering.OrderingSame())) {
1210
- return instancesOrdering_
1211
- } else {
1212
- return ff_core_Ordering.OrderingSame()
1213
- }
1214
- return
1215
- }
1216
- }
1217
- },
1218
- async compare_$(x_, y_, $task) {
1219
- {
1220
- const x_a = x_;
1221
- const y_a = y_;
1222
- {
1223
- const _guard1 = (x_ === y_);
1224
- if(_guard1) {
1225
- return ff_core_Ordering.OrderingSame()
1226
- return
1227
- }
1228
- }
1229
- {
1230
- const instancesOrdering_ = ff_core_Map.ff_core_Ordering_Order$ff_core_Map_Map(ff_compiler_Unification.ff_core_Ordering_Order$ff_compiler_Unification_InstanceKey, ff_compiler_Unification.ff_core_Ordering_Order$ff_compiler_Unification_InstanceValue).compare_(x_.instances_, y_.instances_);
1231
- if((instancesOrdering_ !== ff_core_Ordering.OrderingSame())) {
1232
- return instancesOrdering_
1233
- } else {
1234
- return ff_core_Ordering.OrderingSame()
1235
- }
1236
- return
1237
- }
1238
- }
1239
- }
1240
- };
1241
-
1242
- export const ff_core_Serializable_Serializable$ff_compiler_Dictionaries_Dictionaries = {
1243
- serializeUsing_(serialization_, value_) {
1244
- {
1245
- const serialization_a = serialization_;
1246
- const value_a = value_;
1247
- {
1248
- const v_ = value_a;
1249
- serialization_.checksum_ = ff_core_Int.Int_bitOr(((31 * serialization_.checksum_) + 37), 0);
1250
- ff_core_Buffer.Buffer_setUint8(serialization_.buffer_, serialization_.offset_, 0);
1251
- serialization_.offset_ += 1;
1252
- ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_Map_Map(ff_compiler_Unification.ff_core_Serializable_Serializable$ff_compiler_Unification_InstanceKey, ff_compiler_Unification.ff_core_Ordering_Order$ff_compiler_Unification_InstanceKey, ff_compiler_Unification.ff_core_Serializable_Serializable$ff_compiler_Unification_InstanceValue).serializeUsing_(serialization_, v_.instances_)
1253
- return
1254
- }
1255
- }
1256
- },
1257
- deserializeUsing_(serialization_) {
1258
- const variantIndex_ = ff_core_Buffer.Buffer_grabUint8(serialization_.buffer_, serialization_.offset_);
1259
- serialization_.offset_ += 1;
1260
- {
1261
- const _1 = variantIndex_;
1262
- {
1263
- if(_1 == 0) {
1264
- serialization_.checksum_ = ff_core_Int.Int_bitOr(((31 * serialization_.checksum_) + 37), 0);
1265
- return ff_compiler_Dictionaries.Dictionaries(ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_Map_Map(ff_compiler_Unification.ff_core_Serializable_Serializable$ff_compiler_Unification_InstanceKey, ff_compiler_Unification.ff_core_Ordering_Order$ff_compiler_Unification_InstanceKey, ff_compiler_Unification.ff_core_Serializable_Serializable$ff_compiler_Unification_InstanceValue).deserializeUsing_(serialization_))
1266
- return
1267
- }
1268
- }
1269
- {
1270
- throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_core_Serializable.DeserializationChecksumException(), ff_core_Serializable.ff_core_Any_HasAnyTag$ff_core_Serializable_DeserializationChecksumException)})
1271
- return
1272
- }
1273
- }
1274
- },
1275
- async serializeUsing_$(serialization_, value_, $task) {
1276
- {
1277
- const serialization_a = serialization_;
1278
- const value_a = value_;
1279
- {
1280
- const v_ = value_a;
1281
- serialization_.checksum_ = ff_core_Int.Int_bitOr(((31 * serialization_.checksum_) + 37), 0);
1282
- ff_core_Buffer.Buffer_setUint8(serialization_.buffer_, serialization_.offset_, 0);
1283
- serialization_.offset_ += 1;
1284
- ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_Map_Map(ff_compiler_Unification.ff_core_Serializable_Serializable$ff_compiler_Unification_InstanceKey, ff_compiler_Unification.ff_core_Ordering_Order$ff_compiler_Unification_InstanceKey, ff_compiler_Unification.ff_core_Serializable_Serializable$ff_compiler_Unification_InstanceValue).serializeUsing_(serialization_, v_.instances_)
1285
- return
1286
- }
1287
- }
1288
- },
1289
- async deserializeUsing_$(serialization_, $task) {
1290
- const variantIndex_ = ff_core_Buffer.Buffer_grabUint8(serialization_.buffer_, serialization_.offset_);
1291
- serialization_.offset_ += 1;
1292
- {
1293
- const _1 = variantIndex_;
1294
- {
1295
- if(_1 == 0) {
1296
- serialization_.checksum_ = ff_core_Int.Int_bitOr(((31 * serialization_.checksum_) + 37), 0);
1297
- return ff_compiler_Dictionaries.Dictionaries(ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_Map_Map(ff_compiler_Unification.ff_core_Serializable_Serializable$ff_compiler_Unification_InstanceKey, ff_compiler_Unification.ff_core_Ordering_Order$ff_compiler_Unification_InstanceKey, ff_compiler_Unification.ff_core_Serializable_Serializable$ff_compiler_Unification_InstanceValue).deserializeUsing_(serialization_))
1298
- return
1299
- }
1300
- }
1301
- {
1302
- throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_core_Serializable.DeserializationChecksumException(), ff_core_Serializable.ff_core_Any_HasAnyTag$ff_core_Serializable_DeserializationChecksumException)})
1303
- return
1304
- }
1305
- }
1306
- }
1307
- };
1308
-
1309
-
1
+
2
+
3
+ import * as ff_compiler_Dictionaries from "../../ff/compiler/Dictionaries.mjs"
4
+
5
+ import * as ff_compiler_Environment from "../../ff/compiler/Environment.mjs"
6
+
7
+ import * as ff_compiler_Syntax from "../../ff/compiler/Syntax.mjs"
8
+
9
+ import * as ff_compiler_Unification from "../../ff/compiler/Unification.mjs"
10
+
11
+ import * as ff_core_Any from "../../ff/core/Any.mjs"
12
+
13
+ import * as ff_core_Array from "../../ff/core/Array.mjs"
14
+
15
+ import * as ff_core_AssetSystem from "../../ff/core/AssetSystem.mjs"
16
+
17
+ import * as ff_core_Atomic from "../../ff/core/Atomic.mjs"
18
+
19
+ import * as ff_core_Bool from "../../ff/core/Bool.mjs"
20
+
21
+ import * as ff_core_Box from "../../ff/core/Box.mjs"
22
+
23
+ import * as ff_core_BrowserSystem from "../../ff/core/BrowserSystem.mjs"
24
+
25
+ import * as ff_core_Buffer from "../../ff/core/Buffer.mjs"
26
+
27
+ import * as ff_core_BuildSystem from "../../ff/core/BuildSystem.mjs"
28
+
29
+ import * as ff_core_Channel from "../../ff/core/Channel.mjs"
30
+
31
+ import * as ff_core_Char from "../../ff/core/Char.mjs"
32
+
33
+ import * as ff_core_Core from "../../ff/core/Core.mjs"
34
+
35
+ import * as ff_core_Duration from "../../ff/core/Duration.mjs"
36
+
37
+ import * as ff_core_Equal from "../../ff/core/Equal.mjs"
38
+
39
+ import * as ff_core_Error from "../../ff/core/Error.mjs"
40
+
41
+ import * as ff_core_FileHandle from "../../ff/core/FileHandle.mjs"
42
+
43
+ import * as ff_core_Float from "../../ff/core/Float.mjs"
44
+
45
+ import * as ff_core_HttpClient from "../../ff/core/HttpClient.mjs"
46
+
47
+ import * as ff_core_Instant from "../../ff/core/Instant.mjs"
48
+
49
+ import * as ff_core_Int from "../../ff/core/Int.mjs"
50
+
51
+ import * as ff_core_IntMap from "../../ff/core/IntMap.mjs"
52
+
53
+ import * as ff_core_JsSystem from "../../ff/core/JsSystem.mjs"
54
+
55
+ import * as ff_core_JsValue from "../../ff/core/JsValue.mjs"
56
+
57
+ import * as ff_core_List from "../../ff/core/List.mjs"
58
+
59
+ import * as ff_core_Lock from "../../ff/core/Lock.mjs"
60
+
61
+ import * as ff_core_Log from "../../ff/core/Log.mjs"
62
+
63
+ import * as ff_core_Map from "../../ff/core/Map.mjs"
64
+
65
+ import * as ff_core_NodeSystem from "../../ff/core/NodeSystem.mjs"
66
+
67
+ import * as ff_core_Nothing from "../../ff/core/Nothing.mjs"
68
+
69
+ import * as ff_core_Option from "../../ff/core/Option.mjs"
70
+
71
+ import * as ff_core_Ordering from "../../ff/core/Ordering.mjs"
72
+
73
+ import * as ff_core_Pair from "../../ff/core/Pair.mjs"
74
+
75
+ import * as ff_core_Path from "../../ff/core/Path.mjs"
76
+
77
+ import * as ff_core_Serializable from "../../ff/core/Serializable.mjs"
78
+
79
+ import * as ff_core_Set from "../../ff/core/Set.mjs"
80
+
81
+ import * as ff_core_Show from "../../ff/core/Show.mjs"
82
+
83
+ import * as ff_core_SourceLocation from "../../ff/core/SourceLocation.mjs"
84
+
85
+ import * as ff_core_Stack from "../../ff/core/Stack.mjs"
86
+
87
+ import * as ff_core_Stream from "../../ff/core/Stream.mjs"
88
+
89
+ import * as ff_core_String from "../../ff/core/String.mjs"
90
+
91
+ import * as ff_core_StringMap from "../../ff/core/StringMap.mjs"
92
+
93
+ import * as ff_core_Task from "../../ff/core/Task.mjs"
94
+
95
+ import * as ff_core_Try from "../../ff/core/Try.mjs"
96
+
97
+ import * as ff_core_Unit from "../../ff/core/Unit.mjs"
98
+
99
+ // type Dictionaries
100
+ export function Dictionaries(instances_) {
101
+ return {instances_};
102
+ }
103
+
104
+
105
+
106
+ export function make_(modules_) {
107
+ return ff_compiler_Dictionaries.Dictionaries(ff_compiler_Unification.make_(modules_, false).instances_)
108
+ }
109
+
110
+ export function fail_(at_, message_) {
111
+ return ff_core_Core.panic_(((message_ + " ") + ff_compiler_Syntax.Location_show(at_)))
112
+ }
113
+
114
+ export function constraintsToInstances_(constraints_) {
115
+ return ff_core_List.List_toMap(ff_core_List.List_map(constraints_, ((c_) => {
116
+ const typeName_ = (((_1) => {
117
+ {
118
+ if(_1.TConstructor) {
119
+ const name_ = _1.name_;
120
+ return name_
121
+ return
122
+ }
123
+ }
124
+ {
125
+ if(_1.TVariable) {
126
+ const i_ = _1.index_;
127
+ return ff_compiler_Dictionaries.fail_(c_.at_, ("Unexpected unification variable: $" + i_))
128
+ return
129
+ }
130
+ }
131
+ }))(ff_core_List.List_grabFirst(c_.generics_));
132
+ return ff_core_Pair.Pair(ff_compiler_Unification.InstanceKey(c_.name_, typeName_), ff_compiler_Unification.InstanceValue(ff_core_List.Empty(), ff_core_List.Empty(), ff_compiler_Syntax.PackagePair("", ""), "", c_.name_, c_.generics_))
133
+ })), ff_compiler_Unification.ff_core_Ordering_Order$ff_compiler_Unification_InstanceKey)
134
+ }
135
+
136
+ export async function make_$(modules_, $task) {
137
+ return ff_compiler_Dictionaries.Dictionaries(ff_compiler_Unification.make_(modules_, false).instances_)
138
+ }
139
+
140
+ export async function fail_$(at_, message_, $task) {
141
+ return ff_core_Core.panic_(((message_ + " ") + ff_compiler_Syntax.Location_show(at_)))
142
+ }
143
+
144
+ export async function constraintsToInstances_$(constraints_, $task) {
145
+ return ff_core_List.List_toMap(ff_core_List.List_map(constraints_, ((c_) => {
146
+ const typeName_ = (((_1) => {
147
+ {
148
+ if(_1.TConstructor) {
149
+ const name_ = _1.name_;
150
+ return name_
151
+ return
152
+ }
153
+ }
154
+ {
155
+ if(_1.TVariable) {
156
+ const i_ = _1.index_;
157
+ return ff_compiler_Dictionaries.fail_(c_.at_, ("Unexpected unification variable: $" + i_))
158
+ return
159
+ }
160
+ }
161
+ }))(ff_core_List.List_grabFirst(c_.generics_));
162
+ return ff_core_Pair.Pair(ff_compiler_Unification.InstanceKey(c_.name_, typeName_), ff_compiler_Unification.InstanceValue(ff_core_List.Empty(), ff_core_List.Empty(), ff_compiler_Syntax.PackagePair("", ""), "", c_.name_, c_.generics_))
163
+ })), ff_compiler_Unification.ff_core_Ordering_Order$ff_compiler_Unification_InstanceKey)
164
+ }
165
+
166
+ export function Dictionaries_processModule(self_, module_, otherModules_) {
167
+ const environment_ = ff_compiler_Environment.make_(module_, otherModules_, true);
168
+ const functionSignatures_ = ff_core_List.List_toMap(ff_core_List.List_collect(ff_core_Map.Map_pairs(environment_.symbols_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ((_1) => {
169
+ {
170
+ const name_ = _1.first_;
171
+ const s_ = _1.second_;
172
+ const _guard1 = (!s_.isVariable_);
173
+ if(_guard1) {
174
+ return ff_core_Option.Some(ff_core_Pair.Pair(name_, s_.signature_))
175
+ return
176
+ }
177
+ }
178
+ {
179
+ return ff_core_Option.None()
180
+ return
181
+ }
182
+ })), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
183
+ const lets_ = ff_core_List.List_map(module_.lets_, ((_w1) => {
184
+ return ff_compiler_Dictionaries.Dictionaries_processLetDefinition(self_, functionSignatures_, _w1)
185
+ }));
186
+ const functions_ = ff_core_List.List_map(module_.functions_, ((_w1) => {
187
+ return ff_compiler_Dictionaries.Dictionaries_processFunctionDefinition(self_, functionSignatures_, _w1)
188
+ }));
189
+ const extends_ = ff_core_List.List_map(module_.extends_, ((_w1) => {
190
+ return ff_compiler_Dictionaries.Dictionaries_processExtendDefinition(self_, functionSignatures_, _w1)
191
+ }));
192
+ const instances_ = ff_core_List.List_map(module_.instances_, ((_w1) => {
193
+ return ff_compiler_Dictionaries.Dictionaries_processInstanceDefinition(self_, functionSignatures_, _w1)
194
+ }));
195
+ {
196
+ const _1 = module_;
197
+ {
198
+ const _c = _1;
199
+ return ff_compiler_Syntax.Module(_c.file_, _c.packagePair_, _c.imports_, _c.types_, _c.traits_, instances_, extends_, lets_, functions_)
200
+ return
201
+ }
202
+ }
203
+ }
204
+
205
+ export function Dictionaries_processLetDefinition(self_, functions_, definition_) {
206
+ {
207
+ const _1 = definition_;
208
+ {
209
+ const _c = _1;
210
+ return ff_compiler_Syntax.DLet(_c.at_, _c.name_, _c.variableType_, ff_compiler_Dictionaries.Dictionaries_processTerm(self_, functions_, definition_.value_))
211
+ return
212
+ }
213
+ }
214
+ }
215
+
216
+ export function Dictionaries_processExtendDefinition(self_, functions_, definition_) {
217
+ {
218
+ const _1 = definition_;
219
+ {
220
+ const _c = _1;
221
+ return ff_compiler_Syntax.DExtend(_c.at_, _c.name_, _c.generics_, _c.constraints_, _c.type_, ff_core_List.List_map(definition_.methods_, ((_w1) => {
222
+ return ff_compiler_Dictionaries.Dictionaries_processFunctionDefinition(self_, functions_, _w1)
223
+ })))
224
+ return
225
+ }
226
+ }
227
+ }
228
+
229
+ export function Dictionaries_processFunctionDefinition(self_, functions_, definition_) {
230
+ const instances_ = ff_compiler_Dictionaries.constraintsToInstances_(definition_.signature_.constraints_);
231
+ const self2_ = (((_c) => {
232
+ return ff_compiler_Dictionaries.Dictionaries(ff_core_Map.Map_addAll(self_.instances_, instances_, ff_compiler_Unification.ff_core_Ordering_Order$ff_compiler_Unification_InstanceKey))
233
+ }))(self_);
234
+ {
235
+ const _1 = definition_;
236
+ {
237
+ const _c = _1;
238
+ return ff_compiler_Syntax.DFunction(_c.at_, _c.signature_, ff_compiler_Syntax.Target_mapFirefly(definition_.body_, ((_w1) => {
239
+ return ff_compiler_Dictionaries.Dictionaries_processLambda(self2_, functions_, _w1)
240
+ })))
241
+ return
242
+ }
243
+ }
244
+ }
245
+
246
+ export function Dictionaries_processInstanceDefinition(self_, functions_, definition_) {
247
+ const instances_ = ff_compiler_Dictionaries.constraintsToInstances_(definition_.constraints_);
248
+ const self2_ = (((_c) => {
249
+ return ff_compiler_Dictionaries.Dictionaries(ff_core_Map.Map_addAll(self_.instances_, instances_, ff_compiler_Unification.ff_core_Ordering_Order$ff_compiler_Unification_InstanceKey))
250
+ }))(self_);
251
+ {
252
+ const _1 = definition_;
253
+ {
254
+ const _c = _1;
255
+ return ff_compiler_Syntax.DInstance(_c.at_, _c.generics_, _c.constraints_, _c.traitName_, _c.typeArguments_, _c.generatorArguments_, ff_core_List.List_map(definition_.methods_, ((_w1) => {
256
+ return ff_compiler_Dictionaries.Dictionaries_processFunctionDefinition(self2_, functions_, _w1)
257
+ })), _c.derived_)
258
+ return
259
+ }
260
+ }
261
+ }
262
+
263
+ export function Dictionaries_processLambda(self_, functions_, definition_) {
264
+ {
265
+ const _1 = definition_;
266
+ {
267
+ const _c = _1;
268
+ return ff_compiler_Syntax.Lambda(_c.at_, _c.effect_, ff_core_List.List_map(definition_.cases_, ((case_) => {
269
+ {
270
+ const _1 = case_;
271
+ {
272
+ const _c = _1;
273
+ return ff_compiler_Syntax.MatchCase(_c.at_, _c.patterns_, ff_core_List.List_map(case_.guards_, ((g_) => {
274
+ {
275
+ const _1 = g_;
276
+ {
277
+ const _c = _1;
278
+ return ff_compiler_Syntax.MatchGuard(_c.at_, ff_compiler_Dictionaries.Dictionaries_processTerm(self_, functions_, g_.term_), _c.pattern_)
279
+ return
280
+ }
281
+ }
282
+ })), ff_compiler_Dictionaries.Dictionaries_processTerm(self_, functions_, case_.body_))
283
+ return
284
+ }
285
+ }
286
+ })))
287
+ return
288
+ }
289
+ }
290
+ }
291
+
292
+ export function Dictionaries_processTerm(self_, functions_, term_) {
293
+ {
294
+ const _1 = term_;
295
+ {
296
+ if(_1.EString) {
297
+ return term_
298
+ return
299
+ }
300
+ }
301
+ {
302
+ if(_1.EChar) {
303
+ return term_
304
+ return
305
+ }
306
+ }
307
+ {
308
+ if(_1.EInt) {
309
+ return term_
310
+ return
311
+ }
312
+ }
313
+ {
314
+ if(_1.EFloat) {
315
+ return term_
316
+ return
317
+ }
318
+ }
319
+ {
320
+ if(_1.EVariable) {
321
+ return term_
322
+ return
323
+ }
324
+ }
325
+ {
326
+ if(_1.EField) {
327
+ const e_ = _1;
328
+ {
329
+ const _1 = e_;
330
+ {
331
+ const _c = _1;
332
+ return ff_compiler_Syntax.EField(_c.at_, _c.newtype_, ff_compiler_Dictionaries.Dictionaries_processTerm(self_, functions_, e_.record_), _c.field_)
333
+ return
334
+ }
335
+ }
336
+ return
337
+ }
338
+ }
339
+ {
340
+ if(_1.EWildcard) {
341
+ const e_ = _1;
342
+ return term_
343
+ return
344
+ }
345
+ }
346
+ {
347
+ if(_1.EList) {
348
+ const e_ = _1;
349
+ {
350
+ const _1 = e_;
351
+ {
352
+ const _c = _1;
353
+ return ff_compiler_Syntax.EList(_c.at_, _c.elementType_, ff_core_List.List_map(e_.items_, ((_1) => {
354
+ {
355
+ const item_ = _1.first_;
356
+ const b_ = _1.second_;
357
+ return ff_core_Pair.Pair(ff_compiler_Dictionaries.Dictionaries_processTerm(self_, functions_, item_), b_)
358
+ return
359
+ }
360
+ })))
361
+ return
362
+ }
363
+ }
364
+ return
365
+ }
366
+ }
367
+ {
368
+ if(_1.ESequential) {
369
+ const e_ = _1;
370
+ {
371
+ const _1 = e_;
372
+ {
373
+ const _c = _1;
374
+ return ff_compiler_Syntax.ESequential(_c.at_, ff_compiler_Dictionaries.Dictionaries_processTerm(self_, functions_, e_.before_), ff_compiler_Dictionaries.Dictionaries_processTerm(self_, functions_, e_.after_))
375
+ return
376
+ }
377
+ }
378
+ return
379
+ }
380
+ }
381
+ {
382
+ if(_1.ELet) {
383
+ const e_ = _1;
384
+ const newFunctions_ = ff_core_Map.Map_remove(functions_, e_.name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
385
+ {
386
+ const _1 = e_;
387
+ {
388
+ const _c = _1;
389
+ return ff_compiler_Syntax.ELet(_c.at_, _c.mutable_, _c.name_, _c.valueType_, ff_compiler_Dictionaries.Dictionaries_processTerm(self_, functions_, e_.value_), ff_compiler_Dictionaries.Dictionaries_processTerm(self_, newFunctions_, e_.body_))
390
+ return
391
+ }
392
+ }
393
+ return
394
+ }
395
+ }
396
+ {
397
+ if(_1.ELambda) {
398
+ const e_ = _1;
399
+ {
400
+ const _1 = e_;
401
+ {
402
+ const _c = _1;
403
+ return ff_compiler_Syntax.ELambda(_c.at_, ff_compiler_Dictionaries.Dictionaries_processLambda(self_, functions_, e_.lambda_))
404
+ return
405
+ }
406
+ }
407
+ return
408
+ }
409
+ }
410
+ {
411
+ if(_1.EVariant) {
412
+ const e_ = _1;
413
+ {
414
+ const _1 = e_;
415
+ {
416
+ const _c = _1;
417
+ return ff_compiler_Syntax.EVariant(_c.at_, _c.name_, _c.typeArguments_, ff_core_Option.Option_map(e_.arguments_, ((_w1) => {
418
+ return ff_core_List.List_map(_w1, ((_w1) => {
419
+ return ff_compiler_Dictionaries.Dictionaries_processArgument(self_, functions_, _w1)
420
+ }))
421
+ })))
422
+ return
423
+ }
424
+ }
425
+ return
426
+ }
427
+ }
428
+ {
429
+ if(_1.EVariantIs) {
430
+ const e_ = _1;
431
+ return term_
432
+ return
433
+ }
434
+ }
435
+ {
436
+ if(_1.ECopy) {
437
+ const e_ = _1;
438
+ {
439
+ const _1 = e_;
440
+ {
441
+ const _c = _1;
442
+ return ff_compiler_Syntax.ECopy(_c.at_, _c.name_, ff_compiler_Dictionaries.Dictionaries_processTerm(self_, functions_, e_.record_), ff_core_List.List_map(e_.arguments_, ((_w1) => {
443
+ return ff_compiler_Dictionaries.Dictionaries_processField(self_, functions_, _w1)
444
+ })))
445
+ return
446
+ }
447
+ }
448
+ return
449
+ }
450
+ }
451
+ {
452
+ if(_1.EPipe) {
453
+ const e_ = _1;
454
+ {
455
+ const _1 = e_;
456
+ {
457
+ const _c = _1;
458
+ return ff_compiler_Syntax.EPipe(_c.at_, ff_compiler_Dictionaries.Dictionaries_processTerm(self_, functions_, e_.value_), _c.effect_, ff_compiler_Dictionaries.Dictionaries_processTerm(self_, functions_, e_.function_))
459
+ return
460
+ }
461
+ }
462
+ return
463
+ }
464
+ }
465
+ {
466
+ if(_1.ECall) {
467
+ const at_ = _1.at_;
468
+ if(_1.target_.StaticCall) {
469
+ const target_ = _1.target_;
470
+ const effect_ = _1.effect_;
471
+ const typeArguments_ = _1.typeArguments_;
472
+ const arguments_ = _1.arguments_;
473
+ const _guard1 = ff_core_Map.Map_get(functions_, target_.name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
474
+ if(_guard1.Some) {
475
+ const signature_ = _guard1.value_;
476
+ const dictionaries_ = ff_core_List.List_map(signature_.constraints_, ((_w1) => {
477
+ return ff_compiler_Dictionaries.Dictionaries_makeDictionary(self_, at_, signature_.generics_, typeArguments_, _w1)
478
+ }));
479
+ return ff_compiler_Syntax.ECall(at_, (((_c) => {
480
+ return ff_compiler_Syntax.StaticCall(_c.name_, _c.tailCall_, _c.instanceCall_)
481
+ }))(target_), effect_, typeArguments_, ff_core_List.List_map(arguments_, ((_w1) => {
482
+ return ff_compiler_Dictionaries.Dictionaries_processArgument(self_, functions_, _w1)
483
+ })), dictionaries_)
484
+ return
485
+ }
486
+ }
487
+ }
488
+ }
489
+ {
490
+ if(_1.ECall) {
491
+ const e_ = _1;
492
+ const target_ = (((_1) => {
493
+ {
494
+ if(_1.DynamicCall) {
495
+ const call_ = _1;
496
+ {
497
+ const _1 = call_;
498
+ {
499
+ const _c = _1;
500
+ return ff_compiler_Syntax.DynamicCall(ff_compiler_Dictionaries.Dictionaries_processTerm(self_, functions_, call_.function_), _c.tailCall_)
501
+ return
502
+ }
503
+ }
504
+ return
505
+ }
506
+ }
507
+ {
508
+ if(_1.StaticCall) {
509
+ return e_.target_
510
+ return
511
+ }
512
+ }
513
+ }))(e_.target_);
514
+ {
515
+ const _1 = e_;
516
+ {
517
+ const _c = _1;
518
+ return ff_compiler_Syntax.ECall(_c.at_, target_, _c.effect_, _c.typeArguments_, ff_core_List.List_map(e_.arguments_, ((_w1) => {
519
+ return ff_compiler_Dictionaries.Dictionaries_processArgument(self_, functions_, _w1)
520
+ })), _c.dictionaries_)
521
+ return
522
+ }
523
+ }
524
+ return
525
+ }
526
+ }
527
+ {
528
+ if(_1.ERecord) {
529
+ const e_ = _1;
530
+ {
531
+ const _1 = e_;
532
+ {
533
+ const _c = _1;
534
+ return ff_compiler_Syntax.ERecord(_c.at_, ff_core_List.List_map(e_.fields_, ((_w1) => {
535
+ return ff_compiler_Dictionaries.Dictionaries_processField(self_, functions_, _w1)
536
+ })))
537
+ return
538
+ }
539
+ }
540
+ return
541
+ }
542
+ }
543
+ {
544
+ if(_1.EFunctions) {
545
+ const e_ = _1;
546
+ const newFunctions_ = ff_core_Map.Map_addAll(functions_, ff_core_List.List_toMap(ff_core_List.List_map(e_.functions_, ((f_) => {
547
+ return ff_core_Pair.Pair(f_.signature_.name_, f_.signature_)
548
+ })), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
549
+ {
550
+ const _1 = e_;
551
+ {
552
+ const _c = _1;
553
+ return ff_compiler_Syntax.EFunctions(_c.at_, ff_core_List.List_map(e_.functions_, ((_w1) => {
554
+ return ff_compiler_Dictionaries.Dictionaries_processFunctionDefinition(self_, newFunctions_, _w1)
555
+ })), ff_compiler_Dictionaries.Dictionaries_processTerm(self_, newFunctions_, e_.body_))
556
+ return
557
+ }
558
+ }
559
+ return
560
+ }
561
+ }
562
+ {
563
+ if(_1.EAssign) {
564
+ const e_ = _1;
565
+ {
566
+ const _1 = e_;
567
+ {
568
+ const _c = _1;
569
+ return ff_compiler_Syntax.EAssign(_c.at_, _c.operator_, _c.variable_, ff_compiler_Dictionaries.Dictionaries_processTerm(self_, functions_, e_.value_))
570
+ return
571
+ }
572
+ }
573
+ return
574
+ }
575
+ }
576
+ {
577
+ if(_1.EAssignField) {
578
+ const e_ = _1;
579
+ {
580
+ const _1 = e_;
581
+ {
582
+ const _c = _1;
583
+ return ff_compiler_Syntax.EAssignField(_c.at_, _c.operator_, ff_compiler_Dictionaries.Dictionaries_processTerm(self_, functions_, e_.record_), _c.field_, ff_compiler_Dictionaries.Dictionaries_processTerm(self_, functions_, e_.value_))
584
+ return
585
+ }
586
+ }
587
+ return
588
+ }
589
+ }
590
+ }
591
+ }
592
+
593
+ export function Dictionaries_processArgument(self_, functions_, argument_) {
594
+ {
595
+ const _1 = argument_;
596
+ {
597
+ const _c = _1;
598
+ return ff_compiler_Syntax.Argument(_c.at_, _c.name_, ff_compiler_Dictionaries.Dictionaries_processTerm(self_, functions_, argument_.value_))
599
+ return
600
+ }
601
+ }
602
+ }
603
+
604
+ export function Dictionaries_processField(self_, functions_, field_) {
605
+ {
606
+ const _1 = field_;
607
+ {
608
+ const _c = _1;
609
+ return ff_compiler_Syntax.Field(_c.at_, _c.name_, ff_compiler_Dictionaries.Dictionaries_processTerm(self_, functions_, field_.value_))
610
+ return
611
+ }
612
+ }
613
+ }
614
+
615
+ export function Dictionaries_makeDictionary(self_, at_, typeParameters_, typeArguments_, constraint_) {
616
+ const instantiationMap_ = ff_core_List.List_toMap(ff_core_List.List_zip(typeParameters_, typeArguments_), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
617
+ const unification_ = ff_compiler_Unification.make_(ff_core_List.Empty(), false);
618
+ const newGenerics_ = ff_core_List.List_map(constraint_.generics_, ((_w1) => {
619
+ return ff_compiler_Unification.Unification_instantiate(unification_, instantiationMap_, _w1)
620
+ }));
621
+ const firstType_ = (((_1) => {
622
+ {
623
+ if(_1.TConstructor) {
624
+ const t_ = _1;
625
+ return t_
626
+ return
627
+ }
628
+ }
629
+ {
630
+ if(_1.TVariable) {
631
+ const t_ = _1;
632
+ return ff_compiler_Dictionaries.fail_(t_.at_, " is still a unification variable")
633
+ return
634
+ }
635
+ }
636
+ }))(ff_core_List.List_grabFirst(newGenerics_));
637
+ const instance_ = ff_core_Option.Option_else(ff_core_Map.Map_get(self_.instances_, ff_compiler_Unification.InstanceKey(constraint_.name_, firstType_.name_), ff_compiler_Unification.ff_core_Ordering_Order$ff_compiler_Unification_InstanceKey), (() => {
638
+ throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(at_, ((("Missing instance " + firstType_.name_) + ": ") + constraint_.name_)), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
639
+ }));
640
+ const dictionaries_ = ff_core_List.List_map(instance_.constraints_, ((c_) => {
641
+ return ff_compiler_Dictionaries.Dictionaries_makeDictionary(self_, at_, instance_.generics_, firstType_.generics_, c_)
642
+ }));
643
+ return ff_compiler_Syntax.Dictionary(instance_.packagePair_, instance_.moduleName_, constraint_.name_, firstType_.name_, dictionaries_)
644
+ }
645
+
646
+ export async function Dictionaries_processModule$(self_, module_, otherModules_, $task) {
647
+ const environment_ = ff_compiler_Environment.make_(module_, otherModules_, true);
648
+ const functionSignatures_ = ff_core_List.List_toMap(ff_core_List.List_collect(ff_core_Map.Map_pairs(environment_.symbols_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ((_1) => {
649
+ {
650
+ const name_ = _1.first_;
651
+ const s_ = _1.second_;
652
+ const _guard1 = (!s_.isVariable_);
653
+ if(_guard1) {
654
+ return ff_core_Option.Some(ff_core_Pair.Pair(name_, s_.signature_))
655
+ return
656
+ }
657
+ }
658
+ {
659
+ return ff_core_Option.None()
660
+ return
661
+ }
662
+ })), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
663
+ const lets_ = ff_core_List.List_map(module_.lets_, ((_w1) => {
664
+ return ff_compiler_Dictionaries.Dictionaries_processLetDefinition(self_, functionSignatures_, _w1)
665
+ }));
666
+ const functions_ = ff_core_List.List_map(module_.functions_, ((_w1) => {
667
+ return ff_compiler_Dictionaries.Dictionaries_processFunctionDefinition(self_, functionSignatures_, _w1)
668
+ }));
669
+ const extends_ = ff_core_List.List_map(module_.extends_, ((_w1) => {
670
+ return ff_compiler_Dictionaries.Dictionaries_processExtendDefinition(self_, functionSignatures_, _w1)
671
+ }));
672
+ const instances_ = ff_core_List.List_map(module_.instances_, ((_w1) => {
673
+ return ff_compiler_Dictionaries.Dictionaries_processInstanceDefinition(self_, functionSignatures_, _w1)
674
+ }));
675
+ {
676
+ const _1 = module_;
677
+ {
678
+ const _c = _1;
679
+ return ff_compiler_Syntax.Module(_c.file_, _c.packagePair_, _c.imports_, _c.types_, _c.traits_, instances_, extends_, lets_, functions_)
680
+ return
681
+ }
682
+ }
683
+ }
684
+
685
+ export async function Dictionaries_processLetDefinition$(self_, functions_, definition_, $task) {
686
+ {
687
+ const _1 = definition_;
688
+ {
689
+ const _c = _1;
690
+ return ff_compiler_Syntax.DLet(_c.at_, _c.name_, _c.variableType_, ff_compiler_Dictionaries.Dictionaries_processTerm(self_, functions_, definition_.value_))
691
+ return
692
+ }
693
+ }
694
+ }
695
+
696
+ export async function Dictionaries_processExtendDefinition$(self_, functions_, definition_, $task) {
697
+ {
698
+ const _1 = definition_;
699
+ {
700
+ const _c = _1;
701
+ return ff_compiler_Syntax.DExtend(_c.at_, _c.name_, _c.generics_, _c.constraints_, _c.type_, ff_core_List.List_map(definition_.methods_, ((_w1) => {
702
+ return ff_compiler_Dictionaries.Dictionaries_processFunctionDefinition(self_, functions_, _w1)
703
+ })))
704
+ return
705
+ }
706
+ }
707
+ }
708
+
709
+ export async function Dictionaries_processFunctionDefinition$(self_, functions_, definition_, $task) {
710
+ const instances_ = ff_compiler_Dictionaries.constraintsToInstances_(definition_.signature_.constraints_);
711
+ const self2_ = (((_c) => {
712
+ return ff_compiler_Dictionaries.Dictionaries(ff_core_Map.Map_addAll(self_.instances_, instances_, ff_compiler_Unification.ff_core_Ordering_Order$ff_compiler_Unification_InstanceKey))
713
+ }))(self_);
714
+ {
715
+ const _1 = definition_;
716
+ {
717
+ const _c = _1;
718
+ return ff_compiler_Syntax.DFunction(_c.at_, _c.signature_, ff_compiler_Syntax.Target_mapFirefly(definition_.body_, ((_w1) => {
719
+ return ff_compiler_Dictionaries.Dictionaries_processLambda(self2_, functions_, _w1)
720
+ })))
721
+ return
722
+ }
723
+ }
724
+ }
725
+
726
+ export async function Dictionaries_processInstanceDefinition$(self_, functions_, definition_, $task) {
727
+ const instances_ = ff_compiler_Dictionaries.constraintsToInstances_(definition_.constraints_);
728
+ const self2_ = (((_c) => {
729
+ return ff_compiler_Dictionaries.Dictionaries(ff_core_Map.Map_addAll(self_.instances_, instances_, ff_compiler_Unification.ff_core_Ordering_Order$ff_compiler_Unification_InstanceKey))
730
+ }))(self_);
731
+ {
732
+ const _1 = definition_;
733
+ {
734
+ const _c = _1;
735
+ return ff_compiler_Syntax.DInstance(_c.at_, _c.generics_, _c.constraints_, _c.traitName_, _c.typeArguments_, _c.generatorArguments_, ff_core_List.List_map(definition_.methods_, ((_w1) => {
736
+ return ff_compiler_Dictionaries.Dictionaries_processFunctionDefinition(self2_, functions_, _w1)
737
+ })), _c.derived_)
738
+ return
739
+ }
740
+ }
741
+ }
742
+
743
+ export async function Dictionaries_processLambda$(self_, functions_, definition_, $task) {
744
+ {
745
+ const _1 = definition_;
746
+ {
747
+ const _c = _1;
748
+ return ff_compiler_Syntax.Lambda(_c.at_, _c.effect_, ff_core_List.List_map(definition_.cases_, ((case_) => {
749
+ {
750
+ const _1 = case_;
751
+ {
752
+ const _c = _1;
753
+ return ff_compiler_Syntax.MatchCase(_c.at_, _c.patterns_, ff_core_List.List_map(case_.guards_, ((g_) => {
754
+ {
755
+ const _1 = g_;
756
+ {
757
+ const _c = _1;
758
+ return ff_compiler_Syntax.MatchGuard(_c.at_, ff_compiler_Dictionaries.Dictionaries_processTerm(self_, functions_, g_.term_), _c.pattern_)
759
+ return
760
+ }
761
+ }
762
+ })), ff_compiler_Dictionaries.Dictionaries_processTerm(self_, functions_, case_.body_))
763
+ return
764
+ }
765
+ }
766
+ })))
767
+ return
768
+ }
769
+ }
770
+ }
771
+
772
+ export async function Dictionaries_processTerm$(self_, functions_, term_, $task) {
773
+ {
774
+ const _1 = term_;
775
+ {
776
+ if(_1.EString) {
777
+ return term_
778
+ return
779
+ }
780
+ }
781
+ {
782
+ if(_1.EChar) {
783
+ return term_
784
+ return
785
+ }
786
+ }
787
+ {
788
+ if(_1.EInt) {
789
+ return term_
790
+ return
791
+ }
792
+ }
793
+ {
794
+ if(_1.EFloat) {
795
+ return term_
796
+ return
797
+ }
798
+ }
799
+ {
800
+ if(_1.EVariable) {
801
+ return term_
802
+ return
803
+ }
804
+ }
805
+ {
806
+ if(_1.EField) {
807
+ const e_ = _1;
808
+ {
809
+ const _1 = e_;
810
+ {
811
+ const _c = _1;
812
+ return ff_compiler_Syntax.EField(_c.at_, _c.newtype_, ff_compiler_Dictionaries.Dictionaries_processTerm(self_, functions_, e_.record_), _c.field_)
813
+ return
814
+ }
815
+ }
816
+ return
817
+ }
818
+ }
819
+ {
820
+ if(_1.EWildcard) {
821
+ const e_ = _1;
822
+ return term_
823
+ return
824
+ }
825
+ }
826
+ {
827
+ if(_1.EList) {
828
+ const e_ = _1;
829
+ {
830
+ const _1 = e_;
831
+ {
832
+ const _c = _1;
833
+ return ff_compiler_Syntax.EList(_c.at_, _c.elementType_, ff_core_List.List_map(e_.items_, ((_1) => {
834
+ {
835
+ const item_ = _1.first_;
836
+ const b_ = _1.second_;
837
+ return ff_core_Pair.Pair(ff_compiler_Dictionaries.Dictionaries_processTerm(self_, functions_, item_), b_)
838
+ return
839
+ }
840
+ })))
841
+ return
842
+ }
843
+ }
844
+ return
845
+ }
846
+ }
847
+ {
848
+ if(_1.ESequential) {
849
+ const e_ = _1;
850
+ {
851
+ const _1 = e_;
852
+ {
853
+ const _c = _1;
854
+ return ff_compiler_Syntax.ESequential(_c.at_, ff_compiler_Dictionaries.Dictionaries_processTerm(self_, functions_, e_.before_), ff_compiler_Dictionaries.Dictionaries_processTerm(self_, functions_, e_.after_))
855
+ return
856
+ }
857
+ }
858
+ return
859
+ }
860
+ }
861
+ {
862
+ if(_1.ELet) {
863
+ const e_ = _1;
864
+ const newFunctions_ = ff_core_Map.Map_remove(functions_, e_.name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
865
+ {
866
+ const _1 = e_;
867
+ {
868
+ const _c = _1;
869
+ return ff_compiler_Syntax.ELet(_c.at_, _c.mutable_, _c.name_, _c.valueType_, ff_compiler_Dictionaries.Dictionaries_processTerm(self_, functions_, e_.value_), ff_compiler_Dictionaries.Dictionaries_processTerm(self_, newFunctions_, e_.body_))
870
+ return
871
+ }
872
+ }
873
+ return
874
+ }
875
+ }
876
+ {
877
+ if(_1.ELambda) {
878
+ const e_ = _1;
879
+ {
880
+ const _1 = e_;
881
+ {
882
+ const _c = _1;
883
+ return ff_compiler_Syntax.ELambda(_c.at_, ff_compiler_Dictionaries.Dictionaries_processLambda(self_, functions_, e_.lambda_))
884
+ return
885
+ }
886
+ }
887
+ return
888
+ }
889
+ }
890
+ {
891
+ if(_1.EVariant) {
892
+ const e_ = _1;
893
+ {
894
+ const _1 = e_;
895
+ {
896
+ const _c = _1;
897
+ return ff_compiler_Syntax.EVariant(_c.at_, _c.name_, _c.typeArguments_, ff_core_Option.Option_map(e_.arguments_, ((_w1) => {
898
+ return ff_core_List.List_map(_w1, ((_w1) => {
899
+ return ff_compiler_Dictionaries.Dictionaries_processArgument(self_, functions_, _w1)
900
+ }))
901
+ })))
902
+ return
903
+ }
904
+ }
905
+ return
906
+ }
907
+ }
908
+ {
909
+ if(_1.EVariantIs) {
910
+ const e_ = _1;
911
+ return term_
912
+ return
913
+ }
914
+ }
915
+ {
916
+ if(_1.ECopy) {
917
+ const e_ = _1;
918
+ {
919
+ const _1 = e_;
920
+ {
921
+ const _c = _1;
922
+ return ff_compiler_Syntax.ECopy(_c.at_, _c.name_, ff_compiler_Dictionaries.Dictionaries_processTerm(self_, functions_, e_.record_), ff_core_List.List_map(e_.arguments_, ((_w1) => {
923
+ return ff_compiler_Dictionaries.Dictionaries_processField(self_, functions_, _w1)
924
+ })))
925
+ return
926
+ }
927
+ }
928
+ return
929
+ }
930
+ }
931
+ {
932
+ if(_1.EPipe) {
933
+ const e_ = _1;
934
+ {
935
+ const _1 = e_;
936
+ {
937
+ const _c = _1;
938
+ return ff_compiler_Syntax.EPipe(_c.at_, ff_compiler_Dictionaries.Dictionaries_processTerm(self_, functions_, e_.value_), _c.effect_, ff_compiler_Dictionaries.Dictionaries_processTerm(self_, functions_, e_.function_))
939
+ return
940
+ }
941
+ }
942
+ return
943
+ }
944
+ }
945
+ {
946
+ if(_1.ECall) {
947
+ const at_ = _1.at_;
948
+ if(_1.target_.StaticCall) {
949
+ const target_ = _1.target_;
950
+ const effect_ = _1.effect_;
951
+ const typeArguments_ = _1.typeArguments_;
952
+ const arguments_ = _1.arguments_;
953
+ const _guard1 = ff_core_Map.Map_get(functions_, target_.name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
954
+ if(_guard1.Some) {
955
+ const signature_ = _guard1.value_;
956
+ const dictionaries_ = ff_core_List.List_map(signature_.constraints_, ((_w1) => {
957
+ return ff_compiler_Dictionaries.Dictionaries_makeDictionary(self_, at_, signature_.generics_, typeArguments_, _w1)
958
+ }));
959
+ return ff_compiler_Syntax.ECall(at_, (((_c) => {
960
+ return ff_compiler_Syntax.StaticCall(_c.name_, _c.tailCall_, _c.instanceCall_)
961
+ }))(target_), effect_, typeArguments_, ff_core_List.List_map(arguments_, ((_w1) => {
962
+ return ff_compiler_Dictionaries.Dictionaries_processArgument(self_, functions_, _w1)
963
+ })), dictionaries_)
964
+ return
965
+ }
966
+ }
967
+ }
968
+ }
969
+ {
970
+ if(_1.ECall) {
971
+ const e_ = _1;
972
+ const target_ = (((_1) => {
973
+ {
974
+ if(_1.DynamicCall) {
975
+ const call_ = _1;
976
+ {
977
+ const _1 = call_;
978
+ {
979
+ const _c = _1;
980
+ return ff_compiler_Syntax.DynamicCall(ff_compiler_Dictionaries.Dictionaries_processTerm(self_, functions_, call_.function_), _c.tailCall_)
981
+ return
982
+ }
983
+ }
984
+ return
985
+ }
986
+ }
987
+ {
988
+ if(_1.StaticCall) {
989
+ return e_.target_
990
+ return
991
+ }
992
+ }
993
+ }))(e_.target_);
994
+ {
995
+ const _1 = e_;
996
+ {
997
+ const _c = _1;
998
+ return ff_compiler_Syntax.ECall(_c.at_, target_, _c.effect_, _c.typeArguments_, ff_core_List.List_map(e_.arguments_, ((_w1) => {
999
+ return ff_compiler_Dictionaries.Dictionaries_processArgument(self_, functions_, _w1)
1000
+ })), _c.dictionaries_)
1001
+ return
1002
+ }
1003
+ }
1004
+ return
1005
+ }
1006
+ }
1007
+ {
1008
+ if(_1.ERecord) {
1009
+ const e_ = _1;
1010
+ {
1011
+ const _1 = e_;
1012
+ {
1013
+ const _c = _1;
1014
+ return ff_compiler_Syntax.ERecord(_c.at_, ff_core_List.List_map(e_.fields_, ((_w1) => {
1015
+ return ff_compiler_Dictionaries.Dictionaries_processField(self_, functions_, _w1)
1016
+ })))
1017
+ return
1018
+ }
1019
+ }
1020
+ return
1021
+ }
1022
+ }
1023
+ {
1024
+ if(_1.EFunctions) {
1025
+ const e_ = _1;
1026
+ const newFunctions_ = ff_core_Map.Map_addAll(functions_, ff_core_List.List_toMap(ff_core_List.List_map(e_.functions_, ((f_) => {
1027
+ return ff_core_Pair.Pair(f_.signature_.name_, f_.signature_)
1028
+ })), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
1029
+ {
1030
+ const _1 = e_;
1031
+ {
1032
+ const _c = _1;
1033
+ return ff_compiler_Syntax.EFunctions(_c.at_, ff_core_List.List_map(e_.functions_, ((_w1) => {
1034
+ return ff_compiler_Dictionaries.Dictionaries_processFunctionDefinition(self_, newFunctions_, _w1)
1035
+ })), ff_compiler_Dictionaries.Dictionaries_processTerm(self_, newFunctions_, e_.body_))
1036
+ return
1037
+ }
1038
+ }
1039
+ return
1040
+ }
1041
+ }
1042
+ {
1043
+ if(_1.EAssign) {
1044
+ const e_ = _1;
1045
+ {
1046
+ const _1 = e_;
1047
+ {
1048
+ const _c = _1;
1049
+ return ff_compiler_Syntax.EAssign(_c.at_, _c.operator_, _c.variable_, ff_compiler_Dictionaries.Dictionaries_processTerm(self_, functions_, e_.value_))
1050
+ return
1051
+ }
1052
+ }
1053
+ return
1054
+ }
1055
+ }
1056
+ {
1057
+ if(_1.EAssignField) {
1058
+ const e_ = _1;
1059
+ {
1060
+ const _1 = e_;
1061
+ {
1062
+ const _c = _1;
1063
+ return ff_compiler_Syntax.EAssignField(_c.at_, _c.operator_, ff_compiler_Dictionaries.Dictionaries_processTerm(self_, functions_, e_.record_), _c.field_, ff_compiler_Dictionaries.Dictionaries_processTerm(self_, functions_, e_.value_))
1064
+ return
1065
+ }
1066
+ }
1067
+ return
1068
+ }
1069
+ }
1070
+ }
1071
+ }
1072
+
1073
+ export async function Dictionaries_processArgument$(self_, functions_, argument_, $task) {
1074
+ {
1075
+ const _1 = argument_;
1076
+ {
1077
+ const _c = _1;
1078
+ return ff_compiler_Syntax.Argument(_c.at_, _c.name_, ff_compiler_Dictionaries.Dictionaries_processTerm(self_, functions_, argument_.value_))
1079
+ return
1080
+ }
1081
+ }
1082
+ }
1083
+
1084
+ export async function Dictionaries_processField$(self_, functions_, field_, $task) {
1085
+ {
1086
+ const _1 = field_;
1087
+ {
1088
+ const _c = _1;
1089
+ return ff_compiler_Syntax.Field(_c.at_, _c.name_, ff_compiler_Dictionaries.Dictionaries_processTerm(self_, functions_, field_.value_))
1090
+ return
1091
+ }
1092
+ }
1093
+ }
1094
+
1095
+ export async function Dictionaries_makeDictionary$(self_, at_, typeParameters_, typeArguments_, constraint_, $task) {
1096
+ const instantiationMap_ = ff_core_List.List_toMap(ff_core_List.List_zip(typeParameters_, typeArguments_), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
1097
+ const unification_ = ff_compiler_Unification.make_(ff_core_List.Empty(), false);
1098
+ const newGenerics_ = ff_core_List.List_map(constraint_.generics_, ((_w1) => {
1099
+ return ff_compiler_Unification.Unification_instantiate(unification_, instantiationMap_, _w1)
1100
+ }));
1101
+ const firstType_ = (((_1) => {
1102
+ {
1103
+ if(_1.TConstructor) {
1104
+ const t_ = _1;
1105
+ return t_
1106
+ return
1107
+ }
1108
+ }
1109
+ {
1110
+ if(_1.TVariable) {
1111
+ const t_ = _1;
1112
+ return ff_compiler_Dictionaries.fail_(t_.at_, " is still a unification variable")
1113
+ return
1114
+ }
1115
+ }
1116
+ }))(ff_core_List.List_grabFirst(newGenerics_));
1117
+ const instance_ = ff_core_Option.Option_else(ff_core_Map.Map_get(self_.instances_, ff_compiler_Unification.InstanceKey(constraint_.name_, firstType_.name_), ff_compiler_Unification.ff_core_Ordering_Order$ff_compiler_Unification_InstanceKey), (() => {
1118
+ throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(at_, ((("Missing instance " + firstType_.name_) + ": ") + constraint_.name_)), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
1119
+ }));
1120
+ const dictionaries_ = ff_core_List.List_map(instance_.constraints_, ((c_) => {
1121
+ return ff_compiler_Dictionaries.Dictionaries_makeDictionary(self_, at_, instance_.generics_, firstType_.generics_, c_)
1122
+ }));
1123
+ return ff_compiler_Syntax.Dictionary(instance_.packagePair_, instance_.moduleName_, constraint_.name_, firstType_.name_, dictionaries_)
1124
+ }
1125
+
1126
+ export const ff_core_Any_HasAnyTag$ff_compiler_Dictionaries_Dictionaries = {
1127
+ anyTag_() {
1128
+ return ff_core_Any.internalAnyTag_((("ff:compiler/Dictionaries.Dictionaries" + "[") + "]"))
1129
+ },
1130
+ async anyTag_$($task) {
1131
+ return ff_core_Any.internalAnyTag_((("ff:compiler/Dictionaries.Dictionaries" + "[") + "]"))
1132
+ }
1133
+ };
1134
+
1135
+ export const ff_core_Show_Show$ff_compiler_Dictionaries_Dictionaries = {
1136
+ show_(value_) {
1137
+ {
1138
+ const value_a = value_;
1139
+ {
1140
+ const z_ = value_a;
1141
+ return ((("Dictionaries" + "(") + ff_core_Map.ff_core_Show_Show$ff_core_Map_Map(ff_compiler_Unification.ff_core_Show_Show$ff_compiler_Unification_InstanceKey, ff_compiler_Unification.ff_core_Ordering_Order$ff_compiler_Unification_InstanceKey, ff_compiler_Unification.ff_core_Show_Show$ff_compiler_Unification_InstanceValue).show_(z_.instances_)) + ")")
1142
+ return
1143
+ }
1144
+ }
1145
+ },
1146
+ async show_$(value_, $task) {
1147
+ {
1148
+ const value_a = value_;
1149
+ {
1150
+ const z_ = value_a;
1151
+ return ((("Dictionaries" + "(") + ff_core_Map.ff_core_Show_Show$ff_core_Map_Map(ff_compiler_Unification.ff_core_Show_Show$ff_compiler_Unification_InstanceKey, ff_compiler_Unification.ff_core_Ordering_Order$ff_compiler_Unification_InstanceKey, ff_compiler_Unification.ff_core_Show_Show$ff_compiler_Unification_InstanceValue).show_(z_.instances_)) + ")")
1152
+ return
1153
+ }
1154
+ }
1155
+ }
1156
+ };
1157
+
1158
+ export const ff_core_Equal_Equal$ff_compiler_Dictionaries_Dictionaries = {
1159
+ equals_(x_, y_) {
1160
+ {
1161
+ const x_a = x_;
1162
+ const y_a = y_;
1163
+ {
1164
+ const _guard1 = (x_ === y_);
1165
+ if(_guard1) {
1166
+ return true
1167
+ return
1168
+ }
1169
+ }
1170
+ {
1171
+ return ff_core_Map.ff_core_Equal_Equal$ff_core_Map_Map(ff_compiler_Unification.ff_core_Equal_Equal$ff_compiler_Unification_InstanceKey, ff_compiler_Unification.ff_core_Ordering_Order$ff_compiler_Unification_InstanceKey, ff_compiler_Unification.ff_core_Equal_Equal$ff_compiler_Unification_InstanceValue).equals_(x_.instances_, y_.instances_)
1172
+ return
1173
+ }
1174
+ }
1175
+ },
1176
+ async equals_$(x_, y_, $task) {
1177
+ {
1178
+ const x_a = x_;
1179
+ const y_a = y_;
1180
+ {
1181
+ const _guard1 = (x_ === y_);
1182
+ if(_guard1) {
1183
+ return true
1184
+ return
1185
+ }
1186
+ }
1187
+ {
1188
+ return ff_core_Map.ff_core_Equal_Equal$ff_core_Map_Map(ff_compiler_Unification.ff_core_Equal_Equal$ff_compiler_Unification_InstanceKey, ff_compiler_Unification.ff_core_Ordering_Order$ff_compiler_Unification_InstanceKey, ff_compiler_Unification.ff_core_Equal_Equal$ff_compiler_Unification_InstanceValue).equals_(x_.instances_, y_.instances_)
1189
+ return
1190
+ }
1191
+ }
1192
+ }
1193
+ };
1194
+
1195
+ export const ff_core_Ordering_Order$ff_compiler_Dictionaries_Dictionaries = {
1196
+ compare_(x_, y_) {
1197
+ {
1198
+ const x_a = x_;
1199
+ const y_a = y_;
1200
+ {
1201
+ const _guard1 = (x_ === y_);
1202
+ if(_guard1) {
1203
+ return ff_core_Ordering.OrderingSame()
1204
+ return
1205
+ }
1206
+ }
1207
+ {
1208
+ const instancesOrdering_ = ff_core_Map.ff_core_Ordering_Order$ff_core_Map_Map(ff_compiler_Unification.ff_core_Ordering_Order$ff_compiler_Unification_InstanceKey, ff_compiler_Unification.ff_core_Ordering_Order$ff_compiler_Unification_InstanceValue).compare_(x_.instances_, y_.instances_);
1209
+ if((instancesOrdering_ !== ff_core_Ordering.OrderingSame())) {
1210
+ return instancesOrdering_
1211
+ } else {
1212
+ return ff_core_Ordering.OrderingSame()
1213
+ }
1214
+ return
1215
+ }
1216
+ }
1217
+ },
1218
+ async compare_$(x_, y_, $task) {
1219
+ {
1220
+ const x_a = x_;
1221
+ const y_a = y_;
1222
+ {
1223
+ const _guard1 = (x_ === y_);
1224
+ if(_guard1) {
1225
+ return ff_core_Ordering.OrderingSame()
1226
+ return
1227
+ }
1228
+ }
1229
+ {
1230
+ const instancesOrdering_ = ff_core_Map.ff_core_Ordering_Order$ff_core_Map_Map(ff_compiler_Unification.ff_core_Ordering_Order$ff_compiler_Unification_InstanceKey, ff_compiler_Unification.ff_core_Ordering_Order$ff_compiler_Unification_InstanceValue).compare_(x_.instances_, y_.instances_);
1231
+ if((instancesOrdering_ !== ff_core_Ordering.OrderingSame())) {
1232
+ return instancesOrdering_
1233
+ } else {
1234
+ return ff_core_Ordering.OrderingSame()
1235
+ }
1236
+ return
1237
+ }
1238
+ }
1239
+ }
1240
+ };
1241
+
1242
+ export const ff_core_Serializable_Serializable$ff_compiler_Dictionaries_Dictionaries = {
1243
+ serializeUsing_(serialization_, value_) {
1244
+ {
1245
+ const serialization_a = serialization_;
1246
+ const value_a = value_;
1247
+ {
1248
+ const v_ = value_a;
1249
+ serialization_.checksum_ = ff_core_Int.Int_bitOr(((31 * serialization_.checksum_) + 37), 0);
1250
+ ff_core_Buffer.Buffer_setUint8(serialization_.buffer_, serialization_.offset_, 0);
1251
+ serialization_.offset_ += 1;
1252
+ ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_Map_Map(ff_compiler_Unification.ff_core_Serializable_Serializable$ff_compiler_Unification_InstanceKey, ff_compiler_Unification.ff_core_Ordering_Order$ff_compiler_Unification_InstanceKey, ff_compiler_Unification.ff_core_Serializable_Serializable$ff_compiler_Unification_InstanceValue).serializeUsing_(serialization_, v_.instances_)
1253
+ return
1254
+ }
1255
+ }
1256
+ },
1257
+ deserializeUsing_(serialization_) {
1258
+ const variantIndex_ = ff_core_Buffer.Buffer_grabUint8(serialization_.buffer_, serialization_.offset_);
1259
+ serialization_.offset_ += 1;
1260
+ {
1261
+ const _1 = variantIndex_;
1262
+ {
1263
+ if(_1 == 0) {
1264
+ serialization_.checksum_ = ff_core_Int.Int_bitOr(((31 * serialization_.checksum_) + 37), 0);
1265
+ return ff_compiler_Dictionaries.Dictionaries(ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_Map_Map(ff_compiler_Unification.ff_core_Serializable_Serializable$ff_compiler_Unification_InstanceKey, ff_compiler_Unification.ff_core_Ordering_Order$ff_compiler_Unification_InstanceKey, ff_compiler_Unification.ff_core_Serializable_Serializable$ff_compiler_Unification_InstanceValue).deserializeUsing_(serialization_))
1266
+ return
1267
+ }
1268
+ }
1269
+ {
1270
+ throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_core_Serializable.DeserializationChecksumException(), ff_core_Serializable.ff_core_Any_HasAnyTag$ff_core_Serializable_DeserializationChecksumException)})
1271
+ return
1272
+ }
1273
+ }
1274
+ },
1275
+ async serializeUsing_$(serialization_, value_, $task) {
1276
+ {
1277
+ const serialization_a = serialization_;
1278
+ const value_a = value_;
1279
+ {
1280
+ const v_ = value_a;
1281
+ serialization_.checksum_ = ff_core_Int.Int_bitOr(((31 * serialization_.checksum_) + 37), 0);
1282
+ ff_core_Buffer.Buffer_setUint8(serialization_.buffer_, serialization_.offset_, 0);
1283
+ serialization_.offset_ += 1;
1284
+ ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_Map_Map(ff_compiler_Unification.ff_core_Serializable_Serializable$ff_compiler_Unification_InstanceKey, ff_compiler_Unification.ff_core_Ordering_Order$ff_compiler_Unification_InstanceKey, ff_compiler_Unification.ff_core_Serializable_Serializable$ff_compiler_Unification_InstanceValue).serializeUsing_(serialization_, v_.instances_)
1285
+ return
1286
+ }
1287
+ }
1288
+ },
1289
+ async deserializeUsing_$(serialization_, $task) {
1290
+ const variantIndex_ = ff_core_Buffer.Buffer_grabUint8(serialization_.buffer_, serialization_.offset_);
1291
+ serialization_.offset_ += 1;
1292
+ {
1293
+ const _1 = variantIndex_;
1294
+ {
1295
+ if(_1 == 0) {
1296
+ serialization_.checksum_ = ff_core_Int.Int_bitOr(((31 * serialization_.checksum_) + 37), 0);
1297
+ return ff_compiler_Dictionaries.Dictionaries(ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_Map_Map(ff_compiler_Unification.ff_core_Serializable_Serializable$ff_compiler_Unification_InstanceKey, ff_compiler_Unification.ff_core_Ordering_Order$ff_compiler_Unification_InstanceKey, ff_compiler_Unification.ff_core_Serializable_Serializable$ff_compiler_Unification_InstanceValue).deserializeUsing_(serialization_))
1298
+ return
1299
+ }
1300
+ }
1301
+ {
1302
+ throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_core_Serializable.DeserializationChecksumException(), ff_core_Serializable.ff_core_Any_HasAnyTag$ff_core_Serializable_DeserializationChecksumException)})
1303
+ return
1304
+ }
1305
+ }
1306
+ }
1307
+ };
1308
+
1309
+