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,1752 +1,1762 @@
1
-
2
-
3
- import * as ff_compiler_Unification from "../../ff/compiler/Unification.mjs"
4
-
5
- import * as ff_compiler_Inference from "../../ff/compiler/Inference.mjs"
6
-
7
- import * as ff_compiler_Syntax from "../../ff/compiler/Syntax.mjs"
8
-
9
- import * as ff_core_Any from "../../ff/core/Any.mjs"
10
-
11
- import * as ff_core_Array from "../../ff/core/Array.mjs"
12
-
13
- import * as ff_core_AssetSystem from "../../ff/core/AssetSystem.mjs"
14
-
15
- import * as ff_core_Atomic from "../../ff/core/Atomic.mjs"
16
-
17
- import * as ff_core_Bool from "../../ff/core/Bool.mjs"
18
-
19
- import * as ff_core_Box from "../../ff/core/Box.mjs"
20
-
21
- import * as ff_core_BrowserSystem from "../../ff/core/BrowserSystem.mjs"
22
-
23
- import * as ff_core_Buffer from "../../ff/core/Buffer.mjs"
24
-
25
- import * as ff_core_BuildSystem from "../../ff/core/BuildSystem.mjs"
26
-
27
- import * as ff_core_Channel from "../../ff/core/Channel.mjs"
28
-
29
- import * as ff_core_Char from "../../ff/core/Char.mjs"
30
-
31
- import * as ff_core_Core from "../../ff/core/Core.mjs"
32
-
33
- import * as ff_core_Duration from "../../ff/core/Duration.mjs"
34
-
35
- import * as ff_core_Equal from "../../ff/core/Equal.mjs"
36
-
37
- import * as ff_core_Error from "../../ff/core/Error.mjs"
38
-
39
- import * as ff_core_FileHandle from "../../ff/core/FileHandle.mjs"
40
-
41
- import * as ff_core_Float from "../../ff/core/Float.mjs"
42
-
43
- import * as ff_core_HttpClient from "../../ff/core/HttpClient.mjs"
44
-
45
- import * as ff_core_Instant from "../../ff/core/Instant.mjs"
46
-
47
- import * as ff_core_Int from "../../ff/core/Int.mjs"
48
-
49
- import * as ff_core_IntMap from "../../ff/core/IntMap.mjs"
50
-
51
- import * as ff_core_JsSystem from "../../ff/core/JsSystem.mjs"
52
-
53
- import * as ff_core_JsValue from "../../ff/core/JsValue.mjs"
54
-
55
- import * as ff_core_List from "../../ff/core/List.mjs"
56
-
57
- import * as ff_core_Lock from "../../ff/core/Lock.mjs"
58
-
59
- import * as ff_core_Log from "../../ff/core/Log.mjs"
60
-
61
- import * as ff_core_Map from "../../ff/core/Map.mjs"
62
-
63
- import * as ff_core_NodeSystem from "../../ff/core/NodeSystem.mjs"
64
-
65
- import * as ff_core_Nothing from "../../ff/core/Nothing.mjs"
66
-
67
- import * as ff_core_Option from "../../ff/core/Option.mjs"
68
-
69
- import * as ff_core_Ordering from "../../ff/core/Ordering.mjs"
70
-
71
- import * as ff_core_Pair from "../../ff/core/Pair.mjs"
72
-
73
- import * as ff_core_Path from "../../ff/core/Path.mjs"
74
-
75
- import * as ff_core_Serializable from "../../ff/core/Serializable.mjs"
76
-
77
- import * as ff_core_Set from "../../ff/core/Set.mjs"
78
-
79
- import * as ff_core_Show from "../../ff/core/Show.mjs"
80
-
81
- import * as ff_core_SourceLocation from "../../ff/core/SourceLocation.mjs"
82
-
83
- import * as ff_core_Stack from "../../ff/core/Stack.mjs"
84
-
85
- import * as ff_core_Stream from "../../ff/core/Stream.mjs"
86
-
87
- import * as ff_core_String from "../../ff/core/String.mjs"
88
-
89
- import * as ff_core_StringMap from "../../ff/core/StringMap.mjs"
90
-
91
- import * as ff_core_Task from "../../ff/core/Task.mjs"
92
-
93
- import * as ff_core_Try from "../../ff/core/Try.mjs"
94
-
95
- import * as ff_core_Unit from "../../ff/core/Unit.mjs"
96
-
97
- // type Unification
98
- export function Unification(substitution_, constraints_, nextUnificationVariableIndex_, instances_, affects_, attemptFixes_) {
99
- return {substitution_, constraints_, nextUnificationVariableIndex_, instances_, affects_, attemptFixes_};
100
- }
101
-
102
- // type ConstraintGenerics
103
- export function ConstraintGenerics(at_, generics_) {
104
- return {at_, generics_};
105
- }
106
-
107
- // type InstanceKey
108
- export function InstanceKey(traitName_, typeName_) {
109
- return {traitName_, typeName_};
110
- }
111
-
112
- // type InstanceValue
113
- export function InstanceValue(generics_, constraints_, packagePair_, moduleName_, traitName_, typeArguments_) {
114
- return {generics_, constraints_, packagePair_, moduleName_, traitName_, typeArguments_};
115
- }
116
-
117
-
118
-
119
- export function fail_(at_, message_) {
120
- throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(at_, message_), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
121
- }
122
-
123
- export function make_(modules_, attemptFixes_) {
124
- return ff_compiler_Unification.Unification(ff_core_Map.empty_(), ff_core_Map.empty_(), 3, ff_core_List.List_toMap(ff_core_List.List_flatMap(modules_, ((module_) => {
125
- const moduleName_ = ff_core_String.String_dropLast(module_.file_, ff_core_String.String_size(".ff"));
126
- return ff_core_List.List_map(module_.instances_, ((definition_) => {
127
- const typeName_ = (((_1) => {
128
- {
129
- if(_1.TConstructor) {
130
- const name_ = _1.name_;
131
- return name_
132
- return
133
- }
134
- }
135
- {
136
- if(_1.TVariable) {
137
- const i_ = _1.index_;
138
- return ff_compiler_Unification.fail_(definition_.at_, ("Unexpected unification variable: $" + i_))
139
- return
140
- }
141
- }
142
- }))(ff_core_List.List_grabFirst(definition_.typeArguments_));
143
- return ff_core_Pair.Pair(ff_compiler_Unification.InstanceKey(definition_.traitName_, typeName_), ff_compiler_Unification.InstanceValue(definition_.generics_, definition_.constraints_, module_.packagePair_, moduleName_, definition_.traitName_, definition_.typeArguments_))
144
- }))
145
- })), ff_compiler_Unification.ff_core_Ordering_Order$ff_compiler_Unification_InstanceKey), ff_core_List.List_toMap(ff_core_List.Empty(), ff_core_Ordering.ff_core_Ordering_Order$ff_core_Int_Int), attemptFixes_)
146
- }
147
-
148
- export async function fail_$(at_, message_, $task) {
149
- throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(at_, message_), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
150
- }
151
-
152
- export async function make_$(modules_, attemptFixes_, $task) {
153
- return ff_compiler_Unification.Unification(ff_core_Map.empty_(), ff_core_Map.empty_(), 3, ff_core_List.List_toMap(ff_core_List.List_flatMap(modules_, ((module_) => {
154
- const moduleName_ = ff_core_String.String_dropLast(module_.file_, ff_core_String.String_size(".ff"));
155
- return ff_core_List.List_map(module_.instances_, ((definition_) => {
156
- const typeName_ = (((_1) => {
157
- {
158
- if(_1.TConstructor) {
159
- const name_ = _1.name_;
160
- return name_
161
- return
162
- }
163
- }
164
- {
165
- if(_1.TVariable) {
166
- const i_ = _1.index_;
167
- return ff_compiler_Unification.fail_(definition_.at_, ("Unexpected unification variable: $" + i_))
168
- return
169
- }
170
- }
171
- }))(ff_core_List.List_grabFirst(definition_.typeArguments_));
172
- return ff_core_Pair.Pair(ff_compiler_Unification.InstanceKey(definition_.traitName_, typeName_), ff_compiler_Unification.InstanceValue(definition_.generics_, definition_.constraints_, module_.packagePair_, moduleName_, definition_.traitName_, definition_.typeArguments_))
173
- }))
174
- })), ff_compiler_Unification.ff_core_Ordering_Order$ff_compiler_Unification_InstanceKey), ff_core_List.List_toMap(ff_core_List.Empty(), ff_core_Ordering.ff_core_Ordering_Order$ff_core_Int_Int), attemptFixes_)
175
- }
176
-
177
- export function Unification_withLocalInstances(self_, instances_, body_) {
178
- const oldInstances_ = self_.instances_;
179
- self_.instances_ = ff_core_Map.Map_addAll(self_.instances_, instances_, ff_compiler_Unification.ff_core_Ordering_Order$ff_compiler_Unification_InstanceKey);
180
- try {
181
- return body_()
182
- } finally {
183
- self_.instances_ = oldInstances_
184
- }
185
- }
186
-
187
- export function Unification_freshUnificationVariable(self_, at_) {
188
- const result_ = ff_compiler_Syntax.TVariable(at_, self_.nextUnificationVariableIndex_);
189
- self_.nextUnificationVariableIndex_ += 3;
190
- return result_
191
- }
192
-
193
- export function Unification_instantiate(self_, instantiation_, type_) {
194
- {
195
- const self_a = self_;
196
- const instantiation_a = instantiation_;
197
- const type_a = type_;
198
- {
199
- if(type_a.TConstructor) {
200
- const at_ = type_a.at_;
201
- const name_ = type_a.name_;
202
- if(type_a.generics_.Empty) {
203
- {
204
- const _1 = ff_core_Map.Map_get(instantiation_, name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
205
- {
206
- if(_1.Some) {
207
- const t_ = _1.value_;
208
- return t_
209
- return
210
- }
211
- }
212
- {
213
- if(_1.None) {
214
- return type_
215
- return
216
- }
217
- }
218
- }
219
- return
220
- }
221
- }
222
- }
223
- {
224
- if(type_a.TConstructor) {
225
- const at_ = type_a.at_;
226
- const name_ = type_a.name_;
227
- const generics_ = type_a.generics_;
228
- return ff_compiler_Syntax.TConstructor(at_, name_, ff_core_List.List_map(generics_, ((_w1) => {
229
- return ff_compiler_Unification.Unification_instantiate(self_, instantiation_, _w1)
230
- })))
231
- return
232
- }
233
- }
234
- {
235
- if(type_a.TVariable) {
236
- const i_ = type_a.index_;
237
- const _guard1 = ff_compiler_Unification.Unification_get(self_, i_);
238
- if(_guard1.Some) {
239
- const t_ = _guard1.value_;
240
- return ff_compiler_Unification.Unification_instantiate(self_, instantiation_, t_)
241
- return
242
- }
243
- }
244
- }
245
- {
246
- if(type_a.TVariable) {
247
- const i_ = type_a.index_;
248
- return type_
249
- return
250
- }
251
- }
252
- }
253
- }
254
-
255
- export function Unification_instantiateConstraint(self_, instantiation_, constraint_) {
256
- {
257
- const self_a = self_;
258
- const instantiation_a = instantiation_;
259
- const constraint_a = constraint_;
260
- {
261
- const at_ = constraint_a.at_;
262
- const name_ = constraint_a.name_;
263
- const generics_ = constraint_a.generics_;
264
- return ff_compiler_Syntax.Constraint(at_, name_, ff_core_List.List_map(generics_, ((_w1) => {
265
- return ff_compiler_Unification.Unification_instantiate(self_, instantiation_, _w1)
266
- })))
267
- return
268
- }
269
- }
270
- }
271
-
272
- export function Unification_constrain(self_, at_, type_, constraintName_, generics_) {
273
- {
274
- const _1 = type_;
275
- {
276
- if(_1.TVariable) {
277
- const i_ = _1.index_;
278
- const _guard1 = ff_compiler_Unification.Unification_get(self_, i_);
279
- if(_guard1.Some) {
280
- const t_ = _guard1.value_;
281
- ff_compiler_Unification.Unification_constrain(self_, at_, t_, constraintName_, generics_)
282
- return
283
- }
284
- }
285
- }
286
- {
287
- if(_1.TVariable) {
288
- const i_ = _1.index_;
289
- {
290
- const _1 = ff_core_Map.Map_get(self_.constraints_, i_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_Int_Int);
291
- {
292
- if(_1.None) {
293
- self_.constraints_ = ff_core_Map.Map_add(self_.constraints_, i_, ff_core_List.List_toMap(ff_core_List.Link(ff_core_Pair.Pair(constraintName_, ff_compiler_Unification.ConstraintGenerics(at_, generics_)), ff_core_List.Empty()), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Ordering.ff_core_Ordering_Order$ff_core_Int_Int)
294
- return
295
- }
296
- }
297
- {
298
- if(_1.Some) {
299
- const map_ = _1.value_;
300
- {
301
- const _1 = ff_core_Map.Map_get(map_, constraintName_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
302
- {
303
- if(_1.None) {
304
- const newMap_ = ff_core_Map.Map_add(map_, constraintName_, ff_compiler_Unification.ConstraintGenerics(at_, generics_), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
305
- self_.constraints_ = ff_core_Map.Map_add(self_.constraints_, i_, newMap_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_Int_Int)
306
- return
307
- }
308
- }
309
- {
310
- if(_1.Some) {
311
- const generics2_ = _1.value_.generics_;
312
- ff_core_List.List_each(ff_core_List.List_zip(generics_, generics2_), ((_1) => {
313
- {
314
- const t1_ = _1.first_;
315
- const t2_ = _1.second_;
316
- ff_compiler_Unification.Unification_unify(self_, at_, t1_, t2_)
317
- return
318
- }
319
- }))
320
- return
321
- }
322
- }
323
- }
324
- return
325
- }
326
- }
327
- }
328
- return
329
- }
330
- }
331
- {
332
- if(_1.TConstructor) {
333
- const name_ = _1.name_;
334
- const generics2_ = _1.generics_;
335
- {
336
- const _1 = ff_core_Map.Map_get(self_.instances_, ff_compiler_Unification.InstanceKey(constraintName_, name_), ff_compiler_Unification.ff_core_Ordering_Order$ff_compiler_Unification_InstanceKey);
337
- {
338
- if(_1.None) {
339
- const g1_ = (ff_core_List.List_isEmpty(generics_)
340
- ? ""
341
- : "[...]");
342
- const g2_ = (ff_core_List.List_isEmpty(generics2_)
343
- ? ""
344
- : "[...]");
345
- if((!self_.attemptFixes_)) {
346
- throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(at_, ((((("No such instance: " + name_) + g2_) + ": ") + constraintName_) + g1_)), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
347
- }
348
- return
349
- }
350
- }
351
- {
352
- if(_1.Some) {
353
- const definition_ = _1.value_;
354
- const unificationVariables_ = ff_core_List.List_map(definition_.generics_, ((_) => {
355
- return ff_compiler_Unification.Unification_freshUnificationVariable(self_, at_)
356
- }));
357
- const instantiation_ = ff_core_List.List_toMap(ff_core_List.List_zip(definition_.generics_, unificationVariables_), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
358
- const traitType1_ = ff_compiler_Unification.Unification_instantiate(self_, instantiation_, ff_compiler_Syntax.TConstructor(at_, definition_.traitName_, definition_.typeArguments_));
359
- const traitType2_ = ff_compiler_Syntax.TConstructor(at_, constraintName_, ff_core_List.Link(type_, generics_));
360
- ff_compiler_Unification.Unification_unify(self_, at_, traitType1_, traitType2_);
361
- ff_core_List.List_each(definition_.constraints_, ((constraint_) => {
362
- {
363
- const _1 = ff_compiler_Unification.Unification_instantiateConstraint(self_, instantiation_, constraint_);
364
- {
365
- const constraintName_ = _1.name_;
366
- const newGenerics_ = _1.generics_;
367
- ff_compiler_Unification.Unification_constrain(self_, at_, ff_core_List.List_grabFirst(newGenerics_), constraintName_, ff_core_List.List_dropFirst(newGenerics_, 1))
368
- return
369
- }
370
- }
371
- }))
372
- return
373
- }
374
- }
375
- }
376
- return
377
- }
378
- }
379
- }
380
- }
381
-
382
- export function Unification_get(self_, index_) {
383
- return ff_core_Option.Option_map(ff_core_Map.Map_get(self_.substitution_, index_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_Int_Int), ((_1) => {
384
- {
385
- if(_1.TVariable) {
386
- const i_ = _1.index_;
387
- const _guard1 = ff_core_Map.Map_get(self_.substitution_, i_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_Int_Int);
388
- if(_guard1.Some) {
389
- const t_ = _guard1.value_;
390
- self_.substitution_ = ff_core_Map.Map_add(self_.substitution_, index_, t_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_Int_Int);
391
- return t_
392
- return
393
- }
394
- }
395
- }
396
- {
397
- const t_ = _1;
398
- return t_
399
- return
400
- }
401
- }))
402
- }
403
-
404
- export function Unification_substitute(self_, type_) {
405
- {
406
- const self_a = self_;
407
- const type_a = type_;
408
- {
409
- if(type_a.TVariable) {
410
- const i_ = type_a.index_;
411
- const _guard1 = ff_compiler_Unification.Unification_get(self_, i_);
412
- if(_guard1.Some) {
413
- const t_ = _guard1.value_;
414
- return ff_compiler_Unification.Unification_substitute(self_, t_)
415
- return
416
- }
417
- }
418
- }
419
- {
420
- if(type_a.TVariable) {
421
- return type_
422
- return
423
- }
424
- }
425
- {
426
- if(type_a.TConstructor) {
427
- const t_ = type_a;
428
- {
429
- const _1 = t_;
430
- {
431
- const _c = _1;
432
- return ff_compiler_Syntax.TConstructor(_c.at_, _c.name_, ff_core_List.List_map(t_.generics_, ((t_) => {
433
- return ff_compiler_Unification.Unification_substitute(self_, t_)
434
- })))
435
- return
436
- }
437
- }
438
- return
439
- }
440
- }
441
- }
442
- }
443
-
444
- export function Unification_unify(self_, at_, t1_, t2_) {
445
- {
446
- const self_a = self_;
447
- const at_a = at_;
448
- const t1_a = t1_;
449
- const t2_a = t2_;
450
- {
451
- if(t1_a.TVariable) {
452
- const i1_ = t1_a.index_;
453
- if(t2_a.TVariable) {
454
- const i2_ = t2_a.index_;
455
- const _guard1 = (i1_ === i2_);
456
- if(_guard1) {
457
-
458
- return
459
- }
460
- }
461
- }
462
- }
463
- {
464
- if(t1_a.TVariable) {
465
- const i_ = t1_a.index_;
466
- const _guard1 = ff_compiler_Unification.Unification_get(self_, i_);
467
- if(_guard1.Some) {
468
- const t_ = _guard1.value_;
469
- ff_compiler_Unification.Unification_unify(self_, at_, t_, t2_)
470
- return
471
- }
472
- }
473
- }
474
- {
475
- if(t2_a.TVariable) {
476
- const i_ = t2_a.index_;
477
- const _guard1 = ff_compiler_Unification.Unification_get(self_, i_);
478
- if(_guard1.Some) {
479
- const t_ = _guard1.value_;
480
- ff_compiler_Unification.Unification_unify(self_, at_, t1_, t_)
481
- return
482
- }
483
- }
484
- }
485
- {
486
- if(t1_a.TVariable) {
487
- const i_ = t1_a.index_;
488
- ff_compiler_Unification.Unification_bind(self_, at_, i_, t2_)
489
- return
490
- }
491
- }
492
- {
493
- if(t2_a.TVariable) {
494
- const i_ = t2_a.index_;
495
- ff_compiler_Unification.Unification_bind(self_, at_, i_, t1_)
496
- return
497
- }
498
- }
499
- {
500
- if(t1_a.TConstructor) {
501
- const name1_ = t1_a.name_;
502
- const generics1_ = t1_a.generics_;
503
- if(t2_a.TConstructor) {
504
- const name2_ = t2_a.name_;
505
- const generics2_ = t2_a.generics_;
506
- if(((name1_ !== name2_) || (ff_core_List.List_size(generics1_) !== ff_core_List.List_size(generics2_)))) {
507
- if((!self_.attemptFixes_)) {
508
- const t3_ = ff_compiler_Unification.Unification_substitute(self_, t1_);
509
- const t4_ = ff_compiler_Unification.Unification_substitute(self_, t2_);
510
- throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(at_, ((("Type mismatch: " + ff_compiler_Syntax.Type_show(t3_, ff_core_List.Link(t3_, ff_core_List.Link(t4_, ff_core_List.Empty())))) + " vs. ") + ff_compiler_Syntax.Type_show(t4_, ff_core_List.Link(t3_, ff_core_List.Link(t4_, ff_core_List.Empty()))))), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
511
- } else if((ff_core_String.String_startsWith(name1_, "Function$", 0) && ff_core_String.String_startsWith(name2_, "Function$", 0))) {
512
- ff_core_List.List_each(ff_core_List.List_zip(ff_core_List.List_dropLast(generics1_, 1), ff_core_List.List_dropLast(generics2_, 1)), ((_1) => {
513
- {
514
- const t3_ = _1.first_;
515
- const t4_ = _1.second_;
516
- ff_compiler_Unification.Unification_unify(self_, at_, t3_, t4_)
517
- return
518
- }
519
- }));
520
- ff_core_List.List_each(ff_core_List.List_zip(ff_core_List.List_takeLast(generics1_, 1), ff_core_List.List_takeLast(generics2_, 1)), ((_1) => {
521
- {
522
- const t3_ = _1.first_;
523
- const t4_ = _1.second_;
524
- ff_compiler_Unification.Unification_unify(self_, at_, t3_, t4_)
525
- return
526
- }
527
- }))
528
- } else {}
529
- } else {
530
- ff_core_List.List_each(ff_core_List.List_zip(generics1_, generics2_), ((_1) => {
531
- {
532
- const t1_ = _1.first_;
533
- const t2_ = _1.second_;
534
- ff_compiler_Unification.Unification_unify(self_, at_, t1_, t2_)
535
- return
536
- }
537
- }))
538
- }
539
- return
540
- }
541
- }
542
- }
543
- }
544
- }
545
-
546
- export function Unification_bind(self_, at_, index_, type_) {
547
- if(ff_compiler_Unification.Unification_occursIn(self_, index_, type_)) {
548
- const t_ = ff_compiler_Unification.Unification_substitute(self_, type_);
549
- throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(at_, ((("Infinite type: " + ff_compiler_Syntax.Type_show(ff_compiler_Syntax.TVariable(at_, index_), ff_core_List.Link(t_, ff_core_List.Empty()))) + " = ") + ff_compiler_Syntax.Type_show(t_, ff_core_List.Empty()))), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
550
- };
551
- self_.substitution_ = ff_core_Map.Map_add(self_.substitution_, index_, type_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_Int_Int);
552
- ff_core_Option.Option_each(ff_core_Map.Map_get(self_.constraints_, index_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_Int_Int), ((map_) => {
553
- self_.constraints_ = ff_core_Map.Map_remove(self_.constraints_, index_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_Int_Int);
554
- ff_core_List.List_each(ff_core_Map.Map_pairs(map_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ((_1) => {
555
- {
556
- const name_ = _1.first_;
557
- const at2_ = _1.second_.at_;
558
- const generics_ = _1.second_.generics_;
559
- ff_compiler_Unification.Unification_constrain(self_, at2_, type_, name_, generics_)
560
- return
561
- }
562
- }))
563
- }));
564
- ff_core_Option.Option_each(ff_core_Map.Map_get(self_.affects_, index_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_Int_Int), ((affected_) => {
565
- ff_core_Map.Map_remove(self_.affects_, index_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_Int_Int);
566
- ff_core_Set.Set_each(affected_, ((i_) => {
567
- ff_compiler_Unification.Unification_affect(self_, at_, type_, ff_compiler_Syntax.TVariable(at_, i_))
568
- }), ff_core_Ordering.ff_core_Ordering_Order$ff_core_Int_Int)
569
- }))
570
- }
571
-
572
- export function Unification_affect(self_, at_, source_, target_) {
573
- {
574
- const _1 = ff_core_Pair.Pair(ff_compiler_Unification.Unification_substitute(self_, source_), ff_compiler_Unification.Unification_substitute(self_, target_));
575
- {
576
- if(_1.first_.TVariable) {
577
- const i1_ = _1.first_.index_;
578
- if(_1.second_.TVariable) {
579
- const i2_ = _1.second_.index_;
580
- const is_ = ff_core_Option.Option_else(ff_core_Map.Map_get(self_.affects_, i1_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_Int_Int), (() => {
581
- return ff_core_List.List_toSet(ff_core_List.Empty(), ff_core_Ordering.ff_core_Ordering_Order$ff_core_Int_Int)
582
- }));
583
- self_.affects_ = ff_core_Map.Map_add(self_.affects_, i1_, ff_core_Set.Set_add(is_, i2_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_Int_Int), ff_core_Ordering.ff_core_Ordering_Order$ff_core_Int_Int)
584
- return
585
- }
586
- }
587
- }
588
- {
589
- if(_1.second_.TConstructor) {
590
- if(_1.second_.name_ == "Q$") {
591
-
592
- return
593
- }
594
- }
595
- }
596
- {
597
- if(_1.first_.TConstructor) {
598
- if(_1.first_.name_ == "ff:core/Nothing.Nothing") {
599
-
600
- return
601
- }
602
- }
603
- }
604
- {
605
- const t1_ = _1.first_;
606
- const t2_ = _1.second_;
607
- ff_compiler_Unification.Unification_unify(self_, at_, t1_, t2_)
608
- return
609
- }
610
- }
611
- }
612
-
613
- export function Unification_occursIn(self_, index_, t_) {
614
- {
615
- const self_a = self_;
616
- const index_a = index_;
617
- const t_a = t_;
618
- {
619
- if(t_a.TVariable) {
620
- const i_ = t_a.index_;
621
- const _guard1 = ff_compiler_Unification.Unification_get(self_, i_);
622
- if(_guard1.Some) {
623
- const type_ = _guard1.value_;
624
- return ff_compiler_Unification.Unification_occursIn(self_, index_, type_)
625
- return
626
- }
627
- }
628
- }
629
- {
630
- if(t_a.TVariable) {
631
- const i_ = t_a.index_;
632
- return (i_ === index_)
633
- return
634
- }
635
- }
636
- {
637
- if(t_a.TConstructor) {
638
- const generics_ = t_a.generics_;
639
- return ff_core_List.List_any(generics_, ((t_) => {
640
- return ff_compiler_Unification.Unification_occursIn(self_, index_, t_)
641
- }))
642
- return
643
- }
644
- }
645
- }
646
- }
647
-
648
- export async function Unification_withLocalInstances$(self_, instances_, body_, $task) {
649
- const oldInstances_ = self_.instances_;
650
- self_.instances_ = ff_core_Map.Map_addAll(self_.instances_, instances_, ff_compiler_Unification.ff_core_Ordering_Order$ff_compiler_Unification_InstanceKey);
651
- try {
652
- return (await body_($task))
653
- } finally {
654
- self_.instances_ = oldInstances_
655
- }
656
- }
657
-
658
- export async function Unification_freshUnificationVariable$(self_, at_, $task) {
659
- const result_ = ff_compiler_Syntax.TVariable(at_, self_.nextUnificationVariableIndex_);
660
- self_.nextUnificationVariableIndex_ += 3;
661
- return result_
662
- }
663
-
664
- export async function Unification_instantiate$(self_, instantiation_, type_, $task) {
665
- {
666
- const self_a = self_;
667
- const instantiation_a = instantiation_;
668
- const type_a = type_;
669
- {
670
- if(type_a.TConstructor) {
671
- const at_ = type_a.at_;
672
- const name_ = type_a.name_;
673
- if(type_a.generics_.Empty) {
674
- {
675
- const _1 = ff_core_Map.Map_get(instantiation_, name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
676
- {
677
- if(_1.Some) {
678
- const t_ = _1.value_;
679
- return t_
680
- return
681
- }
682
- }
683
- {
684
- if(_1.None) {
685
- return type_
686
- return
687
- }
688
- }
689
- }
690
- return
691
- }
692
- }
693
- }
694
- {
695
- if(type_a.TConstructor) {
696
- const at_ = type_a.at_;
697
- const name_ = type_a.name_;
698
- const generics_ = type_a.generics_;
699
- return ff_compiler_Syntax.TConstructor(at_, name_, ff_core_List.List_map(generics_, ((_w1) => {
700
- return ff_compiler_Unification.Unification_instantiate(self_, instantiation_, _w1)
701
- })))
702
- return
703
- }
704
- }
705
- {
706
- if(type_a.TVariable) {
707
- const i_ = type_a.index_;
708
- const _guard1 = ff_compiler_Unification.Unification_get(self_, i_);
709
- if(_guard1.Some) {
710
- const t_ = _guard1.value_;
711
- return ff_compiler_Unification.Unification_instantiate(self_, instantiation_, t_)
712
- return
713
- }
714
- }
715
- }
716
- {
717
- if(type_a.TVariable) {
718
- const i_ = type_a.index_;
719
- return type_
720
- return
721
- }
722
- }
723
- }
724
- }
725
-
726
- export async function Unification_instantiateConstraint$(self_, instantiation_, constraint_, $task) {
727
- {
728
- const self_a = self_;
729
- const instantiation_a = instantiation_;
730
- const constraint_a = constraint_;
731
- {
732
- const at_ = constraint_a.at_;
733
- const name_ = constraint_a.name_;
734
- const generics_ = constraint_a.generics_;
735
- return ff_compiler_Syntax.Constraint(at_, name_, ff_core_List.List_map(generics_, ((_w1) => {
736
- return ff_compiler_Unification.Unification_instantiate(self_, instantiation_, _w1)
737
- })))
738
- return
739
- }
740
- }
741
- }
742
-
743
- export async function Unification_constrain$(self_, at_, type_, constraintName_, generics_, $task) {
744
- {
745
- const _1 = type_;
746
- {
747
- if(_1.TVariable) {
748
- const i_ = _1.index_;
749
- const _guard1 = ff_compiler_Unification.Unification_get(self_, i_);
750
- if(_guard1.Some) {
751
- const t_ = _guard1.value_;
752
- ff_compiler_Unification.Unification_constrain(self_, at_, t_, constraintName_, generics_)
753
- return
754
- }
755
- }
756
- }
757
- {
758
- if(_1.TVariable) {
759
- const i_ = _1.index_;
760
- {
761
- const _1 = ff_core_Map.Map_get(self_.constraints_, i_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_Int_Int);
762
- {
763
- if(_1.None) {
764
- self_.constraints_ = ff_core_Map.Map_add(self_.constraints_, i_, ff_core_List.List_toMap(ff_core_List.Link(ff_core_Pair.Pair(constraintName_, ff_compiler_Unification.ConstraintGenerics(at_, generics_)), ff_core_List.Empty()), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Ordering.ff_core_Ordering_Order$ff_core_Int_Int)
765
- return
766
- }
767
- }
768
- {
769
- if(_1.Some) {
770
- const map_ = _1.value_;
771
- {
772
- const _1 = ff_core_Map.Map_get(map_, constraintName_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
773
- {
774
- if(_1.None) {
775
- const newMap_ = ff_core_Map.Map_add(map_, constraintName_, ff_compiler_Unification.ConstraintGenerics(at_, generics_), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
776
- self_.constraints_ = ff_core_Map.Map_add(self_.constraints_, i_, newMap_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_Int_Int)
777
- return
778
- }
779
- }
780
- {
781
- if(_1.Some) {
782
- const generics2_ = _1.value_.generics_;
783
- ff_core_List.List_each(ff_core_List.List_zip(generics_, generics2_), ((_1) => {
784
- {
785
- const t1_ = _1.first_;
786
- const t2_ = _1.second_;
787
- ff_compiler_Unification.Unification_unify(self_, at_, t1_, t2_)
788
- return
789
- }
790
- }))
791
- return
792
- }
793
- }
794
- }
795
- return
796
- }
797
- }
798
- }
799
- return
800
- }
801
- }
802
- {
803
- if(_1.TConstructor) {
804
- const name_ = _1.name_;
805
- const generics2_ = _1.generics_;
806
- {
807
- const _1 = ff_core_Map.Map_get(self_.instances_, ff_compiler_Unification.InstanceKey(constraintName_, name_), ff_compiler_Unification.ff_core_Ordering_Order$ff_compiler_Unification_InstanceKey);
808
- {
809
- if(_1.None) {
810
- const g1_ = (ff_core_List.List_isEmpty(generics_)
811
- ? ""
812
- : "[...]");
813
- const g2_ = (ff_core_List.List_isEmpty(generics2_)
814
- ? ""
815
- : "[...]");
816
- if((!self_.attemptFixes_)) {
817
- throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(at_, ((((("No such instance: " + name_) + g2_) + ": ") + constraintName_) + g1_)), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
818
- }
819
- return
820
- }
821
- }
822
- {
823
- if(_1.Some) {
824
- const definition_ = _1.value_;
825
- const unificationVariables_ = ff_core_List.List_map(definition_.generics_, ((_) => {
826
- return ff_compiler_Unification.Unification_freshUnificationVariable(self_, at_)
827
- }));
828
- const instantiation_ = ff_core_List.List_toMap(ff_core_List.List_zip(definition_.generics_, unificationVariables_), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
829
- const traitType1_ = ff_compiler_Unification.Unification_instantiate(self_, instantiation_, ff_compiler_Syntax.TConstructor(at_, definition_.traitName_, definition_.typeArguments_));
830
- const traitType2_ = ff_compiler_Syntax.TConstructor(at_, constraintName_, ff_core_List.Link(type_, generics_));
831
- ff_compiler_Unification.Unification_unify(self_, at_, traitType1_, traitType2_);
832
- ff_core_List.List_each(definition_.constraints_, ((constraint_) => {
833
- {
834
- const _1 = ff_compiler_Unification.Unification_instantiateConstraint(self_, instantiation_, constraint_);
835
- {
836
- const constraintName_ = _1.name_;
837
- const newGenerics_ = _1.generics_;
838
- ff_compiler_Unification.Unification_constrain(self_, at_, ff_core_List.List_grabFirst(newGenerics_), constraintName_, ff_core_List.List_dropFirst(newGenerics_, 1))
839
- return
840
- }
841
- }
842
- }))
843
- return
844
- }
845
- }
846
- }
847
- return
848
- }
849
- }
850
- }
851
- }
852
-
853
- export async function Unification_get$(self_, index_, $task) {
854
- return ff_core_Option.Option_map(ff_core_Map.Map_get(self_.substitution_, index_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_Int_Int), ((_1) => {
855
- {
856
- if(_1.TVariable) {
857
- const i_ = _1.index_;
858
- const _guard1 = ff_core_Map.Map_get(self_.substitution_, i_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_Int_Int);
859
- if(_guard1.Some) {
860
- const t_ = _guard1.value_;
861
- self_.substitution_ = ff_core_Map.Map_add(self_.substitution_, index_, t_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_Int_Int);
862
- return t_
863
- return
864
- }
865
- }
866
- }
867
- {
868
- const t_ = _1;
869
- return t_
870
- return
871
- }
872
- }))
873
- }
874
-
875
- export async function Unification_substitute$(self_, type_, $task) {
876
- {
877
- const self_a = self_;
878
- const type_a = type_;
879
- {
880
- if(type_a.TVariable) {
881
- const i_ = type_a.index_;
882
- const _guard1 = ff_compiler_Unification.Unification_get(self_, i_);
883
- if(_guard1.Some) {
884
- const t_ = _guard1.value_;
885
- return ff_compiler_Unification.Unification_substitute(self_, t_)
886
- return
887
- }
888
- }
889
- }
890
- {
891
- if(type_a.TVariable) {
892
- return type_
893
- return
894
- }
895
- }
896
- {
897
- if(type_a.TConstructor) {
898
- const t_ = type_a;
899
- {
900
- const _1 = t_;
901
- {
902
- const _c = _1;
903
- return ff_compiler_Syntax.TConstructor(_c.at_, _c.name_, ff_core_List.List_map(t_.generics_, ((t_) => {
904
- return ff_compiler_Unification.Unification_substitute(self_, t_)
905
- })))
906
- return
907
- }
908
- }
909
- return
910
- }
911
- }
912
- }
913
- }
914
-
915
- export async function Unification_unify$(self_, at_, t1_, t2_, $task) {
916
- {
917
- const self_a = self_;
918
- const at_a = at_;
919
- const t1_a = t1_;
920
- const t2_a = t2_;
921
- {
922
- if(t1_a.TVariable) {
923
- const i1_ = t1_a.index_;
924
- if(t2_a.TVariable) {
925
- const i2_ = t2_a.index_;
926
- const _guard1 = (i1_ === i2_);
927
- if(_guard1) {
928
-
929
- return
930
- }
931
- }
932
- }
933
- }
934
- {
935
- if(t1_a.TVariable) {
936
- const i_ = t1_a.index_;
937
- const _guard1 = ff_compiler_Unification.Unification_get(self_, i_);
938
- if(_guard1.Some) {
939
- const t_ = _guard1.value_;
940
- ff_compiler_Unification.Unification_unify(self_, at_, t_, t2_)
941
- return
942
- }
943
- }
944
- }
945
- {
946
- if(t2_a.TVariable) {
947
- const i_ = t2_a.index_;
948
- const _guard1 = ff_compiler_Unification.Unification_get(self_, i_);
949
- if(_guard1.Some) {
950
- const t_ = _guard1.value_;
951
- ff_compiler_Unification.Unification_unify(self_, at_, t1_, t_)
952
- return
953
- }
954
- }
955
- }
956
- {
957
- if(t1_a.TVariable) {
958
- const i_ = t1_a.index_;
959
- ff_compiler_Unification.Unification_bind(self_, at_, i_, t2_)
960
- return
961
- }
962
- }
963
- {
964
- if(t2_a.TVariable) {
965
- const i_ = t2_a.index_;
966
- ff_compiler_Unification.Unification_bind(self_, at_, i_, t1_)
967
- return
968
- }
969
- }
970
- {
971
- if(t1_a.TConstructor) {
972
- const name1_ = t1_a.name_;
973
- const generics1_ = t1_a.generics_;
974
- if(t2_a.TConstructor) {
975
- const name2_ = t2_a.name_;
976
- const generics2_ = t2_a.generics_;
977
- if(((name1_ !== name2_) || (ff_core_List.List_size(generics1_) !== ff_core_List.List_size(generics2_)))) {
978
- if((!self_.attemptFixes_)) {
979
- const t3_ = ff_compiler_Unification.Unification_substitute(self_, t1_);
980
- const t4_ = ff_compiler_Unification.Unification_substitute(self_, t2_);
981
- throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(at_, ((("Type mismatch: " + ff_compiler_Syntax.Type_show(t3_, ff_core_List.Link(t3_, ff_core_List.Link(t4_, ff_core_List.Empty())))) + " vs. ") + ff_compiler_Syntax.Type_show(t4_, ff_core_List.Link(t3_, ff_core_List.Link(t4_, ff_core_List.Empty()))))), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
982
- } else if((ff_core_String.String_startsWith(name1_, "Function$", 0) && ff_core_String.String_startsWith(name2_, "Function$", 0))) {
983
- ff_core_List.List_each(ff_core_List.List_zip(ff_core_List.List_dropLast(generics1_, 1), ff_core_List.List_dropLast(generics2_, 1)), ((_1) => {
984
- {
985
- const t3_ = _1.first_;
986
- const t4_ = _1.second_;
987
- ff_compiler_Unification.Unification_unify(self_, at_, t3_, t4_)
988
- return
989
- }
990
- }));
991
- ff_core_List.List_each(ff_core_List.List_zip(ff_core_List.List_takeLast(generics1_, 1), ff_core_List.List_takeLast(generics2_, 1)), ((_1) => {
992
- {
993
- const t3_ = _1.first_;
994
- const t4_ = _1.second_;
995
- ff_compiler_Unification.Unification_unify(self_, at_, t3_, t4_)
996
- return
997
- }
998
- }))
999
- } else {}
1000
- } else {
1001
- ff_core_List.List_each(ff_core_List.List_zip(generics1_, generics2_), ((_1) => {
1002
- {
1003
- const t1_ = _1.first_;
1004
- const t2_ = _1.second_;
1005
- ff_compiler_Unification.Unification_unify(self_, at_, t1_, t2_)
1006
- return
1007
- }
1008
- }))
1009
- }
1010
- return
1011
- }
1012
- }
1013
- }
1014
- }
1015
- }
1016
-
1017
- export async function Unification_bind$(self_, at_, index_, type_, $task) {
1018
- if(ff_compiler_Unification.Unification_occursIn(self_, index_, type_)) {
1019
- const t_ = ff_compiler_Unification.Unification_substitute(self_, type_);
1020
- throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(at_, ((("Infinite type: " + ff_compiler_Syntax.Type_show(ff_compiler_Syntax.TVariable(at_, index_), ff_core_List.Link(t_, ff_core_List.Empty()))) + " = ") + ff_compiler_Syntax.Type_show(t_, ff_core_List.Empty()))), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
1021
- };
1022
- self_.substitution_ = ff_core_Map.Map_add(self_.substitution_, index_, type_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_Int_Int);
1023
- ff_core_Option.Option_each(ff_core_Map.Map_get(self_.constraints_, index_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_Int_Int), ((map_) => {
1024
- self_.constraints_ = ff_core_Map.Map_remove(self_.constraints_, index_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_Int_Int);
1025
- ff_core_List.List_each(ff_core_Map.Map_pairs(map_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ((_1) => {
1026
- {
1027
- const name_ = _1.first_;
1028
- const at2_ = _1.second_.at_;
1029
- const generics_ = _1.second_.generics_;
1030
- ff_compiler_Unification.Unification_constrain(self_, at2_, type_, name_, generics_)
1031
- return
1032
- }
1033
- }))
1034
- }));
1035
- ff_core_Option.Option_each(ff_core_Map.Map_get(self_.affects_, index_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_Int_Int), ((affected_) => {
1036
- ff_core_Map.Map_remove(self_.affects_, index_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_Int_Int);
1037
- ff_core_Set.Set_each(affected_, ((i_) => {
1038
- ff_compiler_Unification.Unification_affect(self_, at_, type_, ff_compiler_Syntax.TVariable(at_, i_))
1039
- }), ff_core_Ordering.ff_core_Ordering_Order$ff_core_Int_Int)
1040
- }))
1041
- }
1042
-
1043
- export async function Unification_affect$(self_, at_, source_, target_, $task) {
1044
- {
1045
- const _1 = ff_core_Pair.Pair(ff_compiler_Unification.Unification_substitute(self_, source_), ff_compiler_Unification.Unification_substitute(self_, target_));
1046
- {
1047
- if(_1.first_.TVariable) {
1048
- const i1_ = _1.first_.index_;
1049
- if(_1.second_.TVariable) {
1050
- const i2_ = _1.second_.index_;
1051
- const is_ = ff_core_Option.Option_else(ff_core_Map.Map_get(self_.affects_, i1_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_Int_Int), (() => {
1052
- return ff_core_List.List_toSet(ff_core_List.Empty(), ff_core_Ordering.ff_core_Ordering_Order$ff_core_Int_Int)
1053
- }));
1054
- self_.affects_ = ff_core_Map.Map_add(self_.affects_, i1_, ff_core_Set.Set_add(is_, i2_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_Int_Int), ff_core_Ordering.ff_core_Ordering_Order$ff_core_Int_Int)
1055
- return
1056
- }
1057
- }
1058
- }
1059
- {
1060
- if(_1.second_.TConstructor) {
1061
- if(_1.second_.name_ == "Q$") {
1062
-
1063
- return
1064
- }
1065
- }
1066
- }
1067
- {
1068
- if(_1.first_.TConstructor) {
1069
- if(_1.first_.name_ == "ff:core/Nothing.Nothing") {
1070
-
1071
- return
1072
- }
1073
- }
1074
- }
1075
- {
1076
- const t1_ = _1.first_;
1077
- const t2_ = _1.second_;
1078
- ff_compiler_Unification.Unification_unify(self_, at_, t1_, t2_)
1079
- return
1080
- }
1081
- }
1082
- }
1083
-
1084
- export async function Unification_occursIn$(self_, index_, t_, $task) {
1085
- {
1086
- const self_a = self_;
1087
- const index_a = index_;
1088
- const t_a = t_;
1089
- {
1090
- if(t_a.TVariable) {
1091
- const i_ = t_a.index_;
1092
- const _guard1 = ff_compiler_Unification.Unification_get(self_, i_);
1093
- if(_guard1.Some) {
1094
- const type_ = _guard1.value_;
1095
- return ff_compiler_Unification.Unification_occursIn(self_, index_, type_)
1096
- return
1097
- }
1098
- }
1099
- }
1100
- {
1101
- if(t_a.TVariable) {
1102
- const i_ = t_a.index_;
1103
- return (i_ === index_)
1104
- return
1105
- }
1106
- }
1107
- {
1108
- if(t_a.TConstructor) {
1109
- const generics_ = t_a.generics_;
1110
- return ff_core_List.List_any(generics_, ((t_) => {
1111
- return ff_compiler_Unification.Unification_occursIn(self_, index_, t_)
1112
- }))
1113
- return
1114
- }
1115
- }
1116
- }
1117
- }
1118
-
1119
- export const ff_core_Any_HasAnyTag$ff_compiler_Unification_ConstraintGenerics = {
1120
- anyTag_() {
1121
- return ff_core_Any.internalAnyTag_((("ff:compiler/Unification.ConstraintGenerics" + "[") + "]"))
1122
- },
1123
- async anyTag_$($task) {
1124
- return ff_core_Any.internalAnyTag_((("ff:compiler/Unification.ConstraintGenerics" + "[") + "]"))
1125
- }
1126
- };
1127
-
1128
- export const ff_core_Any_HasAnyTag$ff_compiler_Unification_InstanceKey = {
1129
- anyTag_() {
1130
- return ff_core_Any.internalAnyTag_((("ff:compiler/Unification.InstanceKey" + "[") + "]"))
1131
- },
1132
- async anyTag_$($task) {
1133
- return ff_core_Any.internalAnyTag_((("ff:compiler/Unification.InstanceKey" + "[") + "]"))
1134
- }
1135
- };
1136
-
1137
- export const ff_core_Any_HasAnyTag$ff_compiler_Unification_InstanceValue = {
1138
- anyTag_() {
1139
- return ff_core_Any.internalAnyTag_((("ff:compiler/Unification.InstanceValue" + "[") + "]"))
1140
- },
1141
- async anyTag_$($task) {
1142
- return ff_core_Any.internalAnyTag_((("ff:compiler/Unification.InstanceValue" + "[") + "]"))
1143
- }
1144
- };
1145
-
1146
- export const ff_core_Show_Show$ff_compiler_Unification_ConstraintGenerics = {
1147
- show_(value_) {
1148
- {
1149
- const value_a = value_;
1150
- {
1151
- const z_ = value_a;
1152
- return ((((("ConstraintGenerics" + "(") + ff_compiler_Syntax.ff_core_Show_Show$ff_compiler_Syntax_Location.show_(z_.at_)) + ", ") + ff_core_Show.ff_core_Show_Show$ff_core_List_List(ff_compiler_Syntax.ff_core_Show_Show$ff_compiler_Syntax_Type).show_(z_.generics_)) + ")")
1153
- return
1154
- }
1155
- }
1156
- },
1157
- async show_$(value_, $task) {
1158
- {
1159
- const value_a = value_;
1160
- {
1161
- const z_ = value_a;
1162
- return ((((("ConstraintGenerics" + "(") + ff_compiler_Syntax.ff_core_Show_Show$ff_compiler_Syntax_Location.show_(z_.at_)) + ", ") + ff_core_Show.ff_core_Show_Show$ff_core_List_List(ff_compiler_Syntax.ff_core_Show_Show$ff_compiler_Syntax_Type).show_(z_.generics_)) + ")")
1163
- return
1164
- }
1165
- }
1166
- }
1167
- };
1168
-
1169
- export const ff_core_Show_Show$ff_compiler_Unification_InstanceKey = {
1170
- show_(value_) {
1171
- {
1172
- const value_a = value_;
1173
- {
1174
- const z_ = value_a;
1175
- return ((((("InstanceKey" + "(") + ff_core_Show.ff_core_Show_Show$ff_core_String_String.show_(z_.traitName_)) + ", ") + ff_core_Show.ff_core_Show_Show$ff_core_String_String.show_(z_.typeName_)) + ")")
1176
- return
1177
- }
1178
- }
1179
- },
1180
- async show_$(value_, $task) {
1181
- {
1182
- const value_a = value_;
1183
- {
1184
- const z_ = value_a;
1185
- return ((((("InstanceKey" + "(") + ff_core_Show.ff_core_Show_Show$ff_core_String_String.show_(z_.traitName_)) + ", ") + ff_core_Show.ff_core_Show_Show$ff_core_String_String.show_(z_.typeName_)) + ")")
1186
- return
1187
- }
1188
- }
1189
- }
1190
- };
1191
-
1192
- export const ff_core_Show_Show$ff_compiler_Unification_InstanceValue = {
1193
- show_(value_) {
1194
- {
1195
- const value_a = value_;
1196
- {
1197
- const z_ = value_a;
1198
- return ((((((((((((("InstanceValue" + "(") + ff_core_Show.ff_core_Show_Show$ff_core_List_List(ff_core_Show.ff_core_Show_Show$ff_core_String_String).show_(z_.generics_)) + ", ") + ff_core_Show.ff_core_Show_Show$ff_core_List_List(ff_compiler_Syntax.ff_core_Show_Show$ff_compiler_Syntax_Constraint).show_(z_.constraints_)) + ", ") + ff_compiler_Syntax.ff_core_Show_Show$ff_compiler_Syntax_PackagePair.show_(z_.packagePair_)) + ", ") + ff_core_Show.ff_core_Show_Show$ff_core_String_String.show_(z_.moduleName_)) + ", ") + ff_core_Show.ff_core_Show_Show$ff_core_String_String.show_(z_.traitName_)) + ", ") + ff_core_Show.ff_core_Show_Show$ff_core_List_List(ff_compiler_Syntax.ff_core_Show_Show$ff_compiler_Syntax_Type).show_(z_.typeArguments_)) + ")")
1199
- return
1200
- }
1201
- }
1202
- },
1203
- async show_$(value_, $task) {
1204
- {
1205
- const value_a = value_;
1206
- {
1207
- const z_ = value_a;
1208
- return ((((((((((((("InstanceValue" + "(") + ff_core_Show.ff_core_Show_Show$ff_core_List_List(ff_core_Show.ff_core_Show_Show$ff_core_String_String).show_(z_.generics_)) + ", ") + ff_core_Show.ff_core_Show_Show$ff_core_List_List(ff_compiler_Syntax.ff_core_Show_Show$ff_compiler_Syntax_Constraint).show_(z_.constraints_)) + ", ") + ff_compiler_Syntax.ff_core_Show_Show$ff_compiler_Syntax_PackagePair.show_(z_.packagePair_)) + ", ") + ff_core_Show.ff_core_Show_Show$ff_core_String_String.show_(z_.moduleName_)) + ", ") + ff_core_Show.ff_core_Show_Show$ff_core_String_String.show_(z_.traitName_)) + ", ") + ff_core_Show.ff_core_Show_Show$ff_core_List_List(ff_compiler_Syntax.ff_core_Show_Show$ff_compiler_Syntax_Type).show_(z_.typeArguments_)) + ")")
1209
- return
1210
- }
1211
- }
1212
- }
1213
- };
1214
-
1215
- export const ff_core_Equal_Equal$ff_compiler_Unification_ConstraintGenerics = {
1216
- equals_(x_, y_) {
1217
- {
1218
- const x_a = x_;
1219
- const y_a = y_;
1220
- {
1221
- const _guard1 = (x_ === y_);
1222
- if(_guard1) {
1223
- return true
1224
- return
1225
- }
1226
- }
1227
- {
1228
- return (ff_compiler_Syntax.ff_core_Equal_Equal$ff_compiler_Syntax_Location.equals_(x_.at_, y_.at_) && ff_core_List.ff_core_Equal_Equal$ff_core_List_List(ff_compiler_Syntax.ff_core_Equal_Equal$ff_compiler_Syntax_Type).equals_(x_.generics_, y_.generics_))
1229
- return
1230
- }
1231
- }
1232
- },
1233
- async equals_$(x_, y_, $task) {
1234
- {
1235
- const x_a = x_;
1236
- const y_a = y_;
1237
- {
1238
- const _guard1 = (x_ === y_);
1239
- if(_guard1) {
1240
- return true
1241
- return
1242
- }
1243
- }
1244
- {
1245
- return (ff_compiler_Syntax.ff_core_Equal_Equal$ff_compiler_Syntax_Location.equals_(x_.at_, y_.at_) && ff_core_List.ff_core_Equal_Equal$ff_core_List_List(ff_compiler_Syntax.ff_core_Equal_Equal$ff_compiler_Syntax_Type).equals_(x_.generics_, y_.generics_))
1246
- return
1247
- }
1248
- }
1249
- }
1250
- };
1251
-
1252
- export const ff_core_Equal_Equal$ff_compiler_Unification_InstanceKey = {
1253
- equals_(x_, y_) {
1254
- {
1255
- const x_a = x_;
1256
- const y_a = y_;
1257
- {
1258
- const _guard1 = (x_ === y_);
1259
- if(_guard1) {
1260
- return true
1261
- return
1262
- }
1263
- }
1264
- {
1265
- return ((x_.traitName_ === y_.traitName_) && (x_.typeName_ === y_.typeName_))
1266
- return
1267
- }
1268
- }
1269
- },
1270
- async equals_$(x_, y_, $task) {
1271
- {
1272
- const x_a = x_;
1273
- const y_a = y_;
1274
- {
1275
- const _guard1 = (x_ === y_);
1276
- if(_guard1) {
1277
- return true
1278
- return
1279
- }
1280
- }
1281
- {
1282
- return ((x_.traitName_ === y_.traitName_) && (x_.typeName_ === y_.typeName_))
1283
- return
1284
- }
1285
- }
1286
- }
1287
- };
1288
-
1289
- export const ff_core_Equal_Equal$ff_compiler_Unification_InstanceValue = {
1290
- equals_(x_, y_) {
1291
- {
1292
- const x_a = x_;
1293
- const y_a = y_;
1294
- {
1295
- const _guard1 = (x_ === y_);
1296
- if(_guard1) {
1297
- return true
1298
- return
1299
- }
1300
- }
1301
- {
1302
- return (ff_core_List.ff_core_Equal_Equal$ff_core_List_List(ff_core_Equal.ff_core_Equal_Equal$ff_core_String_String).equals_(x_.generics_, y_.generics_) && (ff_core_List.ff_core_Equal_Equal$ff_core_List_List(ff_compiler_Syntax.ff_core_Equal_Equal$ff_compiler_Syntax_Constraint).equals_(x_.constraints_, y_.constraints_) && (ff_compiler_Syntax.ff_core_Equal_Equal$ff_compiler_Syntax_PackagePair.equals_(x_.packagePair_, y_.packagePair_) && ((x_.moduleName_ === y_.moduleName_) && ((x_.traitName_ === y_.traitName_) && ff_core_List.ff_core_Equal_Equal$ff_core_List_List(ff_compiler_Syntax.ff_core_Equal_Equal$ff_compiler_Syntax_Type).equals_(x_.typeArguments_, y_.typeArguments_))))))
1303
- return
1304
- }
1305
- }
1306
- },
1307
- async equals_$(x_, y_, $task) {
1308
- {
1309
- const x_a = x_;
1310
- const y_a = y_;
1311
- {
1312
- const _guard1 = (x_ === y_);
1313
- if(_guard1) {
1314
- return true
1315
- return
1316
- }
1317
- }
1318
- {
1319
- return (ff_core_List.ff_core_Equal_Equal$ff_core_List_List(ff_core_Equal.ff_core_Equal_Equal$ff_core_String_String).equals_(x_.generics_, y_.generics_) && (ff_core_List.ff_core_Equal_Equal$ff_core_List_List(ff_compiler_Syntax.ff_core_Equal_Equal$ff_compiler_Syntax_Constraint).equals_(x_.constraints_, y_.constraints_) && (ff_compiler_Syntax.ff_core_Equal_Equal$ff_compiler_Syntax_PackagePair.equals_(x_.packagePair_, y_.packagePair_) && ((x_.moduleName_ === y_.moduleName_) && ((x_.traitName_ === y_.traitName_) && ff_core_List.ff_core_Equal_Equal$ff_core_List_List(ff_compiler_Syntax.ff_core_Equal_Equal$ff_compiler_Syntax_Type).equals_(x_.typeArguments_, y_.typeArguments_))))))
1320
- return
1321
- }
1322
- }
1323
- }
1324
- };
1325
-
1326
- export const ff_core_Ordering_Order$ff_compiler_Unification_ConstraintGenerics = {
1327
- compare_(x_, y_) {
1328
- {
1329
- const x_a = x_;
1330
- const y_a = y_;
1331
- {
1332
- const _guard1 = (x_ === y_);
1333
- if(_guard1) {
1334
- return ff_core_Ordering.OrderingSame()
1335
- return
1336
- }
1337
- }
1338
- {
1339
- const atOrdering_ = ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_Location.compare_(x_.at_, y_.at_);
1340
- if((atOrdering_ !== ff_core_Ordering.OrderingSame())) {
1341
- return atOrdering_
1342
- } else {
1343
- const genericsOrdering_ = ff_core_Ordering.ff_core_Ordering_Order$ff_core_List_List(ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_Type).compare_(x_.generics_, y_.generics_);
1344
- if((genericsOrdering_ !== ff_core_Ordering.OrderingSame())) {
1345
- return genericsOrdering_
1346
- } else {
1347
- return ff_core_Ordering.OrderingSame()
1348
- }
1349
- }
1350
- return
1351
- }
1352
- }
1353
- },
1354
- async compare_$(x_, y_, $task) {
1355
- {
1356
- const x_a = x_;
1357
- const y_a = y_;
1358
- {
1359
- const _guard1 = (x_ === y_);
1360
- if(_guard1) {
1361
- return ff_core_Ordering.OrderingSame()
1362
- return
1363
- }
1364
- }
1365
- {
1366
- const atOrdering_ = ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_Location.compare_(x_.at_, y_.at_);
1367
- if((atOrdering_ !== ff_core_Ordering.OrderingSame())) {
1368
- return atOrdering_
1369
- } else {
1370
- const genericsOrdering_ = ff_core_Ordering.ff_core_Ordering_Order$ff_core_List_List(ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_Type).compare_(x_.generics_, y_.generics_);
1371
- if((genericsOrdering_ !== ff_core_Ordering.OrderingSame())) {
1372
- return genericsOrdering_
1373
- } else {
1374
- return ff_core_Ordering.OrderingSame()
1375
- }
1376
- }
1377
- return
1378
- }
1379
- }
1380
- }
1381
- };
1382
-
1383
- export const ff_core_Ordering_Order$ff_compiler_Unification_InstanceKey = {
1384
- compare_(x_, y_) {
1385
- {
1386
- const x_a = x_;
1387
- const y_a = y_;
1388
- {
1389
- const _guard1 = (x_ === y_);
1390
- if(_guard1) {
1391
- return ff_core_Ordering.OrderingSame()
1392
- return
1393
- }
1394
- }
1395
- {
1396
- const traitNameOrdering_ = ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String.compare_(x_.traitName_, y_.traitName_);
1397
- if((traitNameOrdering_ !== ff_core_Ordering.OrderingSame())) {
1398
- return traitNameOrdering_
1399
- } else {
1400
- const typeNameOrdering_ = ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String.compare_(x_.typeName_, y_.typeName_);
1401
- if((typeNameOrdering_ !== ff_core_Ordering.OrderingSame())) {
1402
- return typeNameOrdering_
1403
- } else {
1404
- return ff_core_Ordering.OrderingSame()
1405
- }
1406
- }
1407
- return
1408
- }
1409
- }
1410
- },
1411
- async compare_$(x_, y_, $task) {
1412
- {
1413
- const x_a = x_;
1414
- const y_a = y_;
1415
- {
1416
- const _guard1 = (x_ === y_);
1417
- if(_guard1) {
1418
- return ff_core_Ordering.OrderingSame()
1419
- return
1420
- }
1421
- }
1422
- {
1423
- const traitNameOrdering_ = ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String.compare_(x_.traitName_, y_.traitName_);
1424
- if((traitNameOrdering_ !== ff_core_Ordering.OrderingSame())) {
1425
- return traitNameOrdering_
1426
- } else {
1427
- const typeNameOrdering_ = ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String.compare_(x_.typeName_, y_.typeName_);
1428
- if((typeNameOrdering_ !== ff_core_Ordering.OrderingSame())) {
1429
- return typeNameOrdering_
1430
- } else {
1431
- return ff_core_Ordering.OrderingSame()
1432
- }
1433
- }
1434
- return
1435
- }
1436
- }
1437
- }
1438
- };
1439
-
1440
- export const ff_core_Ordering_Order$ff_compiler_Unification_InstanceValue = {
1441
- compare_(x_, y_) {
1442
- {
1443
- const x_a = x_;
1444
- const y_a = y_;
1445
- {
1446
- const _guard1 = (x_ === y_);
1447
- if(_guard1) {
1448
- return ff_core_Ordering.OrderingSame()
1449
- return
1450
- }
1451
- }
1452
- {
1453
- const genericsOrdering_ = ff_core_Ordering.ff_core_Ordering_Order$ff_core_List_List(ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String).compare_(x_.generics_, y_.generics_);
1454
- if((genericsOrdering_ !== ff_core_Ordering.OrderingSame())) {
1455
- return genericsOrdering_
1456
- } else {
1457
- const constraintsOrdering_ = ff_core_Ordering.ff_core_Ordering_Order$ff_core_List_List(ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_Constraint).compare_(x_.constraints_, y_.constraints_);
1458
- if((constraintsOrdering_ !== ff_core_Ordering.OrderingSame())) {
1459
- return constraintsOrdering_
1460
- } else {
1461
- const packagePairOrdering_ = ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_PackagePair.compare_(x_.packagePair_, y_.packagePair_);
1462
- if((packagePairOrdering_ !== ff_core_Ordering.OrderingSame())) {
1463
- return packagePairOrdering_
1464
- } else {
1465
- const moduleNameOrdering_ = ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String.compare_(x_.moduleName_, y_.moduleName_);
1466
- if((moduleNameOrdering_ !== ff_core_Ordering.OrderingSame())) {
1467
- return moduleNameOrdering_
1468
- } else {
1469
- const traitNameOrdering_ = ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String.compare_(x_.traitName_, y_.traitName_);
1470
- if((traitNameOrdering_ !== ff_core_Ordering.OrderingSame())) {
1471
- return traitNameOrdering_
1472
- } else {
1473
- const typeArgumentsOrdering_ = ff_core_Ordering.ff_core_Ordering_Order$ff_core_List_List(ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_Type).compare_(x_.typeArguments_, y_.typeArguments_);
1474
- if((typeArgumentsOrdering_ !== ff_core_Ordering.OrderingSame())) {
1475
- return typeArgumentsOrdering_
1476
- } else {
1477
- return ff_core_Ordering.OrderingSame()
1478
- }
1479
- }
1480
- }
1481
- }
1482
- }
1483
- }
1484
- return
1485
- }
1486
- }
1487
- },
1488
- async compare_$(x_, y_, $task) {
1489
- {
1490
- const x_a = x_;
1491
- const y_a = y_;
1492
- {
1493
- const _guard1 = (x_ === y_);
1494
- if(_guard1) {
1495
- return ff_core_Ordering.OrderingSame()
1496
- return
1497
- }
1498
- }
1499
- {
1500
- const genericsOrdering_ = ff_core_Ordering.ff_core_Ordering_Order$ff_core_List_List(ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String).compare_(x_.generics_, y_.generics_);
1501
- if((genericsOrdering_ !== ff_core_Ordering.OrderingSame())) {
1502
- return genericsOrdering_
1503
- } else {
1504
- const constraintsOrdering_ = ff_core_Ordering.ff_core_Ordering_Order$ff_core_List_List(ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_Constraint).compare_(x_.constraints_, y_.constraints_);
1505
- if((constraintsOrdering_ !== ff_core_Ordering.OrderingSame())) {
1506
- return constraintsOrdering_
1507
- } else {
1508
- const packagePairOrdering_ = ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_PackagePair.compare_(x_.packagePair_, y_.packagePair_);
1509
- if((packagePairOrdering_ !== ff_core_Ordering.OrderingSame())) {
1510
- return packagePairOrdering_
1511
- } else {
1512
- const moduleNameOrdering_ = ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String.compare_(x_.moduleName_, y_.moduleName_);
1513
- if((moduleNameOrdering_ !== ff_core_Ordering.OrderingSame())) {
1514
- return moduleNameOrdering_
1515
- } else {
1516
- const traitNameOrdering_ = ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String.compare_(x_.traitName_, y_.traitName_);
1517
- if((traitNameOrdering_ !== ff_core_Ordering.OrderingSame())) {
1518
- return traitNameOrdering_
1519
- } else {
1520
- const typeArgumentsOrdering_ = ff_core_Ordering.ff_core_Ordering_Order$ff_core_List_List(ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_Type).compare_(x_.typeArguments_, y_.typeArguments_);
1521
- if((typeArgumentsOrdering_ !== ff_core_Ordering.OrderingSame())) {
1522
- return typeArgumentsOrdering_
1523
- } else {
1524
- return ff_core_Ordering.OrderingSame()
1525
- }
1526
- }
1527
- }
1528
- }
1529
- }
1530
- }
1531
- return
1532
- }
1533
- }
1534
- }
1535
- };
1536
-
1537
- export const ff_core_Serializable_Serializable$ff_compiler_Unification_ConstraintGenerics = {
1538
- serializeUsing_(serialization_, value_) {
1539
- {
1540
- const serialization_a = serialization_;
1541
- const value_a = value_;
1542
- {
1543
- const v_ = value_a;
1544
- serialization_.checksum_ = ff_core_Int.Int_bitOr(((31 * serialization_.checksum_) + 42), 0);
1545
- ff_core_Buffer.Buffer_setUint8(serialization_.buffer_, serialization_.offset_, 0);
1546
- serialization_.offset_ += 1;
1547
- ff_compiler_Syntax.ff_core_Serializable_Serializable$ff_compiler_Syntax_Location.serializeUsing_(serialization_, v_.at_);
1548
- ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_List_List(ff_compiler_Syntax.ff_core_Serializable_Serializable$ff_compiler_Syntax_Type).serializeUsing_(serialization_, v_.generics_)
1549
- return
1550
- }
1551
- }
1552
- },
1553
- deserializeUsing_(serialization_) {
1554
- const variantIndex_ = ff_core_Buffer.Buffer_grabUint8(serialization_.buffer_, serialization_.offset_);
1555
- serialization_.offset_ += 1;
1556
- {
1557
- const _1 = variantIndex_;
1558
- {
1559
- if(_1 == 0) {
1560
- serialization_.checksum_ = ff_core_Int.Int_bitOr(((31 * serialization_.checksum_) + 42), 0);
1561
- return ff_compiler_Unification.ConstraintGenerics(ff_compiler_Syntax.ff_core_Serializable_Serializable$ff_compiler_Syntax_Location.deserializeUsing_(serialization_), ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_List_List(ff_compiler_Syntax.ff_core_Serializable_Serializable$ff_compiler_Syntax_Type).deserializeUsing_(serialization_))
1562
- return
1563
- }
1564
- }
1565
- {
1566
- 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)})
1567
- return
1568
- }
1569
- }
1570
- },
1571
- async serializeUsing_$(serialization_, value_, $task) {
1572
- {
1573
- const serialization_a = serialization_;
1574
- const value_a = value_;
1575
- {
1576
- const v_ = value_a;
1577
- serialization_.checksum_ = ff_core_Int.Int_bitOr(((31 * serialization_.checksum_) + 42), 0);
1578
- ff_core_Buffer.Buffer_setUint8(serialization_.buffer_, serialization_.offset_, 0);
1579
- serialization_.offset_ += 1;
1580
- ff_compiler_Syntax.ff_core_Serializable_Serializable$ff_compiler_Syntax_Location.serializeUsing_(serialization_, v_.at_);
1581
- ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_List_List(ff_compiler_Syntax.ff_core_Serializable_Serializable$ff_compiler_Syntax_Type).serializeUsing_(serialization_, v_.generics_)
1582
- return
1583
- }
1584
- }
1585
- },
1586
- async deserializeUsing_$(serialization_, $task) {
1587
- const variantIndex_ = ff_core_Buffer.Buffer_grabUint8(serialization_.buffer_, serialization_.offset_);
1588
- serialization_.offset_ += 1;
1589
- {
1590
- const _1 = variantIndex_;
1591
- {
1592
- if(_1 == 0) {
1593
- serialization_.checksum_ = ff_core_Int.Int_bitOr(((31 * serialization_.checksum_) + 42), 0);
1594
- return ff_compiler_Unification.ConstraintGenerics(ff_compiler_Syntax.ff_core_Serializable_Serializable$ff_compiler_Syntax_Location.deserializeUsing_(serialization_), ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_List_List(ff_compiler_Syntax.ff_core_Serializable_Serializable$ff_compiler_Syntax_Type).deserializeUsing_(serialization_))
1595
- return
1596
- }
1597
- }
1598
- {
1599
- 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)})
1600
- return
1601
- }
1602
- }
1603
- }
1604
- };
1605
-
1606
- export const ff_core_Serializable_Serializable$ff_compiler_Unification_InstanceKey = {
1607
- serializeUsing_(serialization_, value_) {
1608
- {
1609
- const serialization_a = serialization_;
1610
- const value_a = value_;
1611
- {
1612
- const v_ = value_a;
1613
- serialization_.checksum_ = ff_core_Int.Int_bitOr(((31 * serialization_.checksum_) + 35), 0);
1614
- ff_core_Buffer.Buffer_setUint8(serialization_.buffer_, serialization_.offset_, 0);
1615
- serialization_.offset_ += 1;
1616
- ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_String_String.serializeUsing_(serialization_, v_.traitName_);
1617
- ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_String_String.serializeUsing_(serialization_, v_.typeName_)
1618
- return
1619
- }
1620
- }
1621
- },
1622
- deserializeUsing_(serialization_) {
1623
- const variantIndex_ = ff_core_Buffer.Buffer_grabUint8(serialization_.buffer_, serialization_.offset_);
1624
- serialization_.offset_ += 1;
1625
- {
1626
- const _1 = variantIndex_;
1627
- {
1628
- if(_1 == 0) {
1629
- serialization_.checksum_ = ff_core_Int.Int_bitOr(((31 * serialization_.checksum_) + 35), 0);
1630
- return ff_compiler_Unification.InstanceKey(ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_String_String.deserializeUsing_(serialization_), ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_String_String.deserializeUsing_(serialization_))
1631
- return
1632
- }
1633
- }
1634
- {
1635
- 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)})
1636
- return
1637
- }
1638
- }
1639
- },
1640
- async serializeUsing_$(serialization_, value_, $task) {
1641
- {
1642
- const serialization_a = serialization_;
1643
- const value_a = value_;
1644
- {
1645
- const v_ = value_a;
1646
- serialization_.checksum_ = ff_core_Int.Int_bitOr(((31 * serialization_.checksum_) + 35), 0);
1647
- ff_core_Buffer.Buffer_setUint8(serialization_.buffer_, serialization_.offset_, 0);
1648
- serialization_.offset_ += 1;
1649
- ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_String_String.serializeUsing_(serialization_, v_.traitName_);
1650
- ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_String_String.serializeUsing_(serialization_, v_.typeName_)
1651
- return
1652
- }
1653
- }
1654
- },
1655
- async deserializeUsing_$(serialization_, $task) {
1656
- const variantIndex_ = ff_core_Buffer.Buffer_grabUint8(serialization_.buffer_, serialization_.offset_);
1657
- serialization_.offset_ += 1;
1658
- {
1659
- const _1 = variantIndex_;
1660
- {
1661
- if(_1 == 0) {
1662
- serialization_.checksum_ = ff_core_Int.Int_bitOr(((31 * serialization_.checksum_) + 35), 0);
1663
- return ff_compiler_Unification.InstanceKey(ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_String_String.deserializeUsing_(serialization_), ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_String_String.deserializeUsing_(serialization_))
1664
- return
1665
- }
1666
- }
1667
- {
1668
- 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)})
1669
- return
1670
- }
1671
- }
1672
- }
1673
- };
1674
-
1675
- export const ff_core_Serializable_Serializable$ff_compiler_Unification_InstanceValue = {
1676
- serializeUsing_(serialization_, value_) {
1677
- {
1678
- const serialization_a = serialization_;
1679
- const value_a = value_;
1680
- {
1681
- const v_ = value_a;
1682
- serialization_.checksum_ = ff_core_Int.Int_bitOr(((31 * serialization_.checksum_) + 37), 0);
1683
- ff_core_Buffer.Buffer_setUint8(serialization_.buffer_, serialization_.offset_, 0);
1684
- serialization_.offset_ += 1;
1685
- ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_List_List(ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_String_String).serializeUsing_(serialization_, v_.generics_);
1686
- ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_List_List(ff_compiler_Syntax.ff_core_Serializable_Serializable$ff_compiler_Syntax_Constraint).serializeUsing_(serialization_, v_.constraints_);
1687
- ff_compiler_Syntax.ff_core_Serializable_Serializable$ff_compiler_Syntax_PackagePair.serializeUsing_(serialization_, v_.packagePair_);
1688
- ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_String_String.serializeUsing_(serialization_, v_.moduleName_);
1689
- ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_String_String.serializeUsing_(serialization_, v_.traitName_);
1690
- ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_List_List(ff_compiler_Syntax.ff_core_Serializable_Serializable$ff_compiler_Syntax_Type).serializeUsing_(serialization_, v_.typeArguments_)
1691
- return
1692
- }
1693
- }
1694
- },
1695
- deserializeUsing_(serialization_) {
1696
- const variantIndex_ = ff_core_Buffer.Buffer_grabUint8(serialization_.buffer_, serialization_.offset_);
1697
- serialization_.offset_ += 1;
1698
- {
1699
- const _1 = variantIndex_;
1700
- {
1701
- if(_1 == 0) {
1702
- serialization_.checksum_ = ff_core_Int.Int_bitOr(((31 * serialization_.checksum_) + 37), 0);
1703
- return ff_compiler_Unification.InstanceValue(ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_List_List(ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_String_String).deserializeUsing_(serialization_), ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_List_List(ff_compiler_Syntax.ff_core_Serializable_Serializable$ff_compiler_Syntax_Constraint).deserializeUsing_(serialization_), ff_compiler_Syntax.ff_core_Serializable_Serializable$ff_compiler_Syntax_PackagePair.deserializeUsing_(serialization_), ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_String_String.deserializeUsing_(serialization_), ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_String_String.deserializeUsing_(serialization_), ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_List_List(ff_compiler_Syntax.ff_core_Serializable_Serializable$ff_compiler_Syntax_Type).deserializeUsing_(serialization_))
1704
- return
1705
- }
1706
- }
1707
- {
1708
- 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)})
1709
- return
1710
- }
1711
- }
1712
- },
1713
- async serializeUsing_$(serialization_, value_, $task) {
1714
- {
1715
- const serialization_a = serialization_;
1716
- const value_a = value_;
1717
- {
1718
- const v_ = value_a;
1719
- serialization_.checksum_ = ff_core_Int.Int_bitOr(((31 * serialization_.checksum_) + 37), 0);
1720
- ff_core_Buffer.Buffer_setUint8(serialization_.buffer_, serialization_.offset_, 0);
1721
- serialization_.offset_ += 1;
1722
- ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_List_List(ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_String_String).serializeUsing_(serialization_, v_.generics_);
1723
- ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_List_List(ff_compiler_Syntax.ff_core_Serializable_Serializable$ff_compiler_Syntax_Constraint).serializeUsing_(serialization_, v_.constraints_);
1724
- ff_compiler_Syntax.ff_core_Serializable_Serializable$ff_compiler_Syntax_PackagePair.serializeUsing_(serialization_, v_.packagePair_);
1725
- ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_String_String.serializeUsing_(serialization_, v_.moduleName_);
1726
- ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_String_String.serializeUsing_(serialization_, v_.traitName_);
1727
- ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_List_List(ff_compiler_Syntax.ff_core_Serializable_Serializable$ff_compiler_Syntax_Type).serializeUsing_(serialization_, v_.typeArguments_)
1728
- return
1729
- }
1730
- }
1731
- },
1732
- async deserializeUsing_$(serialization_, $task) {
1733
- const variantIndex_ = ff_core_Buffer.Buffer_grabUint8(serialization_.buffer_, serialization_.offset_);
1734
- serialization_.offset_ += 1;
1735
- {
1736
- const _1 = variantIndex_;
1737
- {
1738
- if(_1 == 0) {
1739
- serialization_.checksum_ = ff_core_Int.Int_bitOr(((31 * serialization_.checksum_) + 37), 0);
1740
- return ff_compiler_Unification.InstanceValue(ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_List_List(ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_String_String).deserializeUsing_(serialization_), ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_List_List(ff_compiler_Syntax.ff_core_Serializable_Serializable$ff_compiler_Syntax_Constraint).deserializeUsing_(serialization_), ff_compiler_Syntax.ff_core_Serializable_Serializable$ff_compiler_Syntax_PackagePair.deserializeUsing_(serialization_), ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_String_String.deserializeUsing_(serialization_), ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_String_String.deserializeUsing_(serialization_), ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_List_List(ff_compiler_Syntax.ff_core_Serializable_Serializable$ff_compiler_Syntax_Type).deserializeUsing_(serialization_))
1741
- return
1742
- }
1743
- }
1744
- {
1745
- 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)})
1746
- return
1747
- }
1748
- }
1749
- }
1750
- };
1751
-
1752
-
1
+
2
+
3
+ import * as ff_compiler_Unification from "../../ff/compiler/Unification.mjs"
4
+
5
+ import * as ff_compiler_Inference from "../../ff/compiler/Inference.mjs"
6
+
7
+ import * as ff_compiler_Syntax from "../../ff/compiler/Syntax.mjs"
8
+
9
+ import * as ff_core_Any from "../../ff/core/Any.mjs"
10
+
11
+ import * as ff_core_Array from "../../ff/core/Array.mjs"
12
+
13
+ import * as ff_core_AssetSystem from "../../ff/core/AssetSystem.mjs"
14
+
15
+ import * as ff_core_Atomic from "../../ff/core/Atomic.mjs"
16
+
17
+ import * as ff_core_Bool from "../../ff/core/Bool.mjs"
18
+
19
+ import * as ff_core_Box from "../../ff/core/Box.mjs"
20
+
21
+ import * as ff_core_BrowserSystem from "../../ff/core/BrowserSystem.mjs"
22
+
23
+ import * as ff_core_Buffer from "../../ff/core/Buffer.mjs"
24
+
25
+ import * as ff_core_BuildSystem from "../../ff/core/BuildSystem.mjs"
26
+
27
+ import * as ff_core_Channel from "../../ff/core/Channel.mjs"
28
+
29
+ import * as ff_core_Char from "../../ff/core/Char.mjs"
30
+
31
+ import * as ff_core_Core from "../../ff/core/Core.mjs"
32
+
33
+ import * as ff_core_Duration from "../../ff/core/Duration.mjs"
34
+
35
+ import * as ff_core_Equal from "../../ff/core/Equal.mjs"
36
+
37
+ import * as ff_core_Error from "../../ff/core/Error.mjs"
38
+
39
+ import * as ff_core_FileHandle from "../../ff/core/FileHandle.mjs"
40
+
41
+ import * as ff_core_Float from "../../ff/core/Float.mjs"
42
+
43
+ import * as ff_core_HttpClient from "../../ff/core/HttpClient.mjs"
44
+
45
+ import * as ff_core_Instant from "../../ff/core/Instant.mjs"
46
+
47
+ import * as ff_core_Int from "../../ff/core/Int.mjs"
48
+
49
+ import * as ff_core_IntMap from "../../ff/core/IntMap.mjs"
50
+
51
+ import * as ff_core_JsSystem from "../../ff/core/JsSystem.mjs"
52
+
53
+ import * as ff_core_JsValue from "../../ff/core/JsValue.mjs"
54
+
55
+ import * as ff_core_List from "../../ff/core/List.mjs"
56
+
57
+ import * as ff_core_Lock from "../../ff/core/Lock.mjs"
58
+
59
+ import * as ff_core_Log from "../../ff/core/Log.mjs"
60
+
61
+ import * as ff_core_Map from "../../ff/core/Map.mjs"
62
+
63
+ import * as ff_core_NodeSystem from "../../ff/core/NodeSystem.mjs"
64
+
65
+ import * as ff_core_Nothing from "../../ff/core/Nothing.mjs"
66
+
67
+ import * as ff_core_Option from "../../ff/core/Option.mjs"
68
+
69
+ import * as ff_core_Ordering from "../../ff/core/Ordering.mjs"
70
+
71
+ import * as ff_core_Pair from "../../ff/core/Pair.mjs"
72
+
73
+ import * as ff_core_Path from "../../ff/core/Path.mjs"
74
+
75
+ import * as ff_core_Random from "../../ff/core/Random.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
+ import * as ff_core_WebSocket from "../../ff/core/WebSocket.mjs"
100
+
101
+ // type Unification
102
+ export function Unification(substitution_, constraints_, nextUnificationVariableIndex_, instances_, affects_, attemptFixes_) {
103
+ return {substitution_, constraints_, nextUnificationVariableIndex_, instances_, affects_, attemptFixes_};
104
+ }
105
+
106
+ // type ConstraintGenerics
107
+ export function ConstraintGenerics(at_, generics_) {
108
+ return {at_, generics_};
109
+ }
110
+
111
+ // type InstanceKey
112
+ export function InstanceKey(traitName_, typeName_) {
113
+ return {traitName_, typeName_};
114
+ }
115
+
116
+ // type InstanceValue
117
+ export function InstanceValue(generics_, constraints_, packagePair_, moduleName_, traitName_, typeArguments_) {
118
+ return {generics_, constraints_, packagePair_, moduleName_, traitName_, typeArguments_};
119
+ }
120
+
121
+
122
+
123
+ export function fail_(at_, message_) {
124
+ throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(at_, message_), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
125
+ }
126
+
127
+ export function make_(modules_, attemptFixes_) {
128
+ return ff_compiler_Unification.Unification(ff_core_Map.empty_(), ff_core_Map.empty_(), 3, ff_core_List.List_toMap(ff_core_List.List_flatMap(modules_, ((module_) => {
129
+ const moduleName_ = ff_core_String.String_dropLast(module_.file_, ff_core_String.String_size(".ff"));
130
+ return ff_core_List.List_map(module_.instances_, ((definition_) => {
131
+ const typeName_ = (((_1) => {
132
+ {
133
+ if(_1.TConstructor) {
134
+ const name_ = _1.name_;
135
+ return name_
136
+ return
137
+ }
138
+ }
139
+ {
140
+ if(_1.TVariable) {
141
+ const i_ = _1.index_;
142
+ return ff_compiler_Unification.fail_(definition_.at_, ("Unexpected unification variable: $" + i_))
143
+ return
144
+ }
145
+ }
146
+ }))(ff_core_List.List_grabFirst(definition_.typeArguments_));
147
+ return ff_core_Pair.Pair(ff_compiler_Unification.InstanceKey(definition_.traitName_, typeName_), ff_compiler_Unification.InstanceValue(definition_.generics_, definition_.constraints_, module_.packagePair_, moduleName_, definition_.traitName_, definition_.typeArguments_))
148
+ }))
149
+ })), ff_compiler_Unification.ff_core_Ordering_Order$ff_compiler_Unification_InstanceKey), ff_core_List.List_toMap(ff_core_List.Empty(), ff_core_Ordering.ff_core_Ordering_Order$ff_core_Int_Int), attemptFixes_)
150
+ }
151
+
152
+ export async function fail_$(at_, message_, $task) {
153
+ throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(at_, message_), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
154
+ }
155
+
156
+ export async function make_$(modules_, attemptFixes_, $task) {
157
+ return ff_compiler_Unification.Unification(ff_core_Map.empty_(), ff_core_Map.empty_(), 3, ff_core_List.List_toMap(ff_core_List.List_flatMap(modules_, ((module_) => {
158
+ const moduleName_ = ff_core_String.String_dropLast(module_.file_, ff_core_String.String_size(".ff"));
159
+ return ff_core_List.List_map(module_.instances_, ((definition_) => {
160
+ const typeName_ = (((_1) => {
161
+ {
162
+ if(_1.TConstructor) {
163
+ const name_ = _1.name_;
164
+ return name_
165
+ return
166
+ }
167
+ }
168
+ {
169
+ if(_1.TVariable) {
170
+ const i_ = _1.index_;
171
+ return ff_compiler_Unification.fail_(definition_.at_, ("Unexpected unification variable: $" + i_))
172
+ return
173
+ }
174
+ }
175
+ }))(ff_core_List.List_grabFirst(definition_.typeArguments_));
176
+ return ff_core_Pair.Pair(ff_compiler_Unification.InstanceKey(definition_.traitName_, typeName_), ff_compiler_Unification.InstanceValue(definition_.generics_, definition_.constraints_, module_.packagePair_, moduleName_, definition_.traitName_, definition_.typeArguments_))
177
+ }))
178
+ })), ff_compiler_Unification.ff_core_Ordering_Order$ff_compiler_Unification_InstanceKey), ff_core_List.List_toMap(ff_core_List.Empty(), ff_core_Ordering.ff_core_Ordering_Order$ff_core_Int_Int), attemptFixes_)
179
+ }
180
+
181
+ export function Unification_withLocalInstances(self_, instances_, body_) {
182
+ const oldInstances_ = self_.instances_;
183
+ self_.instances_ = ff_core_Map.Map_addAll(self_.instances_, instances_, ff_compiler_Unification.ff_core_Ordering_Order$ff_compiler_Unification_InstanceKey);
184
+ try {
185
+ return body_()
186
+ } finally {
187
+ self_.instances_ = oldInstances_
188
+ }
189
+ }
190
+
191
+ export function Unification_freshUnificationVariable(self_, at_) {
192
+ const result_ = ff_compiler_Syntax.TVariable(at_, self_.nextUnificationVariableIndex_);
193
+ self_.nextUnificationVariableIndex_ += 3;
194
+ return result_
195
+ }
196
+
197
+ export function Unification_instantiate(self_, instantiation_, type_) {
198
+ {
199
+ const self_a = self_;
200
+ const instantiation_a = instantiation_;
201
+ const type_a = type_;
202
+ {
203
+ if(type_a.TConstructor) {
204
+ const at_ = type_a.at_;
205
+ const name_ = type_a.name_;
206
+ if(type_a.generics_.Empty) {
207
+ {
208
+ const _1 = ff_core_Map.Map_get(instantiation_, name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
209
+ {
210
+ if(_1.Some) {
211
+ const t_ = _1.value_;
212
+ return t_
213
+ return
214
+ }
215
+ }
216
+ {
217
+ if(_1.None) {
218
+ return type_
219
+ return
220
+ }
221
+ }
222
+ }
223
+ return
224
+ }
225
+ }
226
+ }
227
+ {
228
+ if(type_a.TConstructor) {
229
+ const at_ = type_a.at_;
230
+ const name_ = type_a.name_;
231
+ const generics_ = type_a.generics_;
232
+ return ff_compiler_Syntax.TConstructor(at_, name_, ff_core_List.List_map(generics_, ((_w1) => {
233
+ return ff_compiler_Unification.Unification_instantiate(self_, instantiation_, _w1)
234
+ })))
235
+ return
236
+ }
237
+ }
238
+ {
239
+ if(type_a.TVariable) {
240
+ const i_ = type_a.index_;
241
+ const _guard1 = ff_compiler_Unification.Unification_get(self_, i_);
242
+ if(_guard1.Some) {
243
+ const t_ = _guard1.value_;
244
+ return ff_compiler_Unification.Unification_instantiate(self_, instantiation_, t_)
245
+ return
246
+ }
247
+ }
248
+ }
249
+ {
250
+ if(type_a.TVariable) {
251
+ const i_ = type_a.index_;
252
+ return type_
253
+ return
254
+ }
255
+ }
256
+ }
257
+ }
258
+
259
+ export function Unification_instantiateConstraint(self_, instantiation_, constraint_) {
260
+ {
261
+ const self_a = self_;
262
+ const instantiation_a = instantiation_;
263
+ const constraint_a = constraint_;
264
+ {
265
+ const at_ = constraint_a.at_;
266
+ const name_ = constraint_a.name_;
267
+ const generics_ = constraint_a.generics_;
268
+ return ff_compiler_Syntax.Constraint(at_, name_, ff_core_List.List_map(generics_, ((_w1) => {
269
+ return ff_compiler_Unification.Unification_instantiate(self_, instantiation_, _w1)
270
+ })))
271
+ return
272
+ }
273
+ }
274
+ }
275
+
276
+ export function Unification_constrain(self_, at_, type_, constraintName_, generics_) {
277
+ {
278
+ const _1 = type_;
279
+ {
280
+ if(_1.TVariable) {
281
+ const i_ = _1.index_;
282
+ const _guard1 = ff_compiler_Unification.Unification_get(self_, i_);
283
+ if(_guard1.Some) {
284
+ const t_ = _guard1.value_;
285
+ ff_compiler_Unification.Unification_constrain(self_, at_, t_, constraintName_, generics_)
286
+ return
287
+ }
288
+ }
289
+ }
290
+ {
291
+ if(_1.TVariable) {
292
+ const i_ = _1.index_;
293
+ {
294
+ const _1 = ff_core_Map.Map_get(self_.constraints_, i_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_Int_Int);
295
+ {
296
+ if(_1.None) {
297
+ self_.constraints_ = ff_core_Map.Map_add(self_.constraints_, i_, ff_core_List.List_toMap(ff_core_List.Link(ff_core_Pair.Pair(constraintName_, ff_compiler_Unification.ConstraintGenerics(at_, generics_)), ff_core_List.Empty()), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Ordering.ff_core_Ordering_Order$ff_core_Int_Int)
298
+ return
299
+ }
300
+ }
301
+ {
302
+ if(_1.Some) {
303
+ const map_ = _1.value_;
304
+ {
305
+ const _1 = ff_core_Map.Map_get(map_, constraintName_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
306
+ {
307
+ if(_1.None) {
308
+ const newMap_ = ff_core_Map.Map_add(map_, constraintName_, ff_compiler_Unification.ConstraintGenerics(at_, generics_), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
309
+ self_.constraints_ = ff_core_Map.Map_add(self_.constraints_, i_, newMap_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_Int_Int)
310
+ return
311
+ }
312
+ }
313
+ {
314
+ if(_1.Some) {
315
+ const generics2_ = _1.value_.generics_;
316
+ ff_core_List.List_each(ff_core_List.List_zip(generics_, generics2_), ((_1) => {
317
+ {
318
+ const t1_ = _1.first_;
319
+ const t2_ = _1.second_;
320
+ ff_compiler_Unification.Unification_unify(self_, at_, t1_, t2_)
321
+ return
322
+ }
323
+ }))
324
+ return
325
+ }
326
+ }
327
+ }
328
+ return
329
+ }
330
+ }
331
+ }
332
+ return
333
+ }
334
+ }
335
+ {
336
+ if(_1.TConstructor) {
337
+ const name_ = _1.name_;
338
+ const generics2_ = _1.generics_;
339
+ {
340
+ const _1 = ff_core_Map.Map_get(self_.instances_, ff_compiler_Unification.InstanceKey(constraintName_, name_), ff_compiler_Unification.ff_core_Ordering_Order$ff_compiler_Unification_InstanceKey);
341
+ {
342
+ if(_1.None) {
343
+ const g1_ = (ff_core_List.List_isEmpty(generics_)
344
+ ? ""
345
+ : "[...]");
346
+ const g2_ = (ff_core_List.List_isEmpty(generics2_)
347
+ ? ""
348
+ : "[...]");
349
+ if((!self_.attemptFixes_)) {
350
+ throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(at_, ((((("No such instance: " + name_) + g2_) + ": ") + constraintName_) + g1_)), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
351
+ }
352
+ return
353
+ }
354
+ }
355
+ {
356
+ if(_1.Some) {
357
+ const definition_ = _1.value_;
358
+ const unificationVariables_ = ff_core_List.List_map(definition_.generics_, ((_) => {
359
+ return ff_compiler_Unification.Unification_freshUnificationVariable(self_, at_)
360
+ }));
361
+ const instantiation_ = ff_core_List.List_toMap(ff_core_List.List_zip(definition_.generics_, unificationVariables_), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
362
+ const traitType1_ = ff_compiler_Unification.Unification_instantiate(self_, instantiation_, ff_compiler_Syntax.TConstructor(at_, definition_.traitName_, definition_.typeArguments_));
363
+ const traitType2_ = ff_compiler_Syntax.TConstructor(at_, constraintName_, ff_core_List.Link(type_, generics_));
364
+ ff_compiler_Unification.Unification_unify(self_, at_, traitType1_, traitType2_);
365
+ ff_core_List.List_each(definition_.constraints_, ((constraint_) => {
366
+ {
367
+ const _1 = ff_compiler_Unification.Unification_instantiateConstraint(self_, instantiation_, constraint_);
368
+ {
369
+ const constraintName_ = _1.name_;
370
+ const newGenerics_ = _1.generics_;
371
+ ff_compiler_Unification.Unification_constrain(self_, at_, ff_core_List.List_grabFirst(newGenerics_), constraintName_, ff_core_List.List_dropFirst(newGenerics_, 1))
372
+ return
373
+ }
374
+ }
375
+ }))
376
+ return
377
+ }
378
+ }
379
+ }
380
+ return
381
+ }
382
+ }
383
+ }
384
+ }
385
+
386
+ export function Unification_get(self_, index_) {
387
+ return ff_core_Option.Option_map(ff_core_Map.Map_get(self_.substitution_, index_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_Int_Int), ((_1) => {
388
+ {
389
+ if(_1.TVariable) {
390
+ const i_ = _1.index_;
391
+ const _guard1 = ff_core_Map.Map_get(self_.substitution_, i_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_Int_Int);
392
+ if(_guard1.Some) {
393
+ const t_ = _guard1.value_;
394
+ self_.substitution_ = ff_core_Map.Map_add(self_.substitution_, index_, t_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_Int_Int);
395
+ return t_
396
+ return
397
+ }
398
+ }
399
+ }
400
+ {
401
+ const t_ = _1;
402
+ return t_
403
+ return
404
+ }
405
+ }))
406
+ }
407
+
408
+ export function Unification_substitute(self_, type_) {
409
+ {
410
+ const self_a = self_;
411
+ const type_a = type_;
412
+ {
413
+ if(type_a.TVariable) {
414
+ const i_ = type_a.index_;
415
+ const _guard1 = ff_compiler_Unification.Unification_get(self_, i_);
416
+ if(_guard1.Some) {
417
+ const t_ = _guard1.value_;
418
+ return ff_compiler_Unification.Unification_substitute(self_, t_)
419
+ return
420
+ }
421
+ }
422
+ }
423
+ {
424
+ if(type_a.TVariable) {
425
+ return type_
426
+ return
427
+ }
428
+ }
429
+ {
430
+ if(type_a.TConstructor) {
431
+ const t_ = type_a;
432
+ {
433
+ const _1 = t_;
434
+ {
435
+ const _c = _1;
436
+ return ff_compiler_Syntax.TConstructor(_c.at_, _c.name_, ff_core_List.List_map(t_.generics_, ((t_) => {
437
+ return ff_compiler_Unification.Unification_substitute(self_, t_)
438
+ })))
439
+ return
440
+ }
441
+ }
442
+ return
443
+ }
444
+ }
445
+ }
446
+ }
447
+
448
+ export function Unification_unify(self_, at_, t1_, t2_) {
449
+ {
450
+ const self_a = self_;
451
+ const at_a = at_;
452
+ const t1_a = t1_;
453
+ const t2_a = t2_;
454
+ {
455
+ if(t1_a.TVariable) {
456
+ const i1_ = t1_a.index_;
457
+ if(t2_a.TVariable) {
458
+ const i2_ = t2_a.index_;
459
+ const _guard1 = (i1_ === i2_);
460
+ if(_guard1) {
461
+
462
+ return
463
+ }
464
+ }
465
+ }
466
+ }
467
+ {
468
+ if(t1_a.TVariable) {
469
+ const i_ = t1_a.index_;
470
+ const _guard1 = ff_compiler_Unification.Unification_get(self_, i_);
471
+ if(_guard1.Some) {
472
+ const t_ = _guard1.value_;
473
+ ff_compiler_Unification.Unification_unify(self_, at_, t_, t2_)
474
+ return
475
+ }
476
+ }
477
+ }
478
+ {
479
+ if(t2_a.TVariable) {
480
+ const i_ = t2_a.index_;
481
+ const _guard1 = ff_compiler_Unification.Unification_get(self_, i_);
482
+ if(_guard1.Some) {
483
+ const t_ = _guard1.value_;
484
+ ff_compiler_Unification.Unification_unify(self_, at_, t1_, t_)
485
+ return
486
+ }
487
+ }
488
+ }
489
+ {
490
+ if(t1_a.TVariable) {
491
+ const i_ = t1_a.index_;
492
+ ff_compiler_Unification.Unification_bind(self_, at_, i_, t2_)
493
+ return
494
+ }
495
+ }
496
+ {
497
+ if(t2_a.TVariable) {
498
+ const i_ = t2_a.index_;
499
+ ff_compiler_Unification.Unification_bind(self_, at_, i_, t1_)
500
+ return
501
+ }
502
+ }
503
+ {
504
+ if(t1_a.TConstructor) {
505
+ const name1_ = t1_a.name_;
506
+ const generics1_ = t1_a.generics_;
507
+ if(t2_a.TConstructor) {
508
+ const name2_ = t2_a.name_;
509
+ const generics2_ = t2_a.generics_;
510
+ if(((name1_ !== name2_) || (ff_core_List.List_size(generics1_) !== ff_core_List.List_size(generics2_)))) {
511
+ if((!self_.attemptFixes_)) {
512
+ const t3_ = ff_compiler_Unification.Unification_substitute(self_, t1_);
513
+ const t4_ = ff_compiler_Unification.Unification_substitute(self_, t2_);
514
+ throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(at_, ((("Type mismatch: " + ff_compiler_Syntax.Type_show(t3_, ff_core_List.Link(t3_, ff_core_List.Link(t4_, ff_core_List.Empty())))) + " vs. ") + ff_compiler_Syntax.Type_show(t4_, ff_core_List.Link(t3_, ff_core_List.Link(t4_, ff_core_List.Empty()))))), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
515
+ } else if((ff_core_String.String_startsWith(name1_, "Function$", 0) && ff_core_String.String_startsWith(name2_, "Function$", 0))) {
516
+ ff_core_List.List_each(ff_core_List.List_zip(ff_core_List.List_dropLast(generics1_, 1), ff_core_List.List_dropLast(generics2_, 1)), ((_1) => {
517
+ {
518
+ const t3_ = _1.first_;
519
+ const t4_ = _1.second_;
520
+ ff_compiler_Unification.Unification_unify(self_, at_, t3_, t4_)
521
+ return
522
+ }
523
+ }));
524
+ ff_core_List.List_each(ff_core_List.List_zip(ff_core_List.List_takeLast(generics1_, 1), ff_core_List.List_takeLast(generics2_, 1)), ((_1) => {
525
+ {
526
+ const t3_ = _1.first_;
527
+ const t4_ = _1.second_;
528
+ ff_compiler_Unification.Unification_unify(self_, at_, t3_, t4_)
529
+ return
530
+ }
531
+ }))
532
+ } else {}
533
+ } else {
534
+ ff_core_List.List_each(ff_core_List.List_zip(generics1_, generics2_), ((_1) => {
535
+ {
536
+ const t1_ = _1.first_;
537
+ const t2_ = _1.second_;
538
+ ff_compiler_Unification.Unification_unify(self_, at_, t1_, t2_)
539
+ return
540
+ }
541
+ }))
542
+ }
543
+ return
544
+ }
545
+ }
546
+ }
547
+ }
548
+ }
549
+
550
+ export function Unification_bind(self_, at_, index_, type_) {
551
+ if(ff_compiler_Unification.Unification_occursIn(self_, index_, type_)) {
552
+ const t_ = ff_compiler_Unification.Unification_substitute(self_, type_);
553
+ throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(at_, ((("Infinite type: " + ff_compiler_Syntax.Type_show(ff_compiler_Syntax.TVariable(at_, index_), ff_core_List.Link(t_, ff_core_List.Empty()))) + " = ") + ff_compiler_Syntax.Type_show(t_, ff_core_List.Empty()))), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
554
+ };
555
+ self_.substitution_ = ff_core_Map.Map_add(self_.substitution_, index_, type_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_Int_Int);
556
+ ff_core_Option.Option_each(ff_core_Map.Map_get(self_.constraints_, index_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_Int_Int), ((map_) => {
557
+ self_.constraints_ = ff_core_Map.Map_remove(self_.constraints_, index_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_Int_Int);
558
+ ff_core_List.List_each(ff_core_Map.Map_pairs(map_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ((_1) => {
559
+ {
560
+ const name_ = _1.first_;
561
+ const at2_ = _1.second_.at_;
562
+ const generics_ = _1.second_.generics_;
563
+ ff_compiler_Unification.Unification_constrain(self_, at2_, type_, name_, generics_)
564
+ return
565
+ }
566
+ }))
567
+ }));
568
+ ff_core_Option.Option_each(ff_core_Map.Map_get(self_.affects_, index_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_Int_Int), ((affected_) => {
569
+ ff_core_Map.Map_remove(self_.affects_, index_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_Int_Int);
570
+ ff_core_Set.Set_each(affected_, ((i_) => {
571
+ ff_compiler_Unification.Unification_affect(self_, at_, type_, ff_compiler_Syntax.TVariable(at_, i_))
572
+ }), ff_core_Ordering.ff_core_Ordering_Order$ff_core_Int_Int)
573
+ }))
574
+ }
575
+
576
+ export function Unification_affect(self_, at_, source_, target_) {
577
+ {
578
+ const _1 = ff_core_Pair.Pair(ff_compiler_Unification.Unification_substitute(self_, source_), ff_compiler_Unification.Unification_substitute(self_, target_));
579
+ {
580
+ if(_1.first_.TVariable) {
581
+ const i1_ = _1.first_.index_;
582
+ if(_1.second_.TVariable) {
583
+ const i2_ = _1.second_.index_;
584
+ const is_ = ff_core_Option.Option_else(ff_core_Map.Map_get(self_.affects_, i1_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_Int_Int), (() => {
585
+ return ff_core_List.List_toSet(ff_core_List.Empty(), ff_core_Ordering.ff_core_Ordering_Order$ff_core_Int_Int)
586
+ }));
587
+ self_.affects_ = ff_core_Map.Map_add(self_.affects_, i1_, ff_core_Set.Set_add(is_, i2_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_Int_Int), ff_core_Ordering.ff_core_Ordering_Order$ff_core_Int_Int)
588
+ return
589
+ }
590
+ }
591
+ }
592
+ {
593
+ if(_1.second_.TConstructor) {
594
+ if(_1.second_.name_ == "Q$") {
595
+
596
+ return
597
+ }
598
+ }
599
+ }
600
+ {
601
+ if(_1.first_.TConstructor) {
602
+ if(_1.first_.name_ == "ff:core/Nothing.Nothing") {
603
+
604
+ return
605
+ }
606
+ }
607
+ }
608
+ {
609
+ const t1_ = _1.first_;
610
+ const t2_ = _1.second_;
611
+ ff_compiler_Unification.Unification_unify(self_, at_, t1_, t2_)
612
+ return
613
+ }
614
+ }
615
+ }
616
+
617
+ export function Unification_occursIn(self_, index_, t_) {
618
+ {
619
+ const self_a = self_;
620
+ const index_a = index_;
621
+ const t_a = t_;
622
+ {
623
+ if(t_a.TVariable) {
624
+ const i_ = t_a.index_;
625
+ const _guard1 = ff_compiler_Unification.Unification_get(self_, i_);
626
+ if(_guard1.Some) {
627
+ const type_ = _guard1.value_;
628
+ return ff_compiler_Unification.Unification_occursIn(self_, index_, type_)
629
+ return
630
+ }
631
+ }
632
+ }
633
+ {
634
+ if(t_a.TVariable) {
635
+ const i_ = t_a.index_;
636
+ return (i_ === index_)
637
+ return
638
+ }
639
+ }
640
+ {
641
+ if(t_a.TConstructor) {
642
+ const generics_ = t_a.generics_;
643
+ return ff_core_List.List_any(generics_, ((t_) => {
644
+ return ff_compiler_Unification.Unification_occursIn(self_, index_, t_)
645
+ }))
646
+ return
647
+ }
648
+ }
649
+ }
650
+ }
651
+
652
+ export async function Unification_withLocalInstances$(self_, instances_, body_, $task) {
653
+ const oldInstances_ = self_.instances_;
654
+ self_.instances_ = ff_core_Map.Map_addAll(self_.instances_, instances_, ff_compiler_Unification.ff_core_Ordering_Order$ff_compiler_Unification_InstanceKey);
655
+ try {
656
+ return (await body_($task))
657
+ } finally {
658
+ self_.instances_ = oldInstances_
659
+ }
660
+ }
661
+
662
+ export async function Unification_freshUnificationVariable$(self_, at_, $task) {
663
+ const result_ = ff_compiler_Syntax.TVariable(at_, self_.nextUnificationVariableIndex_);
664
+ self_.nextUnificationVariableIndex_ += 3;
665
+ return result_
666
+ }
667
+
668
+ export async function Unification_instantiate$(self_, instantiation_, type_, $task) {
669
+ {
670
+ const self_a = self_;
671
+ const instantiation_a = instantiation_;
672
+ const type_a = type_;
673
+ {
674
+ if(type_a.TConstructor) {
675
+ const at_ = type_a.at_;
676
+ const name_ = type_a.name_;
677
+ if(type_a.generics_.Empty) {
678
+ {
679
+ const _1 = ff_core_Map.Map_get(instantiation_, name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
680
+ {
681
+ if(_1.Some) {
682
+ const t_ = _1.value_;
683
+ return t_
684
+ return
685
+ }
686
+ }
687
+ {
688
+ if(_1.None) {
689
+ return type_
690
+ return
691
+ }
692
+ }
693
+ }
694
+ return
695
+ }
696
+ }
697
+ }
698
+ {
699
+ if(type_a.TConstructor) {
700
+ const at_ = type_a.at_;
701
+ const name_ = type_a.name_;
702
+ const generics_ = type_a.generics_;
703
+ return ff_compiler_Syntax.TConstructor(at_, name_, ff_core_List.List_map(generics_, ((_w1) => {
704
+ return ff_compiler_Unification.Unification_instantiate(self_, instantiation_, _w1)
705
+ })))
706
+ return
707
+ }
708
+ }
709
+ {
710
+ if(type_a.TVariable) {
711
+ const i_ = type_a.index_;
712
+ const _guard1 = ff_compiler_Unification.Unification_get(self_, i_);
713
+ if(_guard1.Some) {
714
+ const t_ = _guard1.value_;
715
+ return ff_compiler_Unification.Unification_instantiate(self_, instantiation_, t_)
716
+ return
717
+ }
718
+ }
719
+ }
720
+ {
721
+ if(type_a.TVariable) {
722
+ const i_ = type_a.index_;
723
+ return type_
724
+ return
725
+ }
726
+ }
727
+ }
728
+ }
729
+
730
+ export async function Unification_instantiateConstraint$(self_, instantiation_, constraint_, $task) {
731
+ {
732
+ const self_a = self_;
733
+ const instantiation_a = instantiation_;
734
+ const constraint_a = constraint_;
735
+ {
736
+ const at_ = constraint_a.at_;
737
+ const name_ = constraint_a.name_;
738
+ const generics_ = constraint_a.generics_;
739
+ return ff_compiler_Syntax.Constraint(at_, name_, ff_core_List.List_map(generics_, ((_w1) => {
740
+ return ff_compiler_Unification.Unification_instantiate(self_, instantiation_, _w1)
741
+ })))
742
+ return
743
+ }
744
+ }
745
+ }
746
+
747
+ export async function Unification_constrain$(self_, at_, type_, constraintName_, generics_, $task) {
748
+ {
749
+ const _1 = type_;
750
+ {
751
+ if(_1.TVariable) {
752
+ const i_ = _1.index_;
753
+ const _guard1 = ff_compiler_Unification.Unification_get(self_, i_);
754
+ if(_guard1.Some) {
755
+ const t_ = _guard1.value_;
756
+ ff_compiler_Unification.Unification_constrain(self_, at_, t_, constraintName_, generics_)
757
+ return
758
+ }
759
+ }
760
+ }
761
+ {
762
+ if(_1.TVariable) {
763
+ const i_ = _1.index_;
764
+ {
765
+ const _1 = ff_core_Map.Map_get(self_.constraints_, i_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_Int_Int);
766
+ {
767
+ if(_1.None) {
768
+ self_.constraints_ = ff_core_Map.Map_add(self_.constraints_, i_, ff_core_List.List_toMap(ff_core_List.Link(ff_core_Pair.Pair(constraintName_, ff_compiler_Unification.ConstraintGenerics(at_, generics_)), ff_core_List.Empty()), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Ordering.ff_core_Ordering_Order$ff_core_Int_Int)
769
+ return
770
+ }
771
+ }
772
+ {
773
+ if(_1.Some) {
774
+ const map_ = _1.value_;
775
+ {
776
+ const _1 = ff_core_Map.Map_get(map_, constraintName_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
777
+ {
778
+ if(_1.None) {
779
+ const newMap_ = ff_core_Map.Map_add(map_, constraintName_, ff_compiler_Unification.ConstraintGenerics(at_, generics_), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
780
+ self_.constraints_ = ff_core_Map.Map_add(self_.constraints_, i_, newMap_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_Int_Int)
781
+ return
782
+ }
783
+ }
784
+ {
785
+ if(_1.Some) {
786
+ const generics2_ = _1.value_.generics_;
787
+ ff_core_List.List_each(ff_core_List.List_zip(generics_, generics2_), ((_1) => {
788
+ {
789
+ const t1_ = _1.first_;
790
+ const t2_ = _1.second_;
791
+ ff_compiler_Unification.Unification_unify(self_, at_, t1_, t2_)
792
+ return
793
+ }
794
+ }))
795
+ return
796
+ }
797
+ }
798
+ }
799
+ return
800
+ }
801
+ }
802
+ }
803
+ return
804
+ }
805
+ }
806
+ {
807
+ if(_1.TConstructor) {
808
+ const name_ = _1.name_;
809
+ const generics2_ = _1.generics_;
810
+ {
811
+ const _1 = ff_core_Map.Map_get(self_.instances_, ff_compiler_Unification.InstanceKey(constraintName_, name_), ff_compiler_Unification.ff_core_Ordering_Order$ff_compiler_Unification_InstanceKey);
812
+ {
813
+ if(_1.None) {
814
+ const g1_ = (ff_core_List.List_isEmpty(generics_)
815
+ ? ""
816
+ : "[...]");
817
+ const g2_ = (ff_core_List.List_isEmpty(generics2_)
818
+ ? ""
819
+ : "[...]");
820
+ if((!self_.attemptFixes_)) {
821
+ throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(at_, ((((("No such instance: " + name_) + g2_) + ": ") + constraintName_) + g1_)), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
822
+ }
823
+ return
824
+ }
825
+ }
826
+ {
827
+ if(_1.Some) {
828
+ const definition_ = _1.value_;
829
+ const unificationVariables_ = ff_core_List.List_map(definition_.generics_, ((_) => {
830
+ return ff_compiler_Unification.Unification_freshUnificationVariable(self_, at_)
831
+ }));
832
+ const instantiation_ = ff_core_List.List_toMap(ff_core_List.List_zip(definition_.generics_, unificationVariables_), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
833
+ const traitType1_ = ff_compiler_Unification.Unification_instantiate(self_, instantiation_, ff_compiler_Syntax.TConstructor(at_, definition_.traitName_, definition_.typeArguments_));
834
+ const traitType2_ = ff_compiler_Syntax.TConstructor(at_, constraintName_, ff_core_List.Link(type_, generics_));
835
+ ff_compiler_Unification.Unification_unify(self_, at_, traitType1_, traitType2_);
836
+ ff_core_List.List_each(definition_.constraints_, ((constraint_) => {
837
+ {
838
+ const _1 = ff_compiler_Unification.Unification_instantiateConstraint(self_, instantiation_, constraint_);
839
+ {
840
+ const constraintName_ = _1.name_;
841
+ const newGenerics_ = _1.generics_;
842
+ ff_compiler_Unification.Unification_constrain(self_, at_, ff_core_List.List_grabFirst(newGenerics_), constraintName_, ff_core_List.List_dropFirst(newGenerics_, 1))
843
+ return
844
+ }
845
+ }
846
+ }))
847
+ return
848
+ }
849
+ }
850
+ }
851
+ return
852
+ }
853
+ }
854
+ }
855
+ }
856
+
857
+ export async function Unification_get$(self_, index_, $task) {
858
+ return ff_core_Option.Option_map(ff_core_Map.Map_get(self_.substitution_, index_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_Int_Int), ((_1) => {
859
+ {
860
+ if(_1.TVariable) {
861
+ const i_ = _1.index_;
862
+ const _guard1 = ff_core_Map.Map_get(self_.substitution_, i_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_Int_Int);
863
+ if(_guard1.Some) {
864
+ const t_ = _guard1.value_;
865
+ self_.substitution_ = ff_core_Map.Map_add(self_.substitution_, index_, t_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_Int_Int);
866
+ return t_
867
+ return
868
+ }
869
+ }
870
+ }
871
+ {
872
+ const t_ = _1;
873
+ return t_
874
+ return
875
+ }
876
+ }))
877
+ }
878
+
879
+ export async function Unification_substitute$(self_, type_, $task) {
880
+ {
881
+ const self_a = self_;
882
+ const type_a = type_;
883
+ {
884
+ if(type_a.TVariable) {
885
+ const i_ = type_a.index_;
886
+ const _guard1 = ff_compiler_Unification.Unification_get(self_, i_);
887
+ if(_guard1.Some) {
888
+ const t_ = _guard1.value_;
889
+ return ff_compiler_Unification.Unification_substitute(self_, t_)
890
+ return
891
+ }
892
+ }
893
+ }
894
+ {
895
+ if(type_a.TVariable) {
896
+ return type_
897
+ return
898
+ }
899
+ }
900
+ {
901
+ if(type_a.TConstructor) {
902
+ const t_ = type_a;
903
+ {
904
+ const _1 = t_;
905
+ {
906
+ const _c = _1;
907
+ return ff_compiler_Syntax.TConstructor(_c.at_, _c.name_, ff_core_List.List_map(t_.generics_, ((t_) => {
908
+ return ff_compiler_Unification.Unification_substitute(self_, t_)
909
+ })))
910
+ return
911
+ }
912
+ }
913
+ return
914
+ }
915
+ }
916
+ }
917
+ }
918
+
919
+ export async function Unification_unify$(self_, at_, t1_, t2_, $task) {
920
+ {
921
+ const self_a = self_;
922
+ const at_a = at_;
923
+ const t1_a = t1_;
924
+ const t2_a = t2_;
925
+ {
926
+ if(t1_a.TVariable) {
927
+ const i1_ = t1_a.index_;
928
+ if(t2_a.TVariable) {
929
+ const i2_ = t2_a.index_;
930
+ const _guard1 = (i1_ === i2_);
931
+ if(_guard1) {
932
+
933
+ return
934
+ }
935
+ }
936
+ }
937
+ }
938
+ {
939
+ if(t1_a.TVariable) {
940
+ const i_ = t1_a.index_;
941
+ const _guard1 = ff_compiler_Unification.Unification_get(self_, i_);
942
+ if(_guard1.Some) {
943
+ const t_ = _guard1.value_;
944
+ ff_compiler_Unification.Unification_unify(self_, at_, t_, t2_)
945
+ return
946
+ }
947
+ }
948
+ }
949
+ {
950
+ if(t2_a.TVariable) {
951
+ const i_ = t2_a.index_;
952
+ const _guard1 = ff_compiler_Unification.Unification_get(self_, i_);
953
+ if(_guard1.Some) {
954
+ const t_ = _guard1.value_;
955
+ ff_compiler_Unification.Unification_unify(self_, at_, t1_, t_)
956
+ return
957
+ }
958
+ }
959
+ }
960
+ {
961
+ if(t1_a.TVariable) {
962
+ const i_ = t1_a.index_;
963
+ ff_compiler_Unification.Unification_bind(self_, at_, i_, t2_)
964
+ return
965
+ }
966
+ }
967
+ {
968
+ if(t2_a.TVariable) {
969
+ const i_ = t2_a.index_;
970
+ ff_compiler_Unification.Unification_bind(self_, at_, i_, t1_)
971
+ return
972
+ }
973
+ }
974
+ {
975
+ if(t1_a.TConstructor) {
976
+ const name1_ = t1_a.name_;
977
+ const generics1_ = t1_a.generics_;
978
+ if(t2_a.TConstructor) {
979
+ const name2_ = t2_a.name_;
980
+ const generics2_ = t2_a.generics_;
981
+ if(((name1_ !== name2_) || (ff_core_List.List_size(generics1_) !== ff_core_List.List_size(generics2_)))) {
982
+ if((!self_.attemptFixes_)) {
983
+ const t3_ = ff_compiler_Unification.Unification_substitute(self_, t1_);
984
+ const t4_ = ff_compiler_Unification.Unification_substitute(self_, t2_);
985
+ throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(at_, ((("Type mismatch: " + ff_compiler_Syntax.Type_show(t3_, ff_core_List.Link(t3_, ff_core_List.Link(t4_, ff_core_List.Empty())))) + " vs. ") + ff_compiler_Syntax.Type_show(t4_, ff_core_List.Link(t3_, ff_core_List.Link(t4_, ff_core_List.Empty()))))), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
986
+ } else if((ff_core_String.String_startsWith(name1_, "Function$", 0) && ff_core_String.String_startsWith(name2_, "Function$", 0))) {
987
+ ff_core_List.List_each(ff_core_List.List_zip(ff_core_List.List_dropLast(generics1_, 1), ff_core_List.List_dropLast(generics2_, 1)), ((_1) => {
988
+ {
989
+ const t3_ = _1.first_;
990
+ const t4_ = _1.second_;
991
+ ff_compiler_Unification.Unification_unify(self_, at_, t3_, t4_)
992
+ return
993
+ }
994
+ }));
995
+ ff_core_List.List_each(ff_core_List.List_zip(ff_core_List.List_takeLast(generics1_, 1), ff_core_List.List_takeLast(generics2_, 1)), ((_1) => {
996
+ {
997
+ const t3_ = _1.first_;
998
+ const t4_ = _1.second_;
999
+ ff_compiler_Unification.Unification_unify(self_, at_, t3_, t4_)
1000
+ return
1001
+ }
1002
+ }))
1003
+ } else {}
1004
+ } else {
1005
+ ff_core_List.List_each(ff_core_List.List_zip(generics1_, generics2_), ((_1) => {
1006
+ {
1007
+ const t1_ = _1.first_;
1008
+ const t2_ = _1.second_;
1009
+ ff_compiler_Unification.Unification_unify(self_, at_, t1_, t2_)
1010
+ return
1011
+ }
1012
+ }))
1013
+ }
1014
+ return
1015
+ }
1016
+ }
1017
+ }
1018
+ }
1019
+ }
1020
+
1021
+ export async function Unification_bind$(self_, at_, index_, type_, $task) {
1022
+ if(ff_compiler_Unification.Unification_occursIn(self_, index_, type_)) {
1023
+ const t_ = ff_compiler_Unification.Unification_substitute(self_, type_);
1024
+ throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(at_, ((("Infinite type: " + ff_compiler_Syntax.Type_show(ff_compiler_Syntax.TVariable(at_, index_), ff_core_List.Link(t_, ff_core_List.Empty()))) + " = ") + ff_compiler_Syntax.Type_show(t_, ff_core_List.Empty()))), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
1025
+ };
1026
+ self_.substitution_ = ff_core_Map.Map_add(self_.substitution_, index_, type_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_Int_Int);
1027
+ ff_core_Option.Option_each(ff_core_Map.Map_get(self_.constraints_, index_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_Int_Int), ((map_) => {
1028
+ self_.constraints_ = ff_core_Map.Map_remove(self_.constraints_, index_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_Int_Int);
1029
+ ff_core_List.List_each(ff_core_Map.Map_pairs(map_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ((_1) => {
1030
+ {
1031
+ const name_ = _1.first_;
1032
+ const at2_ = _1.second_.at_;
1033
+ const generics_ = _1.second_.generics_;
1034
+ ff_compiler_Unification.Unification_constrain(self_, at2_, type_, name_, generics_)
1035
+ return
1036
+ }
1037
+ }))
1038
+ }));
1039
+ ff_core_Option.Option_each(ff_core_Map.Map_get(self_.affects_, index_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_Int_Int), ((affected_) => {
1040
+ ff_core_Map.Map_remove(self_.affects_, index_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_Int_Int);
1041
+ ff_core_Set.Set_each(affected_, ((i_) => {
1042
+ ff_compiler_Unification.Unification_affect(self_, at_, type_, ff_compiler_Syntax.TVariable(at_, i_))
1043
+ }), ff_core_Ordering.ff_core_Ordering_Order$ff_core_Int_Int)
1044
+ }))
1045
+ }
1046
+
1047
+ export async function Unification_affect$(self_, at_, source_, target_, $task) {
1048
+ {
1049
+ const _1 = ff_core_Pair.Pair(ff_compiler_Unification.Unification_substitute(self_, source_), ff_compiler_Unification.Unification_substitute(self_, target_));
1050
+ {
1051
+ if(_1.first_.TVariable) {
1052
+ const i1_ = _1.first_.index_;
1053
+ if(_1.second_.TVariable) {
1054
+ const i2_ = _1.second_.index_;
1055
+ const is_ = ff_core_Option.Option_else(ff_core_Map.Map_get(self_.affects_, i1_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_Int_Int), (() => {
1056
+ return ff_core_List.List_toSet(ff_core_List.Empty(), ff_core_Ordering.ff_core_Ordering_Order$ff_core_Int_Int)
1057
+ }));
1058
+ self_.affects_ = ff_core_Map.Map_add(self_.affects_, i1_, ff_core_Set.Set_add(is_, i2_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_Int_Int), ff_core_Ordering.ff_core_Ordering_Order$ff_core_Int_Int)
1059
+ return
1060
+ }
1061
+ }
1062
+ }
1063
+ {
1064
+ if(_1.second_.TConstructor) {
1065
+ if(_1.second_.name_ == "Q$") {
1066
+
1067
+ return
1068
+ }
1069
+ }
1070
+ }
1071
+ {
1072
+ if(_1.first_.TConstructor) {
1073
+ if(_1.first_.name_ == "ff:core/Nothing.Nothing") {
1074
+
1075
+ return
1076
+ }
1077
+ }
1078
+ }
1079
+ {
1080
+ const t1_ = _1.first_;
1081
+ const t2_ = _1.second_;
1082
+ ff_compiler_Unification.Unification_unify(self_, at_, t1_, t2_)
1083
+ return
1084
+ }
1085
+ }
1086
+ }
1087
+
1088
+ export async function Unification_occursIn$(self_, index_, t_, $task) {
1089
+ {
1090
+ const self_a = self_;
1091
+ const index_a = index_;
1092
+ const t_a = t_;
1093
+ {
1094
+ if(t_a.TVariable) {
1095
+ const i_ = t_a.index_;
1096
+ const _guard1 = ff_compiler_Unification.Unification_get(self_, i_);
1097
+ if(_guard1.Some) {
1098
+ const type_ = _guard1.value_;
1099
+ return ff_compiler_Unification.Unification_occursIn(self_, index_, type_)
1100
+ return
1101
+ }
1102
+ }
1103
+ }
1104
+ {
1105
+ if(t_a.TVariable) {
1106
+ const i_ = t_a.index_;
1107
+ return (i_ === index_)
1108
+ return
1109
+ }
1110
+ }
1111
+ {
1112
+ if(t_a.TConstructor) {
1113
+ const generics_ = t_a.generics_;
1114
+ return ff_core_List.List_any(generics_, ((t_) => {
1115
+ return ff_compiler_Unification.Unification_occursIn(self_, index_, t_)
1116
+ }))
1117
+ return
1118
+ }
1119
+ }
1120
+ }
1121
+ }
1122
+
1123
+ export const ff_core_Any_HasAnyTag$ff_compiler_Unification_ConstraintGenerics = {
1124
+ anyTag_() {
1125
+ return ff_core_Any.internalAnyTag_((("ff:compiler/Unification.ConstraintGenerics" + "[") + "]"))
1126
+ },
1127
+ async anyTag_$($task) {
1128
+ return ff_core_Any.internalAnyTag_((("ff:compiler/Unification.ConstraintGenerics" + "[") + "]"))
1129
+ }
1130
+ };
1131
+
1132
+ export const ff_core_Any_HasAnyTag$ff_compiler_Unification_InstanceKey = {
1133
+ anyTag_() {
1134
+ return ff_core_Any.internalAnyTag_((("ff:compiler/Unification.InstanceKey" + "[") + "]"))
1135
+ },
1136
+ async anyTag_$($task) {
1137
+ return ff_core_Any.internalAnyTag_((("ff:compiler/Unification.InstanceKey" + "[") + "]"))
1138
+ }
1139
+ };
1140
+
1141
+ export const ff_core_Any_HasAnyTag$ff_compiler_Unification_InstanceValue = {
1142
+ anyTag_() {
1143
+ return ff_core_Any.internalAnyTag_((("ff:compiler/Unification.InstanceValue" + "[") + "]"))
1144
+ },
1145
+ async anyTag_$($task) {
1146
+ return ff_core_Any.internalAnyTag_((("ff:compiler/Unification.InstanceValue" + "[") + "]"))
1147
+ }
1148
+ };
1149
+
1150
+ export const ff_core_Show_Show$ff_compiler_Unification_ConstraintGenerics = {
1151
+ show_(value_) {
1152
+ {
1153
+ const value_a = value_;
1154
+ {
1155
+ const z_ = value_a;
1156
+ return ((((("ConstraintGenerics" + "(") + ff_compiler_Syntax.ff_core_Show_Show$ff_compiler_Syntax_Location.show_(z_.at_)) + ", ") + ff_core_Show.ff_core_Show_Show$ff_core_List_List(ff_compiler_Syntax.ff_core_Show_Show$ff_compiler_Syntax_Type).show_(z_.generics_)) + ")")
1157
+ return
1158
+ }
1159
+ }
1160
+ },
1161
+ async show_$(value_, $task) {
1162
+ {
1163
+ const value_a = value_;
1164
+ {
1165
+ const z_ = value_a;
1166
+ return ((((("ConstraintGenerics" + "(") + ff_compiler_Syntax.ff_core_Show_Show$ff_compiler_Syntax_Location.show_(z_.at_)) + ", ") + ff_core_Show.ff_core_Show_Show$ff_core_List_List(ff_compiler_Syntax.ff_core_Show_Show$ff_compiler_Syntax_Type).show_(z_.generics_)) + ")")
1167
+ return
1168
+ }
1169
+ }
1170
+ }
1171
+ };
1172
+
1173
+ export const ff_core_Show_Show$ff_compiler_Unification_InstanceKey = {
1174
+ show_(value_) {
1175
+ {
1176
+ const value_a = value_;
1177
+ {
1178
+ const z_ = value_a;
1179
+ return ((((("InstanceKey" + "(") + ff_core_Show.ff_core_Show_Show$ff_core_String_String.show_(z_.traitName_)) + ", ") + ff_core_Show.ff_core_Show_Show$ff_core_String_String.show_(z_.typeName_)) + ")")
1180
+ return
1181
+ }
1182
+ }
1183
+ },
1184
+ async show_$(value_, $task) {
1185
+ {
1186
+ const value_a = value_;
1187
+ {
1188
+ const z_ = value_a;
1189
+ return ((((("InstanceKey" + "(") + ff_core_Show.ff_core_Show_Show$ff_core_String_String.show_(z_.traitName_)) + ", ") + ff_core_Show.ff_core_Show_Show$ff_core_String_String.show_(z_.typeName_)) + ")")
1190
+ return
1191
+ }
1192
+ }
1193
+ }
1194
+ };
1195
+
1196
+ export const ff_core_Show_Show$ff_compiler_Unification_InstanceValue = {
1197
+ show_(value_) {
1198
+ {
1199
+ const value_a = value_;
1200
+ {
1201
+ const z_ = value_a;
1202
+ return ((((((((((((("InstanceValue" + "(") + ff_core_Show.ff_core_Show_Show$ff_core_List_List(ff_core_Show.ff_core_Show_Show$ff_core_String_String).show_(z_.generics_)) + ", ") + ff_core_Show.ff_core_Show_Show$ff_core_List_List(ff_compiler_Syntax.ff_core_Show_Show$ff_compiler_Syntax_Constraint).show_(z_.constraints_)) + ", ") + ff_compiler_Syntax.ff_core_Show_Show$ff_compiler_Syntax_PackagePair.show_(z_.packagePair_)) + ", ") + ff_core_Show.ff_core_Show_Show$ff_core_String_String.show_(z_.moduleName_)) + ", ") + ff_core_Show.ff_core_Show_Show$ff_core_String_String.show_(z_.traitName_)) + ", ") + ff_core_Show.ff_core_Show_Show$ff_core_List_List(ff_compiler_Syntax.ff_core_Show_Show$ff_compiler_Syntax_Type).show_(z_.typeArguments_)) + ")")
1203
+ return
1204
+ }
1205
+ }
1206
+ },
1207
+ async show_$(value_, $task) {
1208
+ {
1209
+ const value_a = value_;
1210
+ {
1211
+ const z_ = value_a;
1212
+ return ((((((((((((("InstanceValue" + "(") + ff_core_Show.ff_core_Show_Show$ff_core_List_List(ff_core_Show.ff_core_Show_Show$ff_core_String_String).show_(z_.generics_)) + ", ") + ff_core_Show.ff_core_Show_Show$ff_core_List_List(ff_compiler_Syntax.ff_core_Show_Show$ff_compiler_Syntax_Constraint).show_(z_.constraints_)) + ", ") + ff_compiler_Syntax.ff_core_Show_Show$ff_compiler_Syntax_PackagePair.show_(z_.packagePair_)) + ", ") + ff_core_Show.ff_core_Show_Show$ff_core_String_String.show_(z_.moduleName_)) + ", ") + ff_core_Show.ff_core_Show_Show$ff_core_String_String.show_(z_.traitName_)) + ", ") + ff_core_Show.ff_core_Show_Show$ff_core_List_List(ff_compiler_Syntax.ff_core_Show_Show$ff_compiler_Syntax_Type).show_(z_.typeArguments_)) + ")")
1213
+ return
1214
+ }
1215
+ }
1216
+ }
1217
+ };
1218
+
1219
+ export const ff_core_Equal_Equal$ff_compiler_Unification_ConstraintGenerics = {
1220
+ equals_(x_, y_) {
1221
+ {
1222
+ const x_a = x_;
1223
+ const y_a = y_;
1224
+ {
1225
+ const _guard1 = (x_ === y_);
1226
+ if(_guard1) {
1227
+ return true
1228
+ return
1229
+ }
1230
+ }
1231
+ {
1232
+ return (ff_compiler_Syntax.ff_core_Equal_Equal$ff_compiler_Syntax_Location.equals_(x_.at_, y_.at_) && ff_core_List.ff_core_Equal_Equal$ff_core_List_List(ff_compiler_Syntax.ff_core_Equal_Equal$ff_compiler_Syntax_Type).equals_(x_.generics_, y_.generics_))
1233
+ return
1234
+ }
1235
+ }
1236
+ },
1237
+ async equals_$(x_, y_, $task) {
1238
+ {
1239
+ const x_a = x_;
1240
+ const y_a = y_;
1241
+ {
1242
+ const _guard1 = (x_ === y_);
1243
+ if(_guard1) {
1244
+ return true
1245
+ return
1246
+ }
1247
+ }
1248
+ {
1249
+ return (ff_compiler_Syntax.ff_core_Equal_Equal$ff_compiler_Syntax_Location.equals_(x_.at_, y_.at_) && ff_core_List.ff_core_Equal_Equal$ff_core_List_List(ff_compiler_Syntax.ff_core_Equal_Equal$ff_compiler_Syntax_Type).equals_(x_.generics_, y_.generics_))
1250
+ return
1251
+ }
1252
+ }
1253
+ }
1254
+ };
1255
+
1256
+ export const ff_core_Equal_Equal$ff_compiler_Unification_InstanceKey = {
1257
+ equals_(x_, y_) {
1258
+ {
1259
+ const x_a = x_;
1260
+ const y_a = y_;
1261
+ {
1262
+ const _guard1 = (x_ === y_);
1263
+ if(_guard1) {
1264
+ return true
1265
+ return
1266
+ }
1267
+ }
1268
+ {
1269
+ return ((x_.traitName_ === y_.traitName_) && (x_.typeName_ === y_.typeName_))
1270
+ return
1271
+ }
1272
+ }
1273
+ },
1274
+ async equals_$(x_, y_, $task) {
1275
+ {
1276
+ const x_a = x_;
1277
+ const y_a = y_;
1278
+ {
1279
+ const _guard1 = (x_ === y_);
1280
+ if(_guard1) {
1281
+ return true
1282
+ return
1283
+ }
1284
+ }
1285
+ {
1286
+ return ((x_.traitName_ === y_.traitName_) && (x_.typeName_ === y_.typeName_))
1287
+ return
1288
+ }
1289
+ }
1290
+ }
1291
+ };
1292
+
1293
+ export const ff_core_Equal_Equal$ff_compiler_Unification_InstanceValue = {
1294
+ equals_(x_, y_) {
1295
+ {
1296
+ const x_a = x_;
1297
+ const y_a = y_;
1298
+ {
1299
+ const _guard1 = (x_ === y_);
1300
+ if(_guard1) {
1301
+ return true
1302
+ return
1303
+ }
1304
+ }
1305
+ {
1306
+ return (ff_core_List.ff_core_Equal_Equal$ff_core_List_List(ff_core_Equal.ff_core_Equal_Equal$ff_core_String_String).equals_(x_.generics_, y_.generics_) && (ff_core_List.ff_core_Equal_Equal$ff_core_List_List(ff_compiler_Syntax.ff_core_Equal_Equal$ff_compiler_Syntax_Constraint).equals_(x_.constraints_, y_.constraints_) && (ff_compiler_Syntax.ff_core_Equal_Equal$ff_compiler_Syntax_PackagePair.equals_(x_.packagePair_, y_.packagePair_) && ((x_.moduleName_ === y_.moduleName_) && ((x_.traitName_ === y_.traitName_) && ff_core_List.ff_core_Equal_Equal$ff_core_List_List(ff_compiler_Syntax.ff_core_Equal_Equal$ff_compiler_Syntax_Type).equals_(x_.typeArguments_, y_.typeArguments_))))))
1307
+ return
1308
+ }
1309
+ }
1310
+ },
1311
+ async equals_$(x_, y_, $task) {
1312
+ {
1313
+ const x_a = x_;
1314
+ const y_a = y_;
1315
+ {
1316
+ const _guard1 = (x_ === y_);
1317
+ if(_guard1) {
1318
+ return true
1319
+ return
1320
+ }
1321
+ }
1322
+ {
1323
+ return (ff_core_List.ff_core_Equal_Equal$ff_core_List_List(ff_core_Equal.ff_core_Equal_Equal$ff_core_String_String).equals_(x_.generics_, y_.generics_) && (ff_core_List.ff_core_Equal_Equal$ff_core_List_List(ff_compiler_Syntax.ff_core_Equal_Equal$ff_compiler_Syntax_Constraint).equals_(x_.constraints_, y_.constraints_) && (ff_compiler_Syntax.ff_core_Equal_Equal$ff_compiler_Syntax_PackagePair.equals_(x_.packagePair_, y_.packagePair_) && ((x_.moduleName_ === y_.moduleName_) && ((x_.traitName_ === y_.traitName_) && ff_core_List.ff_core_Equal_Equal$ff_core_List_List(ff_compiler_Syntax.ff_core_Equal_Equal$ff_compiler_Syntax_Type).equals_(x_.typeArguments_, y_.typeArguments_))))))
1324
+ return
1325
+ }
1326
+ }
1327
+ }
1328
+ };
1329
+
1330
+ export const ff_core_Ordering_Order$ff_compiler_Unification_ConstraintGenerics = {
1331
+ compare_(x_, y_) {
1332
+ {
1333
+ const x_a = x_;
1334
+ const y_a = y_;
1335
+ {
1336
+ const _guard1 = (x_ === y_);
1337
+ if(_guard1) {
1338
+ return ff_core_Ordering.OrderingSame()
1339
+ return
1340
+ }
1341
+ }
1342
+ {
1343
+ const atOrdering_ = ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_Location.compare_(x_.at_, y_.at_);
1344
+ if((atOrdering_ !== ff_core_Ordering.OrderingSame())) {
1345
+ return atOrdering_
1346
+ } else {
1347
+ const genericsOrdering_ = ff_core_Ordering.ff_core_Ordering_Order$ff_core_List_List(ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_Type).compare_(x_.generics_, y_.generics_);
1348
+ if((genericsOrdering_ !== ff_core_Ordering.OrderingSame())) {
1349
+ return genericsOrdering_
1350
+ } else {
1351
+ return ff_core_Ordering.OrderingSame()
1352
+ }
1353
+ }
1354
+ return
1355
+ }
1356
+ }
1357
+ },
1358
+ async compare_$(x_, y_, $task) {
1359
+ {
1360
+ const x_a = x_;
1361
+ const y_a = y_;
1362
+ {
1363
+ const _guard1 = (x_ === y_);
1364
+ if(_guard1) {
1365
+ return ff_core_Ordering.OrderingSame()
1366
+ return
1367
+ }
1368
+ }
1369
+ {
1370
+ const atOrdering_ = ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_Location.compare_(x_.at_, y_.at_);
1371
+ if((atOrdering_ !== ff_core_Ordering.OrderingSame())) {
1372
+ return atOrdering_
1373
+ } else {
1374
+ const genericsOrdering_ = ff_core_Ordering.ff_core_Ordering_Order$ff_core_List_List(ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_Type).compare_(x_.generics_, y_.generics_);
1375
+ if((genericsOrdering_ !== ff_core_Ordering.OrderingSame())) {
1376
+ return genericsOrdering_
1377
+ } else {
1378
+ return ff_core_Ordering.OrderingSame()
1379
+ }
1380
+ }
1381
+ return
1382
+ }
1383
+ }
1384
+ }
1385
+ };
1386
+
1387
+ export const ff_core_Ordering_Order$ff_compiler_Unification_InstanceKey = {
1388
+ compare_(x_, y_) {
1389
+ {
1390
+ const x_a = x_;
1391
+ const y_a = y_;
1392
+ {
1393
+ const _guard1 = (x_ === y_);
1394
+ if(_guard1) {
1395
+ return ff_core_Ordering.OrderingSame()
1396
+ return
1397
+ }
1398
+ }
1399
+ {
1400
+ const traitNameOrdering_ = ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String.compare_(x_.traitName_, y_.traitName_);
1401
+ if((traitNameOrdering_ !== ff_core_Ordering.OrderingSame())) {
1402
+ return traitNameOrdering_
1403
+ } else {
1404
+ const typeNameOrdering_ = ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String.compare_(x_.typeName_, y_.typeName_);
1405
+ if((typeNameOrdering_ !== ff_core_Ordering.OrderingSame())) {
1406
+ return typeNameOrdering_
1407
+ } else {
1408
+ return ff_core_Ordering.OrderingSame()
1409
+ }
1410
+ }
1411
+ return
1412
+ }
1413
+ }
1414
+ },
1415
+ async compare_$(x_, y_, $task) {
1416
+ {
1417
+ const x_a = x_;
1418
+ const y_a = y_;
1419
+ {
1420
+ const _guard1 = (x_ === y_);
1421
+ if(_guard1) {
1422
+ return ff_core_Ordering.OrderingSame()
1423
+ return
1424
+ }
1425
+ }
1426
+ {
1427
+ const traitNameOrdering_ = ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String.compare_(x_.traitName_, y_.traitName_);
1428
+ if((traitNameOrdering_ !== ff_core_Ordering.OrderingSame())) {
1429
+ return traitNameOrdering_
1430
+ } else {
1431
+ const typeNameOrdering_ = ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String.compare_(x_.typeName_, y_.typeName_);
1432
+ if((typeNameOrdering_ !== ff_core_Ordering.OrderingSame())) {
1433
+ return typeNameOrdering_
1434
+ } else {
1435
+ return ff_core_Ordering.OrderingSame()
1436
+ }
1437
+ }
1438
+ return
1439
+ }
1440
+ }
1441
+ }
1442
+ };
1443
+
1444
+ export const ff_core_Ordering_Order$ff_compiler_Unification_InstanceValue = {
1445
+ compare_(x_, y_) {
1446
+ {
1447
+ const x_a = x_;
1448
+ const y_a = y_;
1449
+ {
1450
+ const _guard1 = (x_ === y_);
1451
+ if(_guard1) {
1452
+ return ff_core_Ordering.OrderingSame()
1453
+ return
1454
+ }
1455
+ }
1456
+ {
1457
+ const genericsOrdering_ = ff_core_Ordering.ff_core_Ordering_Order$ff_core_List_List(ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String).compare_(x_.generics_, y_.generics_);
1458
+ if((genericsOrdering_ !== ff_core_Ordering.OrderingSame())) {
1459
+ return genericsOrdering_
1460
+ } else {
1461
+ const constraintsOrdering_ = ff_core_Ordering.ff_core_Ordering_Order$ff_core_List_List(ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_Constraint).compare_(x_.constraints_, y_.constraints_);
1462
+ if((constraintsOrdering_ !== ff_core_Ordering.OrderingSame())) {
1463
+ return constraintsOrdering_
1464
+ } else {
1465
+ const packagePairOrdering_ = ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_PackagePair.compare_(x_.packagePair_, y_.packagePair_);
1466
+ if((packagePairOrdering_ !== ff_core_Ordering.OrderingSame())) {
1467
+ return packagePairOrdering_
1468
+ } else {
1469
+ const moduleNameOrdering_ = ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String.compare_(x_.moduleName_, y_.moduleName_);
1470
+ if((moduleNameOrdering_ !== ff_core_Ordering.OrderingSame())) {
1471
+ return moduleNameOrdering_
1472
+ } else {
1473
+ const traitNameOrdering_ = ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String.compare_(x_.traitName_, y_.traitName_);
1474
+ if((traitNameOrdering_ !== ff_core_Ordering.OrderingSame())) {
1475
+ return traitNameOrdering_
1476
+ } else {
1477
+ const typeArgumentsOrdering_ = ff_core_Ordering.ff_core_Ordering_Order$ff_core_List_List(ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_Type).compare_(x_.typeArguments_, y_.typeArguments_);
1478
+ if((typeArgumentsOrdering_ !== ff_core_Ordering.OrderingSame())) {
1479
+ return typeArgumentsOrdering_
1480
+ } else {
1481
+ return ff_core_Ordering.OrderingSame()
1482
+ }
1483
+ }
1484
+ }
1485
+ }
1486
+ }
1487
+ }
1488
+ return
1489
+ }
1490
+ }
1491
+ },
1492
+ async compare_$(x_, y_, $task) {
1493
+ {
1494
+ const x_a = x_;
1495
+ const y_a = y_;
1496
+ {
1497
+ const _guard1 = (x_ === y_);
1498
+ if(_guard1) {
1499
+ return ff_core_Ordering.OrderingSame()
1500
+ return
1501
+ }
1502
+ }
1503
+ {
1504
+ const genericsOrdering_ = ff_core_Ordering.ff_core_Ordering_Order$ff_core_List_List(ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String).compare_(x_.generics_, y_.generics_);
1505
+ if((genericsOrdering_ !== ff_core_Ordering.OrderingSame())) {
1506
+ return genericsOrdering_
1507
+ } else {
1508
+ const constraintsOrdering_ = ff_core_Ordering.ff_core_Ordering_Order$ff_core_List_List(ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_Constraint).compare_(x_.constraints_, y_.constraints_);
1509
+ if((constraintsOrdering_ !== ff_core_Ordering.OrderingSame())) {
1510
+ return constraintsOrdering_
1511
+ } else {
1512
+ const packagePairOrdering_ = ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_PackagePair.compare_(x_.packagePair_, y_.packagePair_);
1513
+ if((packagePairOrdering_ !== ff_core_Ordering.OrderingSame())) {
1514
+ return packagePairOrdering_
1515
+ } else {
1516
+ const moduleNameOrdering_ = ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String.compare_(x_.moduleName_, y_.moduleName_);
1517
+ if((moduleNameOrdering_ !== ff_core_Ordering.OrderingSame())) {
1518
+ return moduleNameOrdering_
1519
+ } else {
1520
+ const traitNameOrdering_ = ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String.compare_(x_.traitName_, y_.traitName_);
1521
+ if((traitNameOrdering_ !== ff_core_Ordering.OrderingSame())) {
1522
+ return traitNameOrdering_
1523
+ } else {
1524
+ const typeArgumentsOrdering_ = ff_core_Ordering.ff_core_Ordering_Order$ff_core_List_List(ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_Type).compare_(x_.typeArguments_, y_.typeArguments_);
1525
+ if((typeArgumentsOrdering_ !== ff_core_Ordering.OrderingSame())) {
1526
+ return typeArgumentsOrdering_
1527
+ } else {
1528
+ return ff_core_Ordering.OrderingSame()
1529
+ }
1530
+ }
1531
+ }
1532
+ }
1533
+ }
1534
+ }
1535
+ return
1536
+ }
1537
+ }
1538
+ }
1539
+ };
1540
+
1541
+ export const ff_core_Serializable_Serializable$ff_compiler_Unification_ConstraintGenerics = {
1542
+ serializeUsing_(serialization_, value_) {
1543
+ {
1544
+ const serialization_a = serialization_;
1545
+ const value_a = value_;
1546
+ {
1547
+ const v_ = value_a;
1548
+ serialization_.checksum_ = ff_core_Int.Int_bitOr(((31 * serialization_.checksum_) + 42), 0);
1549
+ ff_core_Serializable.Serialization_autoResize(serialization_, 1);
1550
+ ff_core_Buffer.Buffer_setUint8(serialization_.buffer_, serialization_.offset_, 0);
1551
+ serialization_.offset_ += 1;
1552
+ ff_compiler_Syntax.ff_core_Serializable_Serializable$ff_compiler_Syntax_Location.serializeUsing_(serialization_, v_.at_);
1553
+ ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_List_List(ff_compiler_Syntax.ff_core_Serializable_Serializable$ff_compiler_Syntax_Type).serializeUsing_(serialization_, v_.generics_)
1554
+ return
1555
+ }
1556
+ }
1557
+ },
1558
+ deserializeUsing_(serialization_) {
1559
+ const variantIndex_ = ff_core_Buffer.Buffer_grabUint8(serialization_.buffer_, serialization_.offset_);
1560
+ serialization_.offset_ += 1;
1561
+ {
1562
+ const _1 = variantIndex_;
1563
+ {
1564
+ if(_1 == 0) {
1565
+ serialization_.checksum_ = ff_core_Int.Int_bitOr(((31 * serialization_.checksum_) + 42), 0);
1566
+ return ff_compiler_Unification.ConstraintGenerics(ff_compiler_Syntax.ff_core_Serializable_Serializable$ff_compiler_Syntax_Location.deserializeUsing_(serialization_), ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_List_List(ff_compiler_Syntax.ff_core_Serializable_Serializable$ff_compiler_Syntax_Type).deserializeUsing_(serialization_))
1567
+ return
1568
+ }
1569
+ }
1570
+ {
1571
+ 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)})
1572
+ return
1573
+ }
1574
+ }
1575
+ },
1576
+ async serializeUsing_$(serialization_, value_, $task) {
1577
+ {
1578
+ const serialization_a = serialization_;
1579
+ const value_a = value_;
1580
+ {
1581
+ const v_ = value_a;
1582
+ serialization_.checksum_ = ff_core_Int.Int_bitOr(((31 * serialization_.checksum_) + 42), 0);
1583
+ ff_core_Serializable.Serialization_autoResize(serialization_, 1);
1584
+ ff_core_Buffer.Buffer_setUint8(serialization_.buffer_, serialization_.offset_, 0);
1585
+ serialization_.offset_ += 1;
1586
+ ff_compiler_Syntax.ff_core_Serializable_Serializable$ff_compiler_Syntax_Location.serializeUsing_(serialization_, v_.at_);
1587
+ ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_List_List(ff_compiler_Syntax.ff_core_Serializable_Serializable$ff_compiler_Syntax_Type).serializeUsing_(serialization_, v_.generics_)
1588
+ return
1589
+ }
1590
+ }
1591
+ },
1592
+ async deserializeUsing_$(serialization_, $task) {
1593
+ const variantIndex_ = ff_core_Buffer.Buffer_grabUint8(serialization_.buffer_, serialization_.offset_);
1594
+ serialization_.offset_ += 1;
1595
+ {
1596
+ const _1 = variantIndex_;
1597
+ {
1598
+ if(_1 == 0) {
1599
+ serialization_.checksum_ = ff_core_Int.Int_bitOr(((31 * serialization_.checksum_) + 42), 0);
1600
+ return ff_compiler_Unification.ConstraintGenerics(ff_compiler_Syntax.ff_core_Serializable_Serializable$ff_compiler_Syntax_Location.deserializeUsing_(serialization_), ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_List_List(ff_compiler_Syntax.ff_core_Serializable_Serializable$ff_compiler_Syntax_Type).deserializeUsing_(serialization_))
1601
+ return
1602
+ }
1603
+ }
1604
+ {
1605
+ 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)})
1606
+ return
1607
+ }
1608
+ }
1609
+ }
1610
+ };
1611
+
1612
+ export const ff_core_Serializable_Serializable$ff_compiler_Unification_InstanceKey = {
1613
+ serializeUsing_(serialization_, value_) {
1614
+ {
1615
+ const serialization_a = serialization_;
1616
+ const value_a = value_;
1617
+ {
1618
+ const v_ = value_a;
1619
+ serialization_.checksum_ = ff_core_Int.Int_bitOr(((31 * serialization_.checksum_) + 35), 0);
1620
+ ff_core_Serializable.Serialization_autoResize(serialization_, 1);
1621
+ ff_core_Buffer.Buffer_setUint8(serialization_.buffer_, serialization_.offset_, 0);
1622
+ serialization_.offset_ += 1;
1623
+ ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_String_String.serializeUsing_(serialization_, v_.traitName_);
1624
+ ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_String_String.serializeUsing_(serialization_, v_.typeName_)
1625
+ return
1626
+ }
1627
+ }
1628
+ },
1629
+ deserializeUsing_(serialization_) {
1630
+ const variantIndex_ = ff_core_Buffer.Buffer_grabUint8(serialization_.buffer_, serialization_.offset_);
1631
+ serialization_.offset_ += 1;
1632
+ {
1633
+ const _1 = variantIndex_;
1634
+ {
1635
+ if(_1 == 0) {
1636
+ serialization_.checksum_ = ff_core_Int.Int_bitOr(((31 * serialization_.checksum_) + 35), 0);
1637
+ return ff_compiler_Unification.InstanceKey(ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_String_String.deserializeUsing_(serialization_), ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_String_String.deserializeUsing_(serialization_))
1638
+ return
1639
+ }
1640
+ }
1641
+ {
1642
+ 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)})
1643
+ return
1644
+ }
1645
+ }
1646
+ },
1647
+ async serializeUsing_$(serialization_, value_, $task) {
1648
+ {
1649
+ const serialization_a = serialization_;
1650
+ const value_a = value_;
1651
+ {
1652
+ const v_ = value_a;
1653
+ serialization_.checksum_ = ff_core_Int.Int_bitOr(((31 * serialization_.checksum_) + 35), 0);
1654
+ ff_core_Serializable.Serialization_autoResize(serialization_, 1);
1655
+ ff_core_Buffer.Buffer_setUint8(serialization_.buffer_, serialization_.offset_, 0);
1656
+ serialization_.offset_ += 1;
1657
+ ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_String_String.serializeUsing_(serialization_, v_.traitName_);
1658
+ ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_String_String.serializeUsing_(serialization_, v_.typeName_)
1659
+ return
1660
+ }
1661
+ }
1662
+ },
1663
+ async deserializeUsing_$(serialization_, $task) {
1664
+ const variantIndex_ = ff_core_Buffer.Buffer_grabUint8(serialization_.buffer_, serialization_.offset_);
1665
+ serialization_.offset_ += 1;
1666
+ {
1667
+ const _1 = variantIndex_;
1668
+ {
1669
+ if(_1 == 0) {
1670
+ serialization_.checksum_ = ff_core_Int.Int_bitOr(((31 * serialization_.checksum_) + 35), 0);
1671
+ return ff_compiler_Unification.InstanceKey(ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_String_String.deserializeUsing_(serialization_), ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_String_String.deserializeUsing_(serialization_))
1672
+ return
1673
+ }
1674
+ }
1675
+ {
1676
+ 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)})
1677
+ return
1678
+ }
1679
+ }
1680
+ }
1681
+ };
1682
+
1683
+ export const ff_core_Serializable_Serializable$ff_compiler_Unification_InstanceValue = {
1684
+ serializeUsing_(serialization_, value_) {
1685
+ {
1686
+ const serialization_a = serialization_;
1687
+ const value_a = value_;
1688
+ {
1689
+ const v_ = value_a;
1690
+ serialization_.checksum_ = ff_core_Int.Int_bitOr(((31 * serialization_.checksum_) + 37), 0);
1691
+ ff_core_Serializable.Serialization_autoResize(serialization_, 1);
1692
+ ff_core_Buffer.Buffer_setUint8(serialization_.buffer_, serialization_.offset_, 0);
1693
+ serialization_.offset_ += 1;
1694
+ ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_List_List(ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_String_String).serializeUsing_(serialization_, v_.generics_);
1695
+ ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_List_List(ff_compiler_Syntax.ff_core_Serializable_Serializable$ff_compiler_Syntax_Constraint).serializeUsing_(serialization_, v_.constraints_);
1696
+ ff_compiler_Syntax.ff_core_Serializable_Serializable$ff_compiler_Syntax_PackagePair.serializeUsing_(serialization_, v_.packagePair_);
1697
+ ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_String_String.serializeUsing_(serialization_, v_.moduleName_);
1698
+ ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_String_String.serializeUsing_(serialization_, v_.traitName_);
1699
+ ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_List_List(ff_compiler_Syntax.ff_core_Serializable_Serializable$ff_compiler_Syntax_Type).serializeUsing_(serialization_, v_.typeArguments_)
1700
+ return
1701
+ }
1702
+ }
1703
+ },
1704
+ deserializeUsing_(serialization_) {
1705
+ const variantIndex_ = ff_core_Buffer.Buffer_grabUint8(serialization_.buffer_, serialization_.offset_);
1706
+ serialization_.offset_ += 1;
1707
+ {
1708
+ const _1 = variantIndex_;
1709
+ {
1710
+ if(_1 == 0) {
1711
+ serialization_.checksum_ = ff_core_Int.Int_bitOr(((31 * serialization_.checksum_) + 37), 0);
1712
+ return ff_compiler_Unification.InstanceValue(ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_List_List(ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_String_String).deserializeUsing_(serialization_), ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_List_List(ff_compiler_Syntax.ff_core_Serializable_Serializable$ff_compiler_Syntax_Constraint).deserializeUsing_(serialization_), ff_compiler_Syntax.ff_core_Serializable_Serializable$ff_compiler_Syntax_PackagePair.deserializeUsing_(serialization_), ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_String_String.deserializeUsing_(serialization_), ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_String_String.deserializeUsing_(serialization_), ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_List_List(ff_compiler_Syntax.ff_core_Serializable_Serializable$ff_compiler_Syntax_Type).deserializeUsing_(serialization_))
1713
+ return
1714
+ }
1715
+ }
1716
+ {
1717
+ 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)})
1718
+ return
1719
+ }
1720
+ }
1721
+ },
1722
+ async serializeUsing_$(serialization_, value_, $task) {
1723
+ {
1724
+ const serialization_a = serialization_;
1725
+ const value_a = value_;
1726
+ {
1727
+ const v_ = value_a;
1728
+ serialization_.checksum_ = ff_core_Int.Int_bitOr(((31 * serialization_.checksum_) + 37), 0);
1729
+ ff_core_Serializable.Serialization_autoResize(serialization_, 1);
1730
+ ff_core_Buffer.Buffer_setUint8(serialization_.buffer_, serialization_.offset_, 0);
1731
+ serialization_.offset_ += 1;
1732
+ ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_List_List(ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_String_String).serializeUsing_(serialization_, v_.generics_);
1733
+ ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_List_List(ff_compiler_Syntax.ff_core_Serializable_Serializable$ff_compiler_Syntax_Constraint).serializeUsing_(serialization_, v_.constraints_);
1734
+ ff_compiler_Syntax.ff_core_Serializable_Serializable$ff_compiler_Syntax_PackagePair.serializeUsing_(serialization_, v_.packagePair_);
1735
+ ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_String_String.serializeUsing_(serialization_, v_.moduleName_);
1736
+ ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_String_String.serializeUsing_(serialization_, v_.traitName_);
1737
+ ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_List_List(ff_compiler_Syntax.ff_core_Serializable_Serializable$ff_compiler_Syntax_Type).serializeUsing_(serialization_, v_.typeArguments_)
1738
+ return
1739
+ }
1740
+ }
1741
+ },
1742
+ async deserializeUsing_$(serialization_, $task) {
1743
+ const variantIndex_ = ff_core_Buffer.Buffer_grabUint8(serialization_.buffer_, serialization_.offset_);
1744
+ serialization_.offset_ += 1;
1745
+ {
1746
+ const _1 = variantIndex_;
1747
+ {
1748
+ if(_1 == 0) {
1749
+ serialization_.checksum_ = ff_core_Int.Int_bitOr(((31 * serialization_.checksum_) + 37), 0);
1750
+ return ff_compiler_Unification.InstanceValue(ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_List_List(ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_String_String).deserializeUsing_(serialization_), ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_List_List(ff_compiler_Syntax.ff_core_Serializable_Serializable$ff_compiler_Syntax_Constraint).deserializeUsing_(serialization_), ff_compiler_Syntax.ff_core_Serializable_Serializable$ff_compiler_Syntax_PackagePair.deserializeUsing_(serialization_), ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_String_String.deserializeUsing_(serialization_), ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_String_String.deserializeUsing_(serialization_), ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_List_List(ff_compiler_Syntax.ff_core_Serializable_Serializable$ff_compiler_Syntax_Type).deserializeUsing_(serialization_))
1751
+ return
1752
+ }
1753
+ }
1754
+ {
1755
+ 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)})
1756
+ return
1757
+ }
1758
+ }
1759
+ }
1760
+ };
1761
+
1762
+