firefly-compiler 0.4.6 → 0.4.8

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