firefly-compiler 0.4.4

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