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