firefly-compiler 0.4.20 → 0.4.21

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