firefly-compiler 0.4.18 → 0.4.19

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 (115) hide show
  1. package/compiler/Builder.ff +1 -1
  2. package/compiler/Compiler.ff +6 -5
  3. package/compiler/Inference.ff +31 -19
  4. package/compiler/JsEmitter.ff +98 -71
  5. package/compiler/JsImporter.ff +1 -1
  6. package/compiler/LspHook.ff +4 -4
  7. package/compiler/Main.ff +6 -6
  8. package/compiler/Parser.ff +39 -39
  9. package/compiler/Patterns.ff +2 -0
  10. package/compiler/Syntax.ff +1 -1
  11. package/compiler/Tokenizer.ff +2 -2
  12. package/compiler/Workspace.ff +2 -2
  13. package/core/Array.ff +135 -294
  14. package/core/Buffer.ff +3 -3
  15. package/core/BuildSystem.ff +1 -1
  16. package/core/Equal.ff +36 -52
  17. package/core/HttpClient.ff +1 -1
  18. package/core/IntMap.ff +14 -18
  19. package/core/JsSystem.ff +1 -1
  20. package/core/JsValue.ff +6 -12
  21. package/core/Json.ff +19 -28
  22. package/core/List.ff +281 -312
  23. package/core/Map.ff +4 -8
  24. package/core/NodeSystem.ff +2 -2
  25. package/core/Option.ff +0 -4
  26. package/core/Ordering.ff +10 -6
  27. package/core/Pair.ff +0 -4
  28. package/core/Random.ff +12 -26
  29. package/core/RbMap.ff +216 -216
  30. package/core/Serializable.ff +9 -18
  31. package/core/Set.ff +0 -1
  32. package/core/SourceLocation.ff +1 -1
  33. package/core/Stack.ff +32 -45
  34. package/core/Stream.ff +10 -14
  35. package/core/String.ff +24 -6
  36. package/core/StringMap.ff +15 -19
  37. package/guide/Main.ff +20 -2
  38. package/lsp/CompletionHandler.ff +4 -4
  39. package/lsp/Handler.ff +44 -33
  40. package/lsp/HoverHandler.ff +2 -2
  41. package/lsp/LanguageServer.ff +2 -2
  42. package/lsp/SignatureHelpHandler.ff +1 -1
  43. package/lsp/SymbolHandler.ff +1 -1
  44. package/lux/Lux.ff +3 -3
  45. package/output/js/ff/compiler/Builder.mjs +19 -21
  46. package/output/js/ff/compiler/Compiler.mjs +18 -20
  47. package/output/js/ff/compiler/Dependencies.mjs +8 -10
  48. package/output/js/ff/compiler/Deriver.mjs +234 -236
  49. package/output/js/ff/compiler/Dictionaries.mjs +6 -8
  50. package/output/js/ff/compiler/Environment.mjs +42 -44
  51. package/output/js/ff/compiler/Inference.mjs +346 -304
  52. package/output/js/ff/compiler/JsEmitter.mjs +907 -833
  53. package/output/js/ff/compiler/JsImporter.mjs +0 -2
  54. package/output/js/ff/compiler/LspHook.mjs +10 -12
  55. package/output/js/ff/compiler/Main.mjs +109 -111
  56. package/output/js/ff/compiler/Parser.mjs +405 -407
  57. package/output/js/ff/compiler/Patterns.mjs +64 -50
  58. package/output/js/ff/compiler/Resolver.mjs +36 -38
  59. package/output/js/ff/compiler/Substitution.mjs +4 -6
  60. package/output/js/ff/compiler/Syntax.mjs +160 -162
  61. package/output/js/ff/compiler/Token.mjs +52 -54
  62. package/output/js/ff/compiler/Tokenizer.mjs +16 -18
  63. package/output/js/ff/compiler/Unification.mjs +24 -26
  64. package/output/js/ff/compiler/Wildcards.mjs +0 -2
  65. package/output/js/ff/compiler/Workspace.mjs +18 -20
  66. package/output/js/ff/core/Any.mjs +0 -2
  67. package/output/js/ff/core/Array.mjs +216 -613
  68. package/output/js/ff/core/AssetSystem.mjs +2 -4
  69. package/output/js/ff/core/Atomic.mjs +0 -2
  70. package/output/js/ff/core/Bool.mjs +0 -2
  71. package/output/js/ff/core/Box.mjs +0 -2
  72. package/output/js/ff/core/BrowserSystem.mjs +0 -2
  73. package/output/js/ff/core/Buffer.mjs +0 -2
  74. package/output/js/ff/core/BuildSystem.mjs +12 -14
  75. package/output/js/ff/core/Channel.mjs +0 -2
  76. package/output/js/ff/core/Char.mjs +0 -2
  77. package/output/js/ff/core/Core.mjs +0 -2
  78. package/output/js/ff/core/Duration.mjs +0 -2
  79. package/output/js/ff/core/Equal.mjs +0 -22
  80. package/output/js/ff/core/Error.mjs +0 -2
  81. package/output/js/ff/core/FileHandle.mjs +0 -2
  82. package/output/js/ff/core/Float.mjs +0 -2
  83. package/output/js/ff/core/HttpClient.mjs +2 -4
  84. package/output/js/ff/core/Instant.mjs +0 -2
  85. package/output/js/ff/core/Int.mjs +8 -10
  86. package/output/js/ff/core/IntMap.mjs +32 -42
  87. package/output/js/ff/core/JsSystem.mjs +1 -3
  88. package/output/js/ff/core/JsValue.mjs +5 -12
  89. package/output/js/ff/core/Json.mjs +23 -56
  90. package/output/js/ff/core/List.mjs +648 -1989
  91. package/output/js/ff/core/Lock.mjs +0 -2
  92. package/output/js/ff/core/Log.mjs +0 -2
  93. package/output/js/ff/core/Map.mjs +10 -20
  94. package/output/js/ff/core/NodeSystem.mjs +6 -8
  95. package/output/js/ff/core/Nothing.mjs +0 -2
  96. package/output/js/ff/core/Option.mjs +8 -18
  97. package/output/js/ff/core/Ordering.mjs +20 -98
  98. package/output/js/ff/core/Pair.mjs +6 -16
  99. package/output/js/ff/core/Path.mjs +12 -14
  100. package/output/js/ff/core/Random.mjs +24 -54
  101. package/output/js/ff/core/RbMap.mjs +54 -56
  102. package/output/js/ff/core/Serializable.mjs +19 -36
  103. package/output/js/ff/core/Set.mjs +0 -14
  104. package/output/js/ff/core/Show.mjs +0 -2
  105. package/output/js/ff/core/SourceLocation.mjs +0 -2
  106. package/output/js/ff/core/Stream.mjs +34 -44
  107. package/output/js/ff/core/String.mjs +31 -5
  108. package/output/js/ff/core/StringMap.mjs +32 -42
  109. package/output/js/ff/core/Task.mjs +0 -2
  110. package/output/js/ff/core/Try.mjs +0 -2
  111. package/output/js/ff/core/Unit.mjs +0 -2
  112. package/package.json +1 -1
  113. package/vscode/package.json +1 -1
  114. package/webserver/WebServer.ff +8 -8
  115. package/output/js/ff/core/Stack.mjs +0 -603
@@ -78,8 +78,6 @@ import * as ff_core_Show from "../../ff/core/Show.mjs"
78
78
 
79
79
  import * as ff_core_SourceLocation from "../../ff/core/SourceLocation.mjs"
80
80
 
81
- import * as ff_core_Stack from "../../ff/core/Stack.mjs"
82
-
83
81
  import * as ff_core_Stream from "../../ff/core/Stream.mjs"
84
82
 
85
83
  import * as ff_core_String from "../../ff/core/String.mjs"
@@ -93,306 +91,413 @@ import * as ff_core_Try from "../../ff/core/Try.mjs"
93
91
  import * as ff_core_Unit from "../../ff/core/Unit.mjs"
94
92
 
95
93
  // type List
96
- const Empty$ = {Empty: true};
97
- export function Empty() {
98
- return Empty$;
99
- }
100
- export function Link(head_, tail_) {
101
- return {Link: true, head_, tail_};
102
- }
103
94
 
104
95
 
105
96
 
106
- export function range_(size_) {
97
+
98
+ export function empty_() {
107
99
 
108
- let result = ff_core_List.Empty();
109
- for(let i = size_ - 1; i >= 0; i--) {
110
- result = ff_core_List.Link(i, result);
111
- }
112
- return result;
100
+ return [];
113
101
 
114
102
  }
115
103
 
116
- export function build_(initial_, body_) {
117
- function go_(state_, result_) {
118
- _tailcall: for(;;) {
119
- {
120
- const _1 = body_(state_);
121
- {
122
- if(_1.None) {
123
- return ff_core_List.List_reverse(result_)
124
- return
125
- }
126
- }
127
- {
128
- if(_1.Some) {
129
- const s_ = _1.value_.first_;
130
- const x_ = _1.value_.second_;
131
- {
132
- const state_r_ = s_;
133
- const result_r_ = ff_core_List.Link(x_, result_);
134
- state_ = state_r_
135
- result_ = result_r_
136
- continue _tailcall
104
+ export function fill_(size_, value_) {
105
+
106
+ return new Array(size_).fill(value_);
107
+
137
108
  }
138
- return
109
+
110
+ export function fillBy_(size_, body_) {
111
+
112
+ return Array.from({length: size_}, (_, i) => body_(i));
113
+
139
114
  }
115
+
116
+ export function range_(size_) {
117
+
118
+ return Array.from({length: size_}, (_, i) => i);
119
+
140
120
  }
121
+
122
+ export function internalSame_(left_, right_) {
123
+ return left_ === right_
141
124
  }
142
- return
125
+
126
+ export async function empty_$($task) {
127
+ throw new Error('Function empty is missing on this target in async context.');
143
128
  }
129
+
130
+ export async function fill_$(size_, value_, $task) {
131
+ throw new Error('Function fill is missing on this target in async context.');
144
132
  }
145
- return go_(initial_, ff_core_List.Empty())
133
+
134
+ export async function fillBy_$(size_, body_, $task) {
135
+
136
+ const array = new Array(size_);
137
+ for(let i = 0; i < size_; i++) {
138
+ array[i] = await(body_(_i));
139
+ }
140
+ return array;
141
+
146
142
  }
147
143
 
148
144
  export async function range_$(size_, $task) {
149
145
  throw new Error('Function range is missing on this target in async context.');
150
146
  }
151
147
 
152
- export async function build_$(initial_, body_, $task) {
153
- async function go_$(state_, result_, $task) {
154
- _tailcall: for(;;) {
155
- {
156
- const _1 = (await body_(state_, $task));
157
- {
158
- if(_1.None) {
159
- return ff_core_List.List_reverse(result_)
160
- return
161
- }
162
- }
163
- {
164
- if(_1.Some) {
165
- const s_ = _1.value_.first_;
166
- const x_ = _1.value_.second_;
167
- {
168
- const state_r_ = s_;
169
- const result_r_ = ff_core_List.Link(x_, result_);
170
- state_ = state_r_
171
- result_ = result_r_
172
- continue _tailcall
148
+ export async function internalSame_$(left_, right_, $task) {
149
+ throw new Error('Function internalSame is missing on this target in async context.');
173
150
  }
174
- return
175
- }
176
- }
177
- }
178
- return
151
+
152
+ export function List_addAll(self_, that_) {
153
+ return self_.concat(that_)
179
154
  }
155
+
156
+ export function List_isEmpty(self_) {
157
+ return self_.length === 0
180
158
  }
181
- return (await go_$(initial_, ff_core_List.Empty(), $task))
159
+
160
+ export function List_size(self_) {
161
+ return self_.length
182
162
  }
183
163
 
184
- export function List_addAll(self_, list_) {
185
- return ff_core_List.List_flatten(ff_core_List.Link(self_, ff_core_List.Link(list_, ff_core_List.Empty())))
164
+ export function List_get(self_, index_) {
165
+
166
+ return index_ >= 0 && index_ < self_.length
167
+ ? ff_core_Option.Some(self_[index_])
168
+ : ff_core_Option.None()
169
+
186
170
  }
187
171
 
188
- export function List_toStack(self_) {
172
+ export function List_grab(self_, index_) {
189
173
 
190
- let current = self_;
191
- let result = [];
192
- while(current.Link) {
193
- result.push(current.head_);
194
- current = current.tail_;
174
+ if(index_ < 0 || index_ >= self_.length) {
175
+ ff_core_Try.internalThrowGrabException_()
195
176
  }
196
- return {array: result};
177
+ return self_[index_]
197
178
 
198
179
  }
199
180
 
200
- export function List_toArray(self_) {
201
- return ff_core_Stack.Stack_drain(ff_core_List.List_toStack(self_))
181
+ export function List_first(self_) {
182
+ return ff_core_List.List_get(self_, 0)
202
183
  }
203
184
 
204
- export function List_grab(self_, index_) {
205
- function go_(list_, i_) {
206
- _tailcall: for(;;) {
207
- {
208
- const _1 = list_;
209
- {
210
- if(_1.Empty) {
211
- return ff_core_Try.internalThrowGrabException_()
212
- return
213
- }
214
- }
215
- {
216
- if(_1.Link) {
217
- const head_ = _1.head_;
218
- const _guard1 = (i_ === 0);
219
- if(_guard1) {
220
- return head_
221
- return
185
+ export function List_last(self_) {
186
+ return ff_core_List.List_get(self_, (ff_core_List.List_size(self_) - 1))
222
187
  }
188
+
189
+ export function List_grabFirst(self_) {
190
+ return ff_core_List.List_grab(self_, 0)
223
191
  }
192
+
193
+ export function List_grabLast(self_) {
194
+ return ff_core_List.List_grab(self_, (ff_core_List.List_size(self_) - 1))
224
195
  }
225
- {
226
- if(_1.Link) {
227
- const tail_ = _1.tail_;
228
- {
229
- const list_r_ = tail_;
230
- const i_r_ = (i_ - 1);
231
- list_ = list_r_
232
- i_ = i_r_
233
- continue _tailcall
196
+
197
+ export function List_takeFirst(self_, count_ = 1) {
198
+ return self_.slice(0, count_)
234
199
  }
235
- return
200
+
201
+ export function List_takeLast(self_, count_ = 1) {
202
+ return self_.slice(-count_)
236
203
  }
204
+
205
+ export function List_dropFirst(self_, count_ = 1) {
206
+ return self_.slice(count_)
237
207
  }
208
+
209
+ export function List_dropLast(self_, count_ = 1) {
210
+ return self_.slice(0, self_.length - count_)
238
211
  }
239
- return
212
+
213
+ export function List_pairs(self_) {
214
+ let i_ = 0;
215
+ return ff_core_List.List_map(self_, ((x_) => {
216
+ const r_ = ff_core_Pair.Pair(i_, x_);
217
+ i_ += 1;
218
+ return r_
219
+ }))
240
220
  }
221
+
222
+ export function List_slice(self_, from_, until_) {
223
+ return ff_core_List.List_takeFirst(ff_core_List.List_dropFirst(self_, from_), (until_ - from_))
241
224
  }
242
- return go_(self_, index_)
225
+
226
+ export function List_foldLeft(self_, initial_, body_) {
227
+ let result_ = initial_;
228
+ ff_core_List.List_each(self_, ((x_) => {
229
+ result_ = body_(result_, x_)
230
+ }));
231
+ return result_
243
232
  }
244
233
 
245
- export function List_first(self_) {
246
- {
247
- const _1 = self_;
248
- {
249
- if(_1.Empty) {
250
- return ff_core_Option.None()
251
- return
234
+ export function List_update(self_, index_, value_) {
235
+ return ff_core_List.List_modify(self_, index_, ((_) => {
236
+ return value_
237
+ }))
252
238
  }
239
+
240
+ export function List_modify(self_, index_, body_) {
241
+
242
+ if(index_ < 0 || index_ >= self_.length) {
243
+ ff_core_Try.internalThrowGrabException_()
244
+ }
245
+ let result = self_.slice();
246
+ result[index_] = body_(result[index_]);
247
+ return result;
248
+
253
249
  }
254
- {
255
- if(_1.Link) {
256
- const head_ = _1.head_;
257
- return ff_core_Option.Some(head_)
258
- return
250
+
251
+ export function List_zip(self_, that_) {
252
+ if((ff_core_List.List_size(self_) <= ff_core_List.List_size(that_))) {
253
+ let i_ = (-1);
254
+ return ff_core_List.List_map(self_, ((x_) => {
255
+ i_ += 1;
256
+ return ff_core_Pair.Pair(x_, ff_core_List.List_grab(that_, i_))
257
+ }))
258
+ } else {
259
+ let i_ = (-1);
260
+ return ff_core_List.List_map(that_, ((y_) => {
261
+ i_ += 1;
262
+ return ff_core_Pair.Pair(ff_core_List.List_grab(self_, i_), y_)
263
+ }))
259
264
  }
260
265
  }
266
+
267
+ export function List_chunk(self_, chunkSize_) {
268
+ const results_ = ff_core_Array.make_();
269
+ const result_ = ff_core_Array.make_();
270
+ let added_ = 0;
271
+ ff_core_List.List_each(self_, ((item_) => {
272
+ if((added_ < chunkSize_)) {
273
+ added_ += 1
274
+ } else {
275
+ ff_core_Array.Array_push(results_, ff_core_Array.Array_drain(result_));
276
+ added_ = 1
277
+ };
278
+ ff_core_Array.Array_push(result_, item_)
279
+ }));
280
+ if((added_ !== 0)) {
281
+ ff_core_Array.Array_push(results_, ff_core_Array.Array_drain(result_))
282
+ };
283
+ return ff_core_Array.Array_drain(results_)
261
284
  }
285
+
286
+ export function List_toStream(self_, cycle_ = false) {
287
+ let index_ = 0;
288
+ return ff_core_Stream.make_((() => {
289
+ if((index_ < ff_core_List.List_size(self_))) {
290
+ return ff_core_Option.Some((function() {
291
+ const result_ = ff_core_List.List_grab(self_, index_);
292
+ index_ += 1;
293
+ return result_
294
+ })())
295
+ } else if((cycle_ && (index_ !== 0))) {
296
+ return ff_core_Option.Some((function() {
297
+ const result_ = ff_core_List.List_grab(self_, 0);
298
+ index_ = 1;
299
+ return result_
300
+ })())
301
+ } else return ff_core_Option.None()
302
+ }), (() => {
303
+
304
+ }))
262
305
  }
263
306
 
264
- export function List_last(self_) {
265
- _tailcall: for(;;) {
266
- {
267
- const _1 = self_;
268
- {
269
- if(_1.Empty) {
270
- return ff_core_Option.None()
271
- return
307
+ export function List_toArray(self_) {
308
+ return {array: self_.slice()}
272
309
  }
310
+
311
+ export function List_each(self_, body_) {
312
+
313
+ return self_.forEach(body_);
314
+
273
315
  }
274
- {
275
- if(_1.Link) {
276
- const head_ = _1.head_;
277
- if(_1.tail_.Empty) {
278
- return ff_core_Option.Some(head_)
279
- return
316
+
317
+ export function List_eachWhile(self_, body_) {
318
+ for(const value of self_) if(!body_(value)) break
280
319
  }
320
+
321
+ export function List_all(self_, body_) {
322
+ let result_ = true;
323
+ ff_core_List.List_eachWhile(self_, ((x_) => {
324
+ result_ = (result_ && body_(x_));
325
+ return result_
326
+ }));
327
+ return result_
281
328
  }
329
+
330
+ export function List_any(self_, body_) {
331
+ let result_ = false;
332
+ ff_core_List.List_eachWhile(self_, ((x_) => {
333
+ result_ = (result_ || body_(x_));
334
+ return (!result_)
335
+ }));
336
+ return result_
282
337
  }
283
- {
284
- if(_1.Link) {
285
- const tail_ = _1.tail_;
286
- {
287
- const self_r_ = tail_;
288
- self_ = self_r_
289
- continue _tailcall
338
+
339
+ export function List_find(self_, body_) {
340
+ let result_ = ff_core_Option.None();
341
+ ff_core_List.List_eachWhile(self_, ((x_) => {
342
+ if(body_(x_)) {
343
+ result_ = ff_core_Option.Some(x_);
344
+ return false
345
+ } else {
346
+ return true
290
347
  }
291
- return
348
+ }));
349
+ return result_
292
350
  }
351
+
352
+ export function List_filter(self_, body_) {
353
+ const result_ = ff_core_Array.make_();
354
+ ff_core_List.List_each(self_, ((x_) => {
355
+ if(body_(x_)) {
356
+ ff_core_Array.Array_push(result_, x_)
293
357
  }
358
+ }));
359
+ return ff_core_Array.Array_drain(result_)
294
360
  }
295
- return
361
+
362
+ export function List_partition(self_, body_) {
363
+ return ff_core_Pair.Pair(ff_core_List.List_filter(self_, body_), ff_core_List.List_filter(self_, ((_w1) => {
364
+ return (!body_(_w1))
365
+ })))
296
366
  }
367
+
368
+ export function List_map(self_, body_) {
369
+
370
+ return self_.map(body_)
371
+
297
372
  }
298
373
 
299
- export function List_grabFirst(self_) {
300
- return ff_core_Option.Option_else(ff_core_List.List_first(self_), (() => {
301
- return ff_core_Try.internalThrowGrabException_()
302
- }))
374
+ export function List_flatMap(self_, body_) {
375
+ const results_ = ff_core_Array.make_();
376
+ ff_core_List.List_each(self_, ((x_) => {
377
+ ff_core_Array.Array_pushList(results_, body_(x_))
378
+ }));
379
+ return ff_core_Array.Array_drain(results_)
303
380
  }
304
381
 
305
- export function List_grabLast(self_) {
306
- return ff_core_Option.Option_else(ff_core_List.List_last(self_), (() => {
307
- return ff_core_Try.internalThrowGrabException_()
382
+ export function List_collect(self_, body_) {
383
+ let result_ = ff_core_Array.make_();
384
+ ff_core_List.List_each(self_, ((x_) => {
385
+ ff_core_Option.Option_each(body_(x_), ((_w1) => {
386
+ ff_core_Array.Array_push(result_, _w1)
308
387
  }))
388
+ }));
389
+ return ff_core_Array.Array_drain(result_)
309
390
  }
310
391
 
311
- export function List_dropFirst(self_, count_ = 1) {
312
- _tailcall: for(;;) {
392
+ export function List_collectFirst(self_, body_) {
393
+ let result_ = ff_core_Option.None();
394
+ ff_core_List.List_eachWhile(self_, ((x_) => {
313
395
  {
314
- const _1 = self_;
396
+ const _1 = body_(x_);
315
397
  {
316
- const _guard1 = (count_ <= 0);
317
- if(_guard1) {
318
- return self_
398
+ if(_1.None) {
399
+ return true
319
400
  return
320
401
  }
321
402
  }
322
403
  {
323
- if(_1.Empty) {
324
- return self_
404
+ const o_ = _1;
405
+ result_ = o_;
406
+ return false
325
407
  return
326
408
  }
327
409
  }
328
- {
329
- if(_1.Link) {
330
- const tail_ = _1.tail_;
331
- {
332
- const self_r_ = tail_;
333
- const count_r_ = (count_ - 1);
334
- self_ = self_r_
335
- count_ = count_r_
336
- continue _tailcall
410
+ }));
411
+ return result_
337
412
  }
338
- return
413
+
414
+ export function List_sortBy(self_, body_, ff_core_Ordering_Order$S) {
415
+ return ff_core_List.List_sortWith(self_, ((_w1, _w2) => {
416
+ return ff_core_Ordering_Order$S.compare_(body_(_w1), body_(_w2))
417
+ }))
339
418
  }
419
+
420
+ export function List_sortWith(self_, ordering_) {
421
+ const array_ = ff_core_List.List_toArray(self_);
422
+ ff_core_Array.Array_sortWith(array_, ordering_);
423
+ return ff_core_Array.Array_drain(array_)
340
424
  }
425
+
426
+ export function List_reverse(self_) {
427
+ return ff_core_List.List_map(ff_core_Int.Int_to(1, ff_core_List.List_size(self_)), ((i_) => {
428
+ return ff_core_List.List_grab(self_, (ff_core_List.List_size(self_) - i_))
429
+ }))
341
430
  }
431
+
432
+ export function List_separate(self_, separator_) {
433
+ const array_ = ff_core_Array.make_();
434
+ ff_core_List.List_each(ff_core_List.List_pairs(self_), ((_1) => {
435
+ {
436
+ const i_ = _1.first_;
437
+ const x_ = _1.second_;
438
+ if((i_ !== 0)) {
439
+ ff_core_Array.Array_pushList(array_, separator_)
440
+ };
441
+ ff_core_Array.Array_push(array_, x_)
342
442
  return
343
443
  }
444
+ }));
445
+ return ff_core_Array.Array_drain(array_)
344
446
  }
345
447
 
346
- export function List_dropLast(self_, count_ = 1) {
347
- return ff_core_List.List_reverse(ff_core_List.List_dropFirst(ff_core_List.List_reverse(self_), count_))
448
+ export async function List_addAll$(self_, that_, $task) {
449
+ throw new Error('Function List_addAll is missing on this target in async context.');
348
450
  }
349
451
 
350
- export function List_takeFirst(self_, count_ = 1) {
351
- function go_(list_, count_, result_) {
352
- _tailcall: for(;;) {
353
- {
354
- const _1 = list_;
355
- {
356
- const _guard1 = (count_ <= 0);
357
- if(_guard1) {
358
- return ff_core_List.List_reverse(result_)
359
- return
452
+ export async function List_isEmpty$(self_, $task) {
453
+ throw new Error('Function List_isEmpty is missing on this target in async context.');
360
454
  }
455
+
456
+ export async function List_size$(self_, $task) {
457
+ throw new Error('Function List_size is missing on this target in async context.');
361
458
  }
362
- {
363
- if(_1.Empty) {
364
- return ff_core_List.List_reverse(result_)
365
- return
459
+
460
+ export async function List_get$(self_, index_, $task) {
461
+ throw new Error('Function List_get is missing on this target in async context.');
366
462
  }
463
+
464
+ export async function List_grab$(self_, index_, $task) {
465
+ throw new Error('Function List_grab is missing on this target in async context.');
367
466
  }
368
- {
369
- if(_1.Link) {
370
- const head_ = _1.head_;
371
- const tail_ = _1.tail_;
372
- {
373
- const list_r_ = tail_;
374
- const count_r_ = (count_ - 1);
375
- const result_r_ = ff_core_List.Link(head_, result_);
376
- list_ = list_r_
377
- count_ = count_r_
378
- result_ = result_r_
379
- continue _tailcall
467
+
468
+ export async function List_first$(self_, $task) {
469
+ return ff_core_List.List_get(self_, 0)
380
470
  }
381
- return
471
+
472
+ export async function List_last$(self_, $task) {
473
+ return ff_core_List.List_get(self_, (ff_core_List.List_size(self_) - 1))
382
474
  }
475
+
476
+ export async function List_grabFirst$(self_, $task) {
477
+ return ff_core_List.List_grab(self_, 0)
383
478
  }
479
+
480
+ export async function List_grabLast$(self_, $task) {
481
+ return ff_core_List.List_grab(self_, (ff_core_List.List_size(self_) - 1))
384
482
  }
385
- return
483
+
484
+ export async function List_takeFirst$(self_, count_ = 1, $task) {
485
+ throw new Error('Function List_takeFirst is missing on this target in async context.');
386
486
  }
487
+
488
+ export async function List_takeLast$(self_, count_ = 1, $task) {
489
+ throw new Error('Function List_takeLast is missing on this target in async context.');
387
490
  }
388
- return go_(self_, count_, ff_core_List.Empty())
491
+
492
+ export async function List_dropFirst$(self_, count_ = 1, $task) {
493
+ throw new Error('Function List_dropFirst is missing on this target in async context.');
389
494
  }
390
495
 
391
- export function List_takeLast(self_, count_ = 1) {
392
- return ff_core_List.List_reverse(ff_core_List.List_takeFirst(ff_core_List.List_reverse(self_), count_))
496
+ export async function List_dropLast$(self_, count_ = 1, $task) {
497
+ throw new Error('Function List_dropLast is missing on this target in async context.');
393
498
  }
394
499
 
395
- export function List_pairs(self_) {
500
+ export async function List_pairs$(self_, $task) {
396
501
  let i_ = 0;
397
502
  return ff_core_List.List_map(self_, ((x_) => {
398
503
  const r_ = ff_core_Pair.Pair(i_, x_);
@@ -401,1552 +506,252 @@ return r_
401
506
  }))
402
507
  }
403
508
 
404
- export function List_slice(self_, from_, until_) {
509
+ export async function List_slice$(self_, from_, until_, $task) {
405
510
  return ff_core_List.List_takeFirst(ff_core_List.List_dropFirst(self_, from_), (until_ - from_))
406
511
  }
407
512
 
408
- export function List_isEmpty(self_) {
409
- {
410
- const _1 = self_;
411
- {
412
- if(_1.Empty) {
413
- return true
414
- return
415
- }
416
- }
417
- {
418
- return false
419
- return
420
- }
421
- }
422
- }
423
-
424
- export function List_size(self_) {
425
- function go_(list_, result_) {
426
- _tailcall: for(;;) {
427
- {
428
- const _1 = list_;
429
- {
430
- if(_1.Empty) {
431
- return result_
432
- return
433
- }
434
- }
435
- {
436
- if(_1.Link) {
437
- const tail_ = _1.tail_;
438
- {
439
- const list_r_ = tail_;
440
- const result_r_ = (result_ + 1);
441
- list_ = list_r_
442
- result_ = result_r_
443
- continue _tailcall
444
- }
445
- return
446
- }
447
- }
448
- }
449
- return
450
- }
451
- }
452
- return go_(self_, 0)
453
- }
454
-
455
- export function List_each(self_, body_) {
456
- _tailcall: for(;;) {
457
- {
458
- const _1 = self_;
459
- {
460
- if(_1.Empty) {
461
-
462
- return
463
- }
464
- }
465
- {
466
- if(_1.Link) {
467
- const head_ = _1.head_;
468
- const tail_ = _1.tail_;
469
- body_(head_);
470
- {
471
- const self_r_ = tail_;
472
- const body_r_ = body_;
473
- self_ = self_r_
474
- body_ = body_r_
475
- continue _tailcall
476
- }
477
- return
478
- }
479
- }
480
- }
481
- return
482
- }
483
- }
484
-
485
- export function List_eachWhile(self_, body_) {
486
- return ff_core_List.List_all(self_, body_)
487
- }
488
-
489
- export function List_all(self_, body_) {
490
- _tailcall: for(;;) {
491
- {
492
- const _1 = self_;
493
- {
494
- if(_1.Empty) {
495
- return true
496
- return
497
- }
498
- }
499
- {
500
- if(_1.Link) {
501
- const head_ = _1.head_;
502
- const _guard1 = (!body_(head_));
503
- if(_guard1) {
504
- return false
505
- return
506
- }
507
- }
508
- }
509
- {
510
- if(_1.Link) {
511
- const tail_ = _1.tail_;
512
- {
513
- const self_r_ = tail_;
514
- const body_r_ = body_;
515
- self_ = self_r_
516
- body_ = body_r_
517
- continue _tailcall
518
- }
519
- return
520
- }
521
- }
522
- }
523
- return
524
- }
525
- }
526
-
527
- export function List_any(self_, body_) {
528
- _tailcall: for(;;) {
529
- {
530
- const _1 = self_;
531
- {
532
- if(_1.Empty) {
533
- return false
534
- return
535
- }
536
- }
537
- {
538
- if(_1.Link) {
539
- const head_ = _1.head_;
540
- const _guard1 = body_(head_);
541
- if(_guard1) {
542
- return true
543
- return
544
- }
545
- }
546
- }
547
- {
548
- if(_1.Link) {
549
- const tail_ = _1.tail_;
550
- {
551
- const self_r_ = tail_;
552
- const body_r_ = body_;
553
- self_ = self_r_
554
- body_ = body_r_
555
- continue _tailcall
556
- }
557
- return
558
- }
559
- }
560
- }
561
- return
562
- }
563
- }
564
-
565
- export function List_find(self_, body_) {
566
- _tailcall: for(;;) {
567
- {
568
- const _1 = self_;
569
- {
570
- if(_1.Empty) {
571
- return ff_core_Option.None()
572
- return
573
- }
574
- }
575
- {
576
- if(_1.Link) {
577
- const head_ = _1.head_;
578
- const _guard1 = body_(head_);
579
- if(_guard1) {
580
- return ff_core_Option.Some(head_)
581
- return
582
- }
583
- }
584
- }
585
- {
586
- if(_1.Link) {
587
- const tail_ = _1.tail_;
588
- {
589
- const self_r_ = tail_;
590
- const body_r_ = body_;
591
- self_ = self_r_
592
- body_ = body_r_
593
- continue _tailcall
594
- }
595
- return
596
- }
597
- }
598
- }
599
- return
600
- }
601
- }
602
-
603
- export function List_filter(self_, body_) {
604
- function go_(list_, result_) {
605
- _tailcall: for(;;) {
606
- {
607
- const _1 = list_;
608
- {
609
- if(_1.Empty) {
610
- return ff_core_List.List_reverse(result_)
611
- return
612
- }
613
- }
614
- {
615
- if(_1.Link) {
616
- const head_ = _1.head_;
617
- const tail_ = _1.tail_;
618
- const _guard1 = body_(head_);
619
- if(_guard1) {
620
- {
621
- const list_r_ = tail_;
622
- const result_r_ = ff_core_List.Link(head_, result_);
623
- list_ = list_r_
624
- result_ = result_r_
625
- continue _tailcall
626
- }
627
- return
628
- }
629
- }
630
- }
631
- {
632
- if(_1.Link) {
633
- const tail_ = _1.tail_;
634
- {
635
- const list_r_ = tail_;
636
- const result_r_ = result_;
637
- list_ = list_r_
638
- result_ = result_r_
639
- continue _tailcall
640
- }
641
- return
642
- }
643
- }
644
- }
645
- return
646
- }
647
- }
648
- return go_(self_, ff_core_List.Empty())
649
- }
650
-
651
- export function List_partition(self_, body_) {
652
- return ff_core_Pair.Pair(ff_core_List.List_filter(self_, body_), ff_core_List.List_filter(self_, ((_w1) => {
653
- return (!body_(_w1))
654
- })))
655
- }
656
-
657
- export function List_map(self_, body_) {
658
- function go_(list_, result_) {
659
- _tailcall: for(;;) {
660
- {
661
- const _1 = list_;
662
- {
663
- if(_1.Empty) {
664
- return ff_core_List.List_reverse(result_)
665
- return
666
- }
667
- }
668
- {
669
- if(_1.Link) {
670
- const head_ = _1.head_;
671
- const tail_ = _1.tail_;
672
- {
673
- const list_r_ = tail_;
674
- const result_r_ = ff_core_List.Link(body_(head_), result_);
675
- list_ = list_r_
676
- result_ = result_r_
677
- continue _tailcall
678
- }
679
- return
680
- }
681
- }
682
- }
683
- return
684
- }
685
- }
686
- return go_(self_, ff_core_List.Empty())
687
- }
688
-
689
- export function List_flatMap(self_, body_) {
690
- function go_(list_, result_) {
691
- _tailcall: for(;;) {
692
- {
693
- const _1 = list_;
694
- {
695
- if(_1.Empty) {
696
- return ff_core_List.List_flatten(ff_core_List.List_reverse(result_))
697
- return
698
- }
699
- }
700
- {
701
- if(_1.Link) {
702
- const head_ = _1.head_;
703
- const tail_ = _1.tail_;
704
- {
705
- const list_r_ = tail_;
706
- const result_r_ = ff_core_List.Link(body_(head_), result_);
707
- list_ = list_r_
708
- result_ = result_r_
709
- continue _tailcall
710
- }
711
- return
712
- }
713
- }
714
- }
715
- return
716
- }
717
- }
718
- return go_(self_, ff_core_List.Empty())
719
- }
720
-
721
- export function List_collect(self_, body_) {
722
- return ff_core_Stream.Stream_toList(ff_core_Stream.Stream_collect(ff_core_List.List_toStream(self_, false), body_))
723
- }
724
-
725
- export function List_collectFirst(self_, body_) {
726
- _tailcall: for(;;) {
727
- {
728
- const _1 = self_;
729
- {
730
- if(_1.Empty) {
731
- return ff_core_Option.None()
732
- return
733
- }
734
- }
735
- {
736
- if(_1.Link) {
737
- const head_ = _1.head_;
738
- const tail_ = _1.tail_;
739
- {
740
- const _1 = body_(head_);
741
- {
742
- if(_1.None) {
743
- {
744
- const self_r_ = tail_;
745
- const body_r_ = body_;
746
- self_ = self_r_
747
- body_ = body_r_
748
- continue _tailcall
749
- }
750
- return
751
- }
752
- }
753
- {
754
- if(_1.Some) {
755
- const value_ = _1.value_;
756
- return ff_core_Option.Some(value_)
757
- return
758
- }
759
- }
760
- }
761
- return
762
- }
763
- }
764
- }
765
- return
766
- }
767
- }
768
-
769
- export function List_foldLeft(self_, initial_, body_) {
770
- function go_(state_, list_) {
771
- _tailcall: for(;;) {
772
- {
773
- const _1 = list_;
774
- {
775
- if(_1.Empty) {
776
- return state_
777
- return
778
- }
779
- }
780
- {
781
- if(_1.Link) {
782
- const head_ = _1.head_;
783
- const tail_ = _1.tail_;
784
- {
785
- const state_r_ = body_(state_, head_);
786
- const list_r_ = tail_;
787
- state_ = state_r_
788
- list_ = list_r_
789
- continue _tailcall
790
- }
791
- return
792
- }
793
- }
794
- }
795
- return
796
- }
797
- }
798
- return go_(initial_, self_)
799
- }
800
-
801
- export function List_update(self_, index_, value_) {
802
- function go_(list_, i_, result_) {
803
- _tailcall: for(;;) {
804
- {
805
- const _1 = list_;
806
- {
807
- if(_1.Empty) {
808
- return ff_core_List.List_reverse(result_)
809
- return
810
- }
811
- }
812
- {
813
- if(_1.Link) {
814
- const head_ = _1.head_;
815
- const tail_ = _1.tail_;
816
- const _guard1 = (i_ === 0);
817
- if(_guard1) {
818
- {
819
- const list_r_ = tail_;
820
- const i_r_ = (i_ - 1);
821
- const result_r_ = ff_core_List.Link(value_, result_);
822
- list_ = list_r_
823
- i_ = i_r_
824
- result_ = result_r_
825
- continue _tailcall
826
- }
827
- return
828
- }
829
- }
830
- }
831
- {
832
- if(_1.Link) {
833
- const head_ = _1.head_;
834
- const tail_ = _1.tail_;
835
- {
836
- const list_r_ = tail_;
837
- const i_r_ = (i_ - 1);
838
- const result_r_ = ff_core_List.Link(head_, result_);
839
- list_ = list_r_
840
- i_ = i_r_
841
- result_ = result_r_
842
- continue _tailcall
843
- }
844
- return
845
- }
846
- }
847
- }
848
- return
849
- }
850
- }
851
- return go_(self_, index_, ff_core_List.Empty())
852
- }
853
-
854
- export function List_modify(self_, index_, body_) {
855
- function go_(list_, i_, result_) {
856
- _tailcall: for(;;) {
857
- {
858
- const _1 = list_;
859
- {
860
- if(_1.Empty) {
861
- return ff_core_List.List_reverse(result_)
862
- return
863
- }
864
- }
865
- {
866
- if(_1.Link) {
867
- const head_ = _1.head_;
868
- const tail_ = _1.tail_;
869
- const _guard1 = (i_ === 0);
870
- if(_guard1) {
871
- {
872
- const list_r_ = tail_;
873
- const i_r_ = (i_ - 1);
874
- const result_r_ = ff_core_List.Link(body_(head_), result_);
875
- list_ = list_r_
876
- i_ = i_r_
877
- result_ = result_r_
878
- continue _tailcall
879
- }
880
- return
881
- }
882
- }
883
- }
884
- {
885
- if(_1.Link) {
886
- const head_ = _1.head_;
887
- const tail_ = _1.tail_;
888
- {
889
- const list_r_ = tail_;
890
- const i_r_ = (i_ - 1);
891
- const result_r_ = ff_core_List.Link(head_, result_);
892
- list_ = list_r_
893
- i_ = i_r_
894
- result_ = result_r_
895
- continue _tailcall
896
- }
897
- return
898
- }
899
- }
900
- }
901
- return
902
- }
903
- }
904
- return go_(self_, index_, ff_core_List.Empty())
905
- }
906
-
907
- export function List_zip(self_, that_) {
908
- function go_(list1_, list2_, result_) {
909
- _tailcall: for(;;) {
910
- {
911
- const _1 = ff_core_Pair.Pair(list1_, list2_);
912
- {
913
- if(_1.first_.Link) {
914
- const x_ = _1.first_.head_;
915
- const xs_ = _1.first_.tail_;
916
- if(_1.second_.Link) {
917
- const y_ = _1.second_.head_;
918
- const ys_ = _1.second_.tail_;
919
- {
920
- const list1_r_ = xs_;
921
- const list2_r_ = ys_;
922
- const result_r_ = ff_core_List.Link(ff_core_Pair.Pair(x_, y_), result_);
923
- list1_ = list1_r_
924
- list2_ = list2_r_
925
- result_ = result_r_
926
- continue _tailcall
927
- }
928
- return
929
- }
930
- }
931
- }
932
- {
933
- return ff_core_List.List_reverse(result_)
934
- return
935
- }
936
- }
937
- return
938
- }
939
- }
940
- return go_(self_, that_, ff_core_List.Empty())
941
- }
942
-
943
- export function List_sortBy(self_, body_, ff_core_Ordering_Order$O) {
944
- if((ff_core_List.List_size(self_) <= 1)) {
945
- return self_
946
- } else {
947
- const stack_ = ff_core_List.List_toStack(self_);
948
- ff_core_Stack.Stack_sortBy(stack_, body_, ff_core_Ordering_Order$O);
949
- return ff_core_Stack.Stack_toList(stack_, 0, 9007199254740991)
950
- }
951
- }
952
-
953
- export function List_sortWith(self_, compare_) {
954
- if((ff_core_List.List_size(self_) <= 1)) {
955
- return self_
956
- } else {
957
- const stack_ = ff_core_List.List_toStack(self_);
958
- ff_core_Stack.Stack_sortWith(stack_, compare_);
959
- return ff_core_Stack.Stack_toList(stack_, 0, 9007199254740991)
960
- }
961
- }
962
-
963
- export function List_reverse(self_) {
964
- function go_(list_, result_) {
965
- _tailcall: for(;;) {
966
- {
967
- const _1 = list_;
968
- {
969
- if(_1.Empty) {
970
- return result_
971
- return
972
- }
973
- }
974
- {
975
- if(_1.Link) {
976
- const head_ = _1.head_;
977
- const tail_ = _1.tail_;
978
- {
979
- const list_r_ = tail_;
980
- const result_r_ = ff_core_List.Link(head_, result_);
981
- list_ = list_r_
982
- result_ = result_r_
983
- continue _tailcall
984
- }
985
- return
986
- }
987
- }
988
- }
989
- return
990
- }
991
- }
992
- return go_(self_, ff_core_List.Empty())
993
- }
994
-
995
- export function List_chunk(self_, chunkSize_) {
996
- let results_ = ff_core_List.Empty();
997
- let result_ = ff_core_List.Empty();
998
- let added_ = 0;
999
- ff_core_List.List_each(self_, ((item_) => {
1000
- if((added_ < chunkSize_)) {
1001
- result_ = ff_core_List.Link(item_, result_);
1002
- added_ += 1
1003
- } else {
1004
- results_ = ff_core_List.Link(ff_core_List.List_reverse(result_), results_);
1005
- result_ = ff_core_List.Link(item_, ff_core_List.Empty());
1006
- added_ = 1
1007
- }
1008
- }));
1009
- if((added_ !== 0)) {
1010
- results_ = ff_core_List.Link(ff_core_List.List_reverse(result_), results_)
1011
- };
1012
- return ff_core_List.List_reverse(results_)
1013
- }
1014
-
1015
- export function List_toStream(self_, cycle_ = false) {
1016
- let remaining_ = self_;
1017
- return ff_core_Stream.Stream((() => {
1018
- {
1019
- const _1 = remaining_;
1020
- {
1021
- if(_1.Link) {
1022
- const head_ = _1.head_;
1023
- const tail_ = _1.tail_;
1024
- remaining_ = tail_;
1025
- return ff_core_Option.Some(head_)
1026
- return
1027
- }
1028
- }
1029
- {
1030
- if(_1.Empty) {
1031
- const _guard2 = self_;
1032
- if(_guard2.Link) {
1033
- const head_ = _guard2.head_;
1034
- const tail_ = _guard2.tail_;
1035
- const _guard1 = cycle_;
1036
- if(_guard1) {
1037
- remaining_ = tail_;
1038
- return ff_core_Option.Some(head_)
1039
- return
1040
- }
1041
- }
1042
- }
1043
- }
1044
- {
1045
- if(_1.Empty) {
1046
- return ff_core_Option.None()
1047
- return
1048
- }
1049
- }
1050
- }
1051
- }), (() => {
1052
- remaining_ = ff_core_List.Empty()
1053
- }))
1054
- }
1055
-
1056
- export function List_separate(self_, separator_) {
1057
- return ff_core_List.List_dropFirst(ff_core_List.List_flatMap(self_, ((e_) => {
1058
- return ff_core_List.List_addAll(separator_, ff_core_List.Link(e_, ff_core_List.Empty()))
1059
- })), ff_core_List.List_size(separator_))
1060
- }
1061
-
1062
- export async function List_addAll$(self_, list_, $task) {
1063
- return ff_core_List.List_flatten(ff_core_List.Link(self_, ff_core_List.Link(list_, ff_core_List.Empty())))
1064
- }
1065
-
1066
- export async function List_toStack$(self_, $task) {
1067
- throw new Error('Function List_toStack is missing on this target in async context.');
1068
- }
1069
-
1070
- export async function List_toArray$(self_, $task) {
1071
- return ff_core_Stack.Stack_drain(ff_core_List.List_toStack(self_))
1072
- }
1073
-
1074
- export async function List_grab$(self_, index_, $task) {
1075
- function go_(list_, i_) {
1076
- _tailcall: for(;;) {
1077
- {
1078
- const _1 = list_;
1079
- {
1080
- if(_1.Empty) {
1081
- return ff_core_Try.internalThrowGrabException_()
1082
- return
1083
- }
1084
- }
1085
- {
1086
- if(_1.Link) {
1087
- const head_ = _1.head_;
1088
- const _guard1 = (i_ === 0);
1089
- if(_guard1) {
1090
- return head_
1091
- return
1092
- }
1093
- }
1094
- }
1095
- {
1096
- if(_1.Link) {
1097
- const tail_ = _1.tail_;
1098
- {
1099
- const list_r_ = tail_;
1100
- const i_r_ = (i_ - 1);
1101
- list_ = list_r_
1102
- i_ = i_r_
1103
- continue _tailcall
1104
- }
1105
- return
1106
- }
1107
- }
1108
- }
1109
- return
1110
- }
1111
- }
1112
- return go_(self_, index_)
1113
- }
1114
-
1115
- export async function List_first$(self_, $task) {
1116
- {
1117
- const _1 = self_;
1118
- {
1119
- if(_1.Empty) {
1120
- return ff_core_Option.None()
1121
- return
1122
- }
1123
- }
1124
- {
1125
- if(_1.Link) {
1126
- const head_ = _1.head_;
1127
- return ff_core_Option.Some(head_)
1128
- return
1129
- }
1130
- }
1131
- }
1132
- }
1133
-
1134
- export async function List_last$(self_, $task) {
1135
- _tailcall: for(;;) {
1136
- {
1137
- const _1 = self_;
1138
- {
1139
- if(_1.Empty) {
1140
- return ff_core_Option.None()
1141
- return
1142
- }
1143
- }
1144
- {
1145
- if(_1.Link) {
1146
- const head_ = _1.head_;
1147
- if(_1.tail_.Empty) {
1148
- return ff_core_Option.Some(head_)
1149
- return
1150
- }
1151
- }
1152
- }
1153
- {
1154
- if(_1.Link) {
1155
- const tail_ = _1.tail_;
1156
- {
1157
- const self_r_ = tail_;
1158
- self_ = self_r_
1159
- continue _tailcall
1160
- }
1161
- return
1162
- }
1163
- }
1164
- }
1165
- return
1166
- }
1167
- }
1168
-
1169
- export async function List_grabFirst$(self_, $task) {
1170
- return ff_core_Option.Option_else(ff_core_List.List_first(self_), (() => {
1171
- return ff_core_Try.internalThrowGrabException_()
1172
- }))
1173
- }
1174
-
1175
- export async function List_grabLast$(self_, $task) {
1176
- return ff_core_Option.Option_else(ff_core_List.List_last(self_), (() => {
1177
- return ff_core_Try.internalThrowGrabException_()
1178
- }))
1179
- }
1180
-
1181
- export async function List_dropFirst$(self_, count_ = 1, $task) {
1182
- _tailcall: for(;;) {
1183
- {
1184
- const _1 = self_;
1185
- {
1186
- const _guard1 = (count_ <= 0);
1187
- if(_guard1) {
1188
- return self_
1189
- return
1190
- }
1191
- }
1192
- {
1193
- if(_1.Empty) {
1194
- return self_
1195
- return
1196
- }
1197
- }
1198
- {
1199
- if(_1.Link) {
1200
- const tail_ = _1.tail_;
1201
- {
1202
- const self_r_ = tail_;
1203
- const count_r_ = (count_ - 1);
1204
- self_ = self_r_
1205
- count_ = count_r_
1206
- continue _tailcall
1207
- }
1208
- return
1209
- }
1210
- }
1211
- }
1212
- return
1213
- }
1214
- }
1215
-
1216
- export async function List_dropLast$(self_, count_ = 1, $task) {
1217
- return ff_core_List.List_reverse(ff_core_List.List_dropFirst(ff_core_List.List_reverse(self_), count_))
1218
- }
1219
-
1220
- export async function List_takeFirst$(self_, count_ = 1, $task) {
1221
- function go_(list_, count_, result_) {
1222
- _tailcall: for(;;) {
1223
- {
1224
- const _1 = list_;
1225
- {
1226
- const _guard1 = (count_ <= 0);
1227
- if(_guard1) {
1228
- return ff_core_List.List_reverse(result_)
1229
- return
1230
- }
1231
- }
1232
- {
1233
- if(_1.Empty) {
1234
- return ff_core_List.List_reverse(result_)
1235
- return
1236
- }
1237
- }
1238
- {
1239
- if(_1.Link) {
1240
- const head_ = _1.head_;
1241
- const tail_ = _1.tail_;
1242
- {
1243
- const list_r_ = tail_;
1244
- const count_r_ = (count_ - 1);
1245
- const result_r_ = ff_core_List.Link(head_, result_);
1246
- list_ = list_r_
1247
- count_ = count_r_
1248
- result_ = result_r_
1249
- continue _tailcall
1250
- }
1251
- return
1252
- }
1253
- }
1254
- }
1255
- return
1256
- }
1257
- }
1258
- return go_(self_, count_, ff_core_List.Empty())
1259
- }
1260
-
1261
- export async function List_takeLast$(self_, count_ = 1, $task) {
1262
- return ff_core_List.List_reverse(ff_core_List.List_takeFirst(ff_core_List.List_reverse(self_), count_))
1263
- }
1264
-
1265
- export async function List_pairs$(self_, $task) {
1266
- let i_ = 0;
1267
- return ff_core_List.List_map(self_, ((x_) => {
1268
- const r_ = ff_core_Pair.Pair(i_, x_);
1269
- i_ += 1;
1270
- return r_
1271
- }))
1272
- }
1273
-
1274
- export async function List_slice$(self_, from_, until_, $task) {
1275
- return ff_core_List.List_takeFirst(ff_core_List.List_dropFirst(self_, from_), (until_ - from_))
1276
- }
1277
-
1278
- export async function List_isEmpty$(self_, $task) {
1279
- {
1280
- const _1 = self_;
1281
- {
1282
- if(_1.Empty) {
1283
- return true
1284
- return
1285
- }
1286
- }
1287
- {
1288
- return false
1289
- return
1290
- }
1291
- }
1292
- }
1293
-
1294
- export async function List_size$(self_, $task) {
1295
- function go_(list_, result_) {
1296
- _tailcall: for(;;) {
1297
- {
1298
- const _1 = list_;
1299
- {
1300
- if(_1.Empty) {
1301
- return result_
1302
- return
1303
- }
1304
- }
1305
- {
1306
- if(_1.Link) {
1307
- const tail_ = _1.tail_;
1308
- {
1309
- const list_r_ = tail_;
1310
- const result_r_ = (result_ + 1);
1311
- list_ = list_r_
1312
- result_ = result_r_
1313
- continue _tailcall
1314
- }
1315
- return
1316
- }
1317
- }
1318
- }
1319
- return
1320
- }
1321
- }
1322
- return go_(self_, 0)
1323
- }
1324
-
1325
- export async function List_each$(self_, body_, $task) {
1326
- _tailcall: for(;;) {
1327
- {
1328
- const _1 = self_;
1329
- {
1330
- if(_1.Empty) {
1331
-
1332
- return
1333
- }
1334
- }
1335
- {
1336
- if(_1.Link) {
1337
- const head_ = _1.head_;
1338
- const tail_ = _1.tail_;
1339
- (await body_(head_, $task));
1340
- {
1341
- const self_r_ = tail_;
1342
- const body_r_ = body_;
1343
- self_ = self_r_
1344
- body_ = body_r_
1345
- continue _tailcall
1346
- }
1347
- return
1348
- }
1349
- }
1350
- }
1351
- return
1352
- }
1353
- }
1354
-
1355
- export async function List_eachWhile$(self_, body_, $task) {
1356
- return (await ff_core_List.List_all$(self_, body_, $task))
1357
- }
1358
-
1359
- export async function List_all$(self_, body_, $task) {
1360
- _tailcall: for(;;) {
1361
- {
1362
- const _1 = self_;
1363
- {
1364
- if(_1.Empty) {
1365
- return true
1366
- return
1367
- }
1368
- }
1369
- {
1370
- if(_1.Link) {
1371
- const head_ = _1.head_;
1372
- const _guard1 = (!(await body_(head_, $task)));
1373
- if(_guard1) {
1374
- return false
1375
- return
1376
- }
1377
- }
1378
- }
1379
- {
1380
- if(_1.Link) {
1381
- const tail_ = _1.tail_;
1382
- {
1383
- const self_r_ = tail_;
1384
- const body_r_ = body_;
1385
- self_ = self_r_
1386
- body_ = body_r_
1387
- continue _tailcall
1388
- }
1389
- return
1390
- }
1391
- }
1392
- }
1393
- return
1394
- }
1395
- }
1396
-
1397
- export async function List_any$(self_, body_, $task) {
1398
- _tailcall: for(;;) {
1399
- {
1400
- const _1 = self_;
1401
- {
1402
- if(_1.Empty) {
1403
- return false
1404
- return
1405
- }
1406
- }
1407
- {
1408
- if(_1.Link) {
1409
- const head_ = _1.head_;
1410
- const _guard1 = (await body_(head_, $task));
1411
- if(_guard1) {
1412
- return true
1413
- return
1414
- }
1415
- }
1416
- }
1417
- {
1418
- if(_1.Link) {
1419
- const tail_ = _1.tail_;
1420
- {
1421
- const self_r_ = tail_;
1422
- const body_r_ = body_;
1423
- self_ = self_r_
1424
- body_ = body_r_
1425
- continue _tailcall
1426
- }
1427
- return
1428
- }
1429
- }
1430
- }
1431
- return
1432
- }
1433
- }
1434
-
1435
- export async function List_find$(self_, body_, $task) {
1436
- _tailcall: for(;;) {
1437
- {
1438
- const _1 = self_;
1439
- {
1440
- if(_1.Empty) {
1441
- return ff_core_Option.None()
1442
- return
1443
- }
1444
- }
1445
- {
1446
- if(_1.Link) {
1447
- const head_ = _1.head_;
1448
- const _guard1 = (await body_(head_, $task));
1449
- if(_guard1) {
1450
- return ff_core_Option.Some(head_)
1451
- return
1452
- }
1453
- }
1454
- }
1455
- {
1456
- if(_1.Link) {
1457
- const tail_ = _1.tail_;
1458
- {
1459
- const self_r_ = tail_;
1460
- const body_r_ = body_;
1461
- self_ = self_r_
1462
- body_ = body_r_
1463
- continue _tailcall
1464
- }
1465
- return
1466
- }
1467
- }
1468
- }
1469
- return
1470
- }
1471
- }
1472
-
1473
- export async function List_filter$(self_, body_, $task) {
1474
- async function go_$(list_, result_, $task) {
1475
- _tailcall: for(;;) {
1476
- {
1477
- const _1 = list_;
1478
- {
1479
- if(_1.Empty) {
1480
- return ff_core_List.List_reverse(result_)
1481
- return
1482
- }
1483
- }
1484
- {
1485
- if(_1.Link) {
1486
- const head_ = _1.head_;
1487
- const tail_ = _1.tail_;
1488
- const _guard1 = (await body_(head_, $task));
1489
- if(_guard1) {
1490
- {
1491
- const list_r_ = tail_;
1492
- const result_r_ = ff_core_List.Link(head_, result_);
1493
- list_ = list_r_
1494
- result_ = result_r_
1495
- continue _tailcall
1496
- }
1497
- return
1498
- }
1499
- }
1500
- }
1501
- {
1502
- if(_1.Link) {
1503
- const tail_ = _1.tail_;
1504
- {
1505
- const list_r_ = tail_;
1506
- const result_r_ = result_;
1507
- list_ = list_r_
1508
- result_ = result_r_
1509
- continue _tailcall
1510
- }
1511
- return
1512
- }
1513
- }
1514
- }
1515
- return
1516
- }
1517
- }
1518
- return (await go_$(self_, ff_core_List.Empty(), $task))
1519
- }
1520
-
1521
- export async function List_partition$(self_, body_, $task) {
1522
- return ff_core_Pair.Pair((await ff_core_List.List_filter$(self_, body_, $task)), (await ff_core_List.List_filter$(self_, (async (_w1, $task) => {
1523
- return (!(await body_(_w1, $task)))
1524
- }), $task)))
1525
- }
1526
-
1527
- export async function List_map$(self_, body_, $task) {
1528
- async function go_$(list_, result_, $task) {
1529
- _tailcall: for(;;) {
1530
- {
1531
- const _1 = list_;
1532
- {
1533
- if(_1.Empty) {
1534
- return ff_core_List.List_reverse(result_)
1535
- return
1536
- }
1537
- }
1538
- {
1539
- if(_1.Link) {
1540
- const head_ = _1.head_;
1541
- const tail_ = _1.tail_;
1542
- {
1543
- const list_r_ = tail_;
1544
- const result_r_ = ff_core_List.Link((await body_(head_, $task)), result_);
1545
- list_ = list_r_
1546
- result_ = result_r_
1547
- continue _tailcall
1548
- }
1549
- return
1550
- }
1551
- }
1552
- }
1553
- return
1554
- }
1555
- }
1556
- return (await go_$(self_, ff_core_List.Empty(), $task))
513
+ export async function List_foldLeft$(self_, initial_, body_, $task) {
514
+ let result_ = initial_;
515
+ (await ff_core_List.List_each$(self_, (async (x_, $task) => {
516
+ result_ = (await body_(result_, x_, $task))
517
+ }), $task));
518
+ return result_
1557
519
  }
1558
520
 
1559
- export async function List_flatMap$(self_, body_, $task) {
1560
- async function go_$(list_, result_, $task) {
1561
- _tailcall: for(;;) {
1562
- {
1563
- const _1 = list_;
1564
- {
1565
- if(_1.Empty) {
1566
- return ff_core_List.List_flatten(ff_core_List.List_reverse(result_))
1567
- return
1568
- }
1569
- }
1570
- {
1571
- if(_1.Link) {
1572
- const head_ = _1.head_;
1573
- const tail_ = _1.tail_;
1574
- {
1575
- const list_r_ = tail_;
1576
- const result_r_ = ff_core_List.Link((await body_(head_, $task)), result_);
1577
- list_ = list_r_
1578
- result_ = result_r_
1579
- continue _tailcall
1580
- }
1581
- return
1582
- }
1583
- }
1584
- }
1585
- return
1586
- }
1587
- }
1588
- return (await go_$(self_, ff_core_List.Empty(), $task))
521
+ export async function List_update$(self_, index_, value_, $task) {
522
+ return ff_core_List.List_modify(self_, index_, ((_) => {
523
+ return value_
524
+ }))
1589
525
  }
1590
526
 
1591
- export async function List_collect$(self_, body_, $task) {
1592
- return (await ff_core_Stream.Stream_toList$((await ff_core_Stream.Stream_collect$((await ff_core_List.List_toStream$(self_, false, $task)), body_, $task)), $task))
527
+ export async function List_modify$(self_, index_, body_, $task) {
528
+
529
+ if(index_ < 0 || index_ >= self_.length) {
530
+ ff_core_Try.internalThrowGrabException_()
531
+ }
532
+ let result = self_.slice();
533
+ result[index_] = await body_(result[index_], $task);
534
+ return result;
535
+
1593
536
  }
1594
537
 
1595
- export async function List_collectFirst$(self_, body_, $task) {
1596
- _tailcall: for(;;) {
1597
- {
1598
- const _1 = self_;
1599
- {
1600
- if(_1.Empty) {
1601
- return ff_core_Option.None()
1602
- return
1603
- }
1604
- }
1605
- {
1606
- if(_1.Link) {
1607
- const head_ = _1.head_;
1608
- const tail_ = _1.tail_;
1609
- {
1610
- const _1 = (await body_(head_, $task));
1611
- {
1612
- if(_1.None) {
1613
- {
1614
- const self_r_ = tail_;
1615
- const body_r_ = body_;
1616
- self_ = self_r_
1617
- body_ = body_r_
1618
- continue _tailcall
1619
- }
1620
- return
1621
- }
1622
- }
1623
- {
1624
- if(_1.Some) {
1625
- const value_ = _1.value_;
1626
- return ff_core_Option.Some(value_)
1627
- return
1628
- }
1629
- }
1630
- }
1631
- return
1632
- }
1633
- }
1634
- }
1635
- return
538
+ export async function List_zip$(self_, that_, $task) {
539
+ if((ff_core_List.List_size(self_) <= ff_core_List.List_size(that_))) {
540
+ let i_ = (-1);
541
+ return ff_core_List.List_map(self_, ((x_) => {
542
+ i_ += 1;
543
+ return ff_core_Pair.Pair(x_, ff_core_List.List_grab(that_, i_))
544
+ }))
545
+ } else {
546
+ let i_ = (-1);
547
+ return ff_core_List.List_map(that_, ((y_) => {
548
+ i_ += 1;
549
+ return ff_core_Pair.Pair(ff_core_List.List_grab(self_, i_), y_)
550
+ }))
1636
551
  }
1637
552
  }
1638
553
 
1639
- export async function List_foldLeft$(self_, initial_, body_, $task) {
1640
- async function go_$(state_, list_, $task) {
1641
- _tailcall: for(;;) {
1642
- {
1643
- const _1 = list_;
1644
- {
1645
- if(_1.Empty) {
1646
- return state_
1647
- return
1648
- }
1649
- }
1650
- {
1651
- if(_1.Link) {
1652
- const head_ = _1.head_;
1653
- const tail_ = _1.tail_;
1654
- {
1655
- const state_r_ = (await body_(state_, head_, $task));
1656
- const list_r_ = tail_;
1657
- state_ = state_r_
1658
- list_ = list_r_
1659
- continue _tailcall
1660
- }
1661
- return
1662
- }
1663
- }
1664
- }
1665
- return
1666
- }
1667
- }
1668
- return (await go_$(initial_, self_, $task))
554
+ export async function List_chunk$(self_, chunkSize_, $task) {
555
+ const results_ = ff_core_Array.make_();
556
+ const result_ = ff_core_Array.make_();
557
+ let added_ = 0;
558
+ ff_core_List.List_each(self_, ((item_) => {
559
+ if((added_ < chunkSize_)) {
560
+ added_ += 1
561
+ } else {
562
+ ff_core_Array.Array_push(results_, ff_core_Array.Array_drain(result_));
563
+ added_ = 1
564
+ };
565
+ ff_core_Array.Array_push(result_, item_)
566
+ }));
567
+ if((added_ !== 0)) {
568
+ ff_core_Array.Array_push(results_, ff_core_Array.Array_drain(result_))
569
+ };
570
+ return ff_core_Array.Array_drain(results_)
1669
571
  }
1670
572
 
1671
- export async function List_update$(self_, index_, value_, $task) {
1672
- function go_(list_, i_, result_) {
1673
- _tailcall: for(;;) {
1674
- {
1675
- const _1 = list_;
1676
- {
1677
- if(_1.Empty) {
1678
- return ff_core_List.List_reverse(result_)
1679
- return
1680
- }
1681
- }
1682
- {
1683
- if(_1.Link) {
1684
- const head_ = _1.head_;
1685
- const tail_ = _1.tail_;
1686
- const _guard1 = (i_ === 0);
1687
- if(_guard1) {
1688
- {
1689
- const list_r_ = tail_;
1690
- const i_r_ = (i_ - 1);
1691
- const result_r_ = ff_core_List.Link(value_, result_);
1692
- list_ = list_r_
1693
- i_ = i_r_
1694
- result_ = result_r_
1695
- continue _tailcall
1696
- }
1697
- return
1698
- }
1699
- }
1700
- }
1701
- {
1702
- if(_1.Link) {
1703
- const head_ = _1.head_;
1704
- const tail_ = _1.tail_;
1705
- {
1706
- const list_r_ = tail_;
1707
- const i_r_ = (i_ - 1);
1708
- const result_r_ = ff_core_List.Link(head_, result_);
1709
- list_ = list_r_
1710
- i_ = i_r_
1711
- result_ = result_r_
1712
- continue _tailcall
1713
- }
1714
- return
1715
- }
1716
- }
1717
- }
1718
- return
1719
- }
1720
- }
1721
- return go_(self_, index_, ff_core_List.Empty())
1722
- }
573
+ export async function List_toStream$(self_, cycle_ = false, $task) {
574
+ let index_ = 0;
575
+ return (await ff_core_Stream.make_$((async ($task) => {
576
+ if((index_ < ff_core_List.List_size(self_))) {
577
+ return ff_core_Option.Some((await (async function() {
578
+ const result_ = ff_core_List.List_grab(self_, index_);
579
+ index_ += 1;
580
+ return result_
581
+ })()))
582
+ } else if((cycle_ && (index_ !== 0))) {
583
+ return ff_core_Option.Some((await (async function() {
584
+ const result_ = ff_core_List.List_grab(self_, 0);
585
+ index_ = 1;
586
+ return result_
587
+ })()))
588
+ } else return ff_core_Option.None()
589
+ }), (async ($task) => {
1723
590
 
1724
- export async function List_modify$(self_, index_, body_, $task) {
1725
- async function go_$(list_, i_, result_, $task) {
1726
- _tailcall: for(;;) {
1727
- {
1728
- const _1 = list_;
1729
- {
1730
- if(_1.Empty) {
1731
- return ff_core_List.List_reverse(result_)
1732
- return
1733
- }
1734
- }
1735
- {
1736
- if(_1.Link) {
1737
- const head_ = _1.head_;
1738
- const tail_ = _1.tail_;
1739
- const _guard1 = (i_ === 0);
1740
- if(_guard1) {
1741
- {
1742
- const list_r_ = tail_;
1743
- const i_r_ = (i_ - 1);
1744
- const result_r_ = ff_core_List.Link((await body_(head_, $task)), result_);
1745
- list_ = list_r_
1746
- i_ = i_r_
1747
- result_ = result_r_
1748
- continue _tailcall
1749
- }
1750
- return
1751
- }
1752
- }
1753
- }
1754
- {
1755
- if(_1.Link) {
1756
- const head_ = _1.head_;
1757
- const tail_ = _1.tail_;
1758
- {
1759
- const list_r_ = tail_;
1760
- const i_r_ = (i_ - 1);
1761
- const result_r_ = ff_core_List.Link(head_, result_);
1762
- list_ = list_r_
1763
- i_ = i_r_
1764
- result_ = result_r_
1765
- continue _tailcall
1766
- }
1767
- return
1768
- }
1769
- }
1770
- }
1771
- return
1772
- }
1773
- }
1774
- return (await go_$(self_, index_, ff_core_List.Empty(), $task))
591
+ }), $task))
1775
592
  }
1776
593
 
1777
- export async function List_zip$(self_, that_, $task) {
1778
- function go_(list1_, list2_, result_) {
1779
- _tailcall: for(;;) {
1780
- {
1781
- const _1 = ff_core_Pair.Pair(list1_, list2_);
1782
- {
1783
- if(_1.first_.Link) {
1784
- const x_ = _1.first_.head_;
1785
- const xs_ = _1.first_.tail_;
1786
- if(_1.second_.Link) {
1787
- const y_ = _1.second_.head_;
1788
- const ys_ = _1.second_.tail_;
1789
- {
1790
- const list1_r_ = xs_;
1791
- const list2_r_ = ys_;
1792
- const result_r_ = ff_core_List.Link(ff_core_Pair.Pair(x_, y_), result_);
1793
- list1_ = list1_r_
1794
- list2_ = list2_r_
1795
- result_ = result_r_
1796
- continue _tailcall
1797
- }
1798
- return
1799
- }
1800
- }
1801
- }
1802
- {
1803
- return ff_core_List.List_reverse(result_)
1804
- return
1805
- }
1806
- }
1807
- return
1808
- }
1809
- }
1810
- return go_(self_, that_, ff_core_List.Empty())
594
+ export async function List_toArray$(self_, $task) {
595
+ throw new Error('Function List_toArray is missing on this target in async context.');
1811
596
  }
1812
597
 
1813
- export async function List_sortBy$(self_, body_, ff_core_Ordering_Order$O, $task) {
1814
- if((ff_core_List.List_size(self_) <= 1)) {
1815
- return self_
1816
- } else {
1817
- const stack_ = ff_core_List.List_toStack(self_);
1818
- (await ff_core_Stack.Stack_sortBy$(stack_, body_, ff_core_Ordering_Order$O, $task));
1819
- return ff_core_Stack.Stack_toList(stack_, 0, 9007199254740991)
1820
- }
598
+ export async function List_each$(self_, body_, $task) {
599
+
600
+ for(let i = 0; i < self_.length; i++) {
601
+ await body_(self_[i], $task)
602
+ }
603
+
1821
604
  }
1822
605
 
1823
- export async function List_sortWith$(self_, compare_, $task) {
1824
- if((ff_core_List.List_size(self_) <= 1)) {
1825
- return self_
1826
- } else {
1827
- const stack_ = ff_core_List.List_toStack(self_);
1828
- (await ff_core_Stack.Stack_sortWith$(stack_, compare_, $task));
1829
- return ff_core_Stack.Stack_toList(stack_, 0, 9007199254740991)
1830
- }
606
+ export async function List_eachWhile$(self_, body_, $task) {
607
+ for(const value of self_) if(!await body_(value, $task)) break
1831
608
  }
1832
609
 
1833
- export async function List_reverse$(self_, $task) {
1834
- function go_(list_, result_) {
1835
- _tailcall: for(;;) {
1836
- {
1837
- const _1 = list_;
1838
- {
1839
- if(_1.Empty) {
610
+ export async function List_all$(self_, body_, $task) {
611
+ let result_ = true;
612
+ (await ff_core_List.List_eachWhile$(self_, (async (x_, $task) => {
613
+ result_ = (result_ && (await body_(x_, $task)));
614
+ return result_
615
+ }), $task));
1840
616
  return result_
1841
- return
1842
- }
1843
617
  }
1844
- {
1845
- if(_1.Link) {
1846
- const head_ = _1.head_;
1847
- const tail_ = _1.tail_;
1848
- {
1849
- const list_r_ = tail_;
1850
- const result_r_ = ff_core_List.Link(head_, result_);
1851
- list_ = list_r_
1852
- result_ = result_r_
1853
- continue _tailcall
618
+
619
+ export async function List_any$(self_, body_, $task) {
620
+ let result_ = false;
621
+ (await ff_core_List.List_eachWhile$(self_, (async (x_, $task) => {
622
+ result_ = (result_ || (await body_(x_, $task)));
623
+ return (!result_)
624
+ }), $task));
625
+ return result_
1854
626
  }
1855
- return
627
+
628
+ export async function List_find$(self_, body_, $task) {
629
+ let result_ = ff_core_Option.None();
630
+ (await ff_core_List.List_eachWhile$(self_, (async (x_, $task) => {
631
+ if((await body_(x_, $task))) {
632
+ result_ = ff_core_Option.Some(x_);
633
+ return false
634
+ } else {
635
+ return true
1856
636
  }
637
+ }), $task));
638
+ return result_
1857
639
  }
640
+
641
+ export async function List_filter$(self_, body_, $task) {
642
+ const result_ = ff_core_Array.make_();
643
+ (await ff_core_List.List_each$(self_, (async (x_, $task) => {
644
+ if((await body_(x_, $task))) {
645
+ ff_core_Array.Array_push(result_, x_)
1858
646
  }
1859
- return
647
+ }), $task));
648
+ return ff_core_Array.Array_drain(result_)
1860
649
  }
650
+
651
+ export async function List_partition$(self_, body_, $task) {
652
+ return ff_core_Pair.Pair((await ff_core_List.List_filter$(self_, body_, $task)), (await ff_core_List.List_filter$(self_, (async (_w1, $task) => {
653
+ return (!(await body_(_w1, $task)))
654
+ }), $task)))
1861
655
  }
1862
- return go_(self_, ff_core_List.Empty())
656
+
657
+ export async function List_map$(self_, body_, $task) {
658
+
659
+ let result = [];
660
+ for(let i = 0; i < self_.length; i++) {
661
+ result.push(await body_(self_[i], $task));
662
+ }
663
+ return result;
664
+
1863
665
  }
1864
666
 
1865
- export async function List_chunk$(self_, chunkSize_, $task) {
1866
- let results_ = ff_core_List.Empty();
1867
- let result_ = ff_core_List.Empty();
1868
- let added_ = 0;
1869
- ff_core_List.List_each(self_, ((item_) => {
1870
- if((added_ < chunkSize_)) {
1871
- result_ = ff_core_List.Link(item_, result_);
1872
- added_ += 1
1873
- } else {
1874
- results_ = ff_core_List.Link(ff_core_List.List_reverse(result_), results_);
1875
- result_ = ff_core_List.Link(item_, ff_core_List.Empty());
1876
- added_ = 1
667
+ export async function List_flatMap$(self_, body_, $task) {
668
+ const results_ = ff_core_Array.make_();
669
+ (await ff_core_List.List_each$(self_, (async (x_, $task) => {
670
+ ff_core_Array.Array_pushList(results_, (await body_(x_, $task)))
671
+ }), $task));
672
+ return ff_core_Array.Array_drain(results_)
1877
673
  }
1878
- }));
1879
- if((added_ !== 0)) {
1880
- results_ = ff_core_List.Link(ff_core_List.List_reverse(result_), results_)
1881
- };
1882
- return ff_core_List.List_reverse(results_)
674
+
675
+ export async function List_collect$(self_, body_, $task) {
676
+ let result_ = ff_core_Array.make_();
677
+ (await ff_core_List.List_each$(self_, (async (x_, $task) => {
678
+ ff_core_Option.Option_each((await body_(x_, $task)), ((_w1) => {
679
+ ff_core_Array.Array_push(result_, _w1)
680
+ }))
681
+ }), $task));
682
+ return ff_core_Array.Array_drain(result_)
1883
683
  }
1884
684
 
1885
- export async function List_toStream$(self_, cycle_ = false, $task) {
1886
- let remaining_ = self_;
1887
- return ff_core_Stream.Stream((async ($task) => {
685
+ export async function List_collectFirst$(self_, body_, $task) {
686
+ let result_ = ff_core_Option.None();
687
+ (await ff_core_List.List_eachWhile$(self_, (async (x_, $task) => {
1888
688
  {
1889
- const _1 = remaining_;
689
+ const _1 = (await body_(x_, $task));
1890
690
  {
1891
- if(_1.Link) {
1892
- const head_ = _1.head_;
1893
- const tail_ = _1.tail_;
1894
- remaining_ = tail_;
1895
- return ff_core_Option.Some(head_)
691
+ if(_1.None) {
692
+ return true
1896
693
  return
1897
694
  }
1898
695
  }
1899
696
  {
1900
- if(_1.Empty) {
1901
- const _guard2 = self_;
1902
- if(_guard2.Link) {
1903
- const head_ = _guard2.head_;
1904
- const tail_ = _guard2.tail_;
1905
- const _guard1 = cycle_;
1906
- if(_guard1) {
1907
- remaining_ = tail_;
1908
- return ff_core_Option.Some(head_)
697
+ const o_ = _1;
698
+ result_ = o_;
699
+ return false
1909
700
  return
1910
701
  }
1911
702
  }
703
+ }), $task));
704
+ return result_
1912
705
  }
706
+
707
+ export async function List_sortBy$(self_, body_, ff_core_Ordering_Order$S, $task) {
708
+ return (await ff_core_List.List_sortWith$(self_, (async (_w1, _w2, $task) => {
709
+ return ff_core_Ordering_Order$S.compare_((await body_(_w1, $task)), (await body_(_w2, $task)))
710
+ }), $task))
1913
711
  }
1914
- {
1915
- if(_1.Empty) {
1916
- return ff_core_Option.None()
1917
- return
1918
- }
1919
- }
712
+
713
+ export async function List_sortWith$(self_, ordering_, $task) {
714
+ const array_ = ff_core_List.List_toArray(self_);
715
+ (await ff_core_Array.Array_sortWith$(array_, ordering_, $task));
716
+ return ff_core_Array.Array_drain(array_)
1920
717
  }
1921
- }), (async ($task) => {
1922
- remaining_ = ff_core_List.Empty()
718
+
719
+ export async function List_reverse$(self_, $task) {
720
+ return ff_core_List.List_map(ff_core_Int.Int_to(1, ff_core_List.List_size(self_)), ((i_) => {
721
+ return ff_core_List.List_grab(self_, (ff_core_List.List_size(self_) - i_))
1923
722
  }))
1924
723
  }
1925
724
 
1926
725
  export async function List_separate$(self_, separator_, $task) {
1927
- return ff_core_List.List_dropFirst(ff_core_List.List_flatMap(self_, ((e_) => {
1928
- return ff_core_List.List_addAll(separator_, ff_core_List.Link(e_, ff_core_List.Empty()))
1929
- })), ff_core_List.List_size(separator_))
726
+ const array_ = ff_core_Array.make_();
727
+ ff_core_List.List_each(ff_core_List.List_pairs(self_), ((_1) => {
728
+ {
729
+ const i_ = _1.first_;
730
+ const x_ = _1.second_;
731
+ if((i_ !== 0)) {
732
+ ff_core_Array.Array_pushList(array_, separator_)
733
+ };
734
+ ff_core_Array.Array_push(array_, x_)
735
+ return
736
+ }
737
+ }));
738
+ return ff_core_Array.Array_drain(array_)
1930
739
  }
1931
740
 
1932
741
  export function List_sort(self_, ff_core_Ordering_Order$T) {
1933
- if((ff_core_List.List_size(self_) <= 1)) {
1934
- return self_
1935
- } else {
1936
- const stack_ = ff_core_List.List_toStack(self_);
1937
- ff_core_Stack.Stack_sort(stack_, ff_core_Ordering_Order$T);
1938
- return ff_core_Stack.Stack_toList(stack_, 0, 9007199254740991)
1939
- }
742
+ return ff_core_List.List_sortWith(self_, ((x_, y_) => {
743
+ return ff_core_Ordering_Order$T.compare_(x_, y_)
744
+ }))
1940
745
  }
1941
746
 
1942
747
  export function List_toSet(self_, ff_core_Ordering_Order$T) {
1943
- return ff_core_List.List_foldLeft(self_, ff_core_Set.empty_(), ((set_, value_) => {
1944
- return ff_core_Set.Set_add(set_, value_, ff_core_Ordering_Order$T)
748
+ return ff_core_List.List_foldLeft(self_, ff_core_Set.empty_(), ((_w1, _w2) => {
749
+ return ff_core_Set.Set_add(_w1, _w2, ff_core_Ordering_Order$T)
1945
750
  }))
1946
751
  }
1947
752
 
1948
753
  export function List_distinct(self_, ff_core_Ordering_Order$T) {
1949
- let seen_ = ff_core_List.List_toSet(ff_core_List.Empty(), ff_core_Ordering_Order$T);
754
+ let seen_ = ff_core_List.List_toSet([], ff_core_Ordering_Order$T);
1950
755
  return ff_core_List.List_filter(self_, ((_1) => {
1951
756
  {
1952
757
  const item_ = _1;
@@ -1965,23 +770,19 @@ return
1965
770
  }
1966
771
 
1967
772
  export async function List_sort$(self_, ff_core_Ordering_Order$T, $task) {
1968
- if((ff_core_List.List_size(self_) <= 1)) {
1969
- return self_
1970
- } else {
1971
- const stack_ = ff_core_List.List_toStack(self_);
1972
- ff_core_Stack.Stack_sort(stack_, ff_core_Ordering_Order$T);
1973
- return ff_core_Stack.Stack_toList(stack_, 0, 9007199254740991)
1974
- }
773
+ return ff_core_List.List_sortWith(self_, ((x_, y_) => {
774
+ return ff_core_Ordering_Order$T.compare_(x_, y_)
775
+ }))
1975
776
  }
1976
777
 
1977
778
  export async function List_toSet$(self_, ff_core_Ordering_Order$T, $task) {
1978
- return ff_core_List.List_foldLeft(self_, ff_core_Set.empty_(), ((set_, value_) => {
1979
- return ff_core_Set.Set_add(set_, value_, ff_core_Ordering_Order$T)
779
+ return ff_core_List.List_foldLeft(self_, ff_core_Set.empty_(), ((_w1, _w2) => {
780
+ return ff_core_Set.Set_add(_w1, _w2, ff_core_Ordering_Order$T)
1980
781
  }))
1981
782
  }
1982
783
 
1983
784
  export async function List_distinct$(self_, ff_core_Ordering_Order$T, $task) {
1984
- let seen_ = ff_core_List.List_toSet(ff_core_List.Empty(), ff_core_Ordering_Order$T);
785
+ let seen_ = ff_core_List.List_toSet([], ff_core_Ordering_Order$T);
1985
786
  return ff_core_List.List_filter(self_, ((_1) => {
1986
787
  {
1987
788
  const item_ = _1;
@@ -1999,361 +800,219 @@ return
1999
800
  }))
2000
801
  }
2001
802
 
2002
- export function List_show(self_, ff_core_Show_Show$T) {
2003
- return ff_core_Show.ff_core_Show_Show$ff_core_List_List(ff_core_Show_Show$T).show_(self_)
2004
- }
2005
-
2006
- export async function List_show$(self_, ff_core_Show_Show$T, $task) {
2007
- return ff_core_Show.ff_core_Show_Show$ff_core_List_List(ff_core_Show_Show$T).show_(self_)
2008
- }
2009
-
2010
803
  export function List_flatten(self_) {
2011
- function finish_(list_, result_) {
2012
- _tailcall: for(;;) {
2013
- {
2014
- const list_a = list_;
2015
- const result_a = result_;
2016
- {
2017
- const as_ = list_a;
2018
- if(result_a.Empty) {
2019
- return as_
2020
- return
2021
- }
2022
- }
2023
- {
2024
- const as_ = list_a;
2025
- if(result_a.Link) {
2026
- const x_ = result_a.head_;
2027
- const xs_ = result_a.tail_;
2028
- {
2029
- const list_r_ = ff_core_List.Link(x_, as_);
2030
- const result_r_ = xs_;
2031
- list_ = list_r_
2032
- result_ = result_r_
2033
- continue _tailcall
2034
- }
2035
- return
2036
- }
2037
- }
2038
- }
2039
- return
2040
- }
2041
- }
2042
- function go_(lists_, result_) {
2043
- _tailcall: for(;;) {
2044
- {
2045
- const _1 = lists_;
2046
- {
2047
- if(_1.Empty) {
2048
- return ff_core_List.Empty()
2049
- return
2050
- }
2051
- }
2052
- {
2053
- if(_1.Link) {
2054
- const as_ = _1.head_;
2055
- if(_1.tail_.Empty) {
2056
- return finish_(as_, result_)
2057
- return
2058
- }
2059
- }
2060
- }
2061
- {
2062
- if(_1.Link) {
2063
- if(_1.head_.Empty) {
2064
- const aas_ = _1.tail_;
2065
- {
2066
- const lists_r_ = aas_;
2067
- const result_r_ = result_;
2068
- lists_ = lists_r_
2069
- result_ = result_r_
2070
- continue _tailcall
2071
- }
2072
- return
2073
- }
2074
- }
2075
- }
2076
- {
2077
- if(_1.Link) {
2078
- if(_1.head_.Link) {
2079
- const a_ = _1.head_.head_;
2080
- const as_ = _1.head_.tail_;
2081
- const aas_ = _1.tail_;
2082
- {
2083
- const lists_r_ = ff_core_List.Link(as_, aas_);
2084
- const result_r_ = ff_core_List.Link(a_, result_);
2085
- lists_ = lists_r_
2086
- result_ = result_r_
2087
- continue _tailcall
2088
- }
2089
- return
2090
- }
2091
- }
2092
- }
2093
- }
2094
- return
2095
- }
2096
- }
2097
- return go_(self_, ff_core_List.Empty())
804
+ const result_ = ff_core_Array.make_();
805
+ ff_core_List.List_each(self_, ((xs_) => {
806
+ ff_core_Array.Array_pushList(result_, xs_)
807
+ }));
808
+ return ff_core_Array.Array_drain(result_)
2098
809
  }
2099
810
 
2100
811
  export async function List_flatten$(self_, $task) {
2101
- function finish_(list_, result_) {
2102
- _tailcall: for(;;) {
2103
- {
2104
- const list_a = list_;
2105
- const result_a = result_;
2106
- {
2107
- const as_ = list_a;
2108
- if(result_a.Empty) {
2109
- return as_
2110
- return
2111
- }
2112
- }
2113
- {
2114
- const as_ = list_a;
2115
- if(result_a.Link) {
2116
- const x_ = result_a.head_;
2117
- const xs_ = result_a.tail_;
2118
- {
2119
- const list_r_ = ff_core_List.Link(x_, as_);
2120
- const result_r_ = xs_;
2121
- list_ = list_r_
2122
- result_ = result_r_
2123
- continue _tailcall
2124
- }
2125
- return
2126
- }
2127
- }
2128
- }
2129
- return
2130
- }
2131
- }
2132
- function go_(lists_, result_) {
2133
- _tailcall: for(;;) {
2134
- {
2135
- const _1 = lists_;
2136
- {
2137
- if(_1.Empty) {
2138
- return ff_core_List.Empty()
2139
- return
2140
- }
812
+ const result_ = ff_core_Array.make_();
813
+ ff_core_List.List_each(self_, ((xs_) => {
814
+ ff_core_Array.Array_pushList(result_, xs_)
815
+ }));
816
+ return ff_core_Array.Array_drain(result_)
2141
817
  }
818
+
819
+ export function List_toMap(self_, ff_core_Ordering_Order$K) {
820
+ return ff_core_List.List_foldLeft(self_, ff_core_Map.empty_(), ((_1, _2) => {
2142
821
  {
2143
- if(_1.Link) {
2144
- const as_ = _1.head_;
2145
- if(_1.tail_.Empty) {
2146
- return finish_(as_, result_)
822
+ const map_ = _1;
823
+ const key_ = _2.first_;
824
+ const value_ = _2.second_;
825
+ return ff_core_Map.Map_add(map_, key_, value_, ff_core_Ordering_Order$K)
2147
826
  return
2148
827
  }
828
+ }))
2149
829
  }
2150
- }
2151
- {
2152
- if(_1.Link) {
2153
- if(_1.head_.Empty) {
2154
- const aas_ = _1.tail_;
830
+
831
+ export function List_group(self_, ff_core_Ordering_Order$K) {
832
+ let map_ = ff_core_Map.empty_();
833
+ ff_core_List.List_each(self_, ((_1) => {
2155
834
  {
2156
- const lists_r_ = aas_;
2157
- const result_r_ = result_;
2158
- lists_ = lists_r_
2159
- result_ = result_r_
2160
- continue _tailcall
2161
- }
835
+ const k_ = _1.first_;
836
+ const v_ = _1.second_;
837
+ map_ = ff_core_Map.Map_push(map_, k_, v_, ff_core_Ordering_Order$K)
2162
838
  return
2163
839
  }
840
+ }));
841
+ return ff_core_Map.Map_mapValues(map_, ((_, v_) => {
842
+ return ff_core_Array.Array_drain(v_)
843
+ }), ff_core_Ordering_Order$K)
2164
844
  }
2165
- }
2166
- {
2167
- if(_1.Link) {
2168
- if(_1.head_.Link) {
2169
- const a_ = _1.head_.head_;
2170
- const as_ = _1.head_.tail_;
2171
- const aas_ = _1.tail_;
845
+
846
+ export async function List_toMap$(self_, ff_core_Ordering_Order$K, $task) {
847
+ return ff_core_List.List_foldLeft(self_, ff_core_Map.empty_(), ((_1, _2) => {
2172
848
  {
2173
- const lists_r_ = ff_core_List.Link(as_, aas_);
2174
- const result_r_ = ff_core_List.Link(a_, result_);
2175
- lists_ = lists_r_
2176
- result_ = result_r_
2177
- continue _tailcall
2178
- }
2179
- return
2180
- }
2181
- }
2182
- }
2183
- }
849
+ const map_ = _1;
850
+ const key_ = _2.first_;
851
+ const value_ = _2.second_;
852
+ return ff_core_Map.Map_add(map_, key_, value_, ff_core_Ordering_Order$K)
2184
853
  return
2185
854
  }
2186
- }
2187
- return go_(self_, ff_core_List.Empty())
2188
- }
2189
-
2190
- export function List_toMap(self_, ff_core_Ordering_Order$K) {
2191
- return ff_core_List.List_foldLeft(self_, ff_core_Map.empty_(), ((map_, pair_) => {
2192
- return ff_core_Map.Map_add(map_, pair_.first_, pair_.second_, ff_core_Ordering_Order$K)
2193
- }))
2194
- }
2195
-
2196
- export function List_group(self_, ff_core_Ordering_Order$K) {
2197
- const initial_ = ff_core_List.Empty();
2198
- return ff_core_List.List_foldLeft(self_, ff_core_List.List_toMap(initial_, ff_core_Ordering_Order$K), ((map_, pair_) => {
2199
- return ff_core_Map.Map_addToList(map_, pair_.first_, pair_.second_, ff_core_Ordering_Order$K)
2200
- }))
2201
- }
2202
-
2203
- export async function List_toMap$(self_, ff_core_Ordering_Order$K, $task) {
2204
- return ff_core_List.List_foldLeft(self_, ff_core_Map.empty_(), ((map_, pair_) => {
2205
- return ff_core_Map.Map_add(map_, pair_.first_, pair_.second_, ff_core_Ordering_Order$K)
2206
855
  }))
2207
856
  }
2208
857
 
2209
858
  export async function List_group$(self_, ff_core_Ordering_Order$K, $task) {
2210
- const initial_ = ff_core_List.Empty();
2211
- return ff_core_List.List_foldLeft(self_, ff_core_List.List_toMap(initial_, ff_core_Ordering_Order$K), ((map_, pair_) => {
2212
- return ff_core_Map.Map_addToList(map_, pair_.first_, pair_.second_, ff_core_Ordering_Order$K)
2213
- }))
2214
- }
2215
-
2216
- export function List_unzip(self_) {
2217
- function go_(pairs_, ks_, vs_) {
2218
- _tailcall: for(;;) {
2219
- {
2220
- const _1 = pairs_;
859
+ let map_ = ff_core_Map.empty_();
860
+ ff_core_List.List_each(self_, ((_1) => {
2221
861
  {
2222
- if(_1.Empty) {
2223
- return ff_core_Pair.Pair(ff_core_List.List_reverse(ks_), ff_core_List.List_reverse(vs_))
862
+ const k_ = _1.first_;
863
+ const v_ = _1.second_;
864
+ map_ = ff_core_Map.Map_push(map_, k_, v_, ff_core_Ordering_Order$K)
2224
865
  return
2225
866
  }
867
+ }));
868
+ return ff_core_Map.Map_mapValues(map_, ((_, v_) => {
869
+ return ff_core_Array.Array_drain(v_)
870
+ }), ff_core_Ordering_Order$K)
2226
871
  }
872
+
873
+ export function List_unzip(self_) {
874
+ const first_ = ff_core_Array.make_();
875
+ const second_ = ff_core_Array.make_();
876
+ ff_core_List.List_each(self_, ((_1) => {
2227
877
  {
2228
- if(_1.Link) {
2229
- const k_ = _1.head_.first_;
2230
- const v_ = _1.head_.second_;
2231
- const tail_ = _1.tail_;
2232
- {
2233
- const pairs_r_ = tail_;
2234
- const ks_r_ = ff_core_List.Link(k_, ks_);
2235
- const vs_r_ = ff_core_List.Link(v_, vs_);
2236
- pairs_ = pairs_r_
2237
- ks_ = ks_r_
2238
- vs_ = vs_r_
2239
- continue _tailcall
2240
- }
2241
- return
2242
- }
2243
- }
2244
- }
878
+ const x_ = _1.first_;
879
+ const y_ = _1.second_;
880
+ ff_core_Array.Array_push(first_, x_);
881
+ ff_core_Array.Array_push(second_, y_)
2245
882
  return
2246
883
  }
2247
- }
2248
- return go_(self_, ff_core_List.Empty(), ff_core_List.Empty())
884
+ }));
885
+ return ff_core_Pair.Pair(ff_core_Array.Array_drain(first_), ff_core_Array.Array_drain(second_))
2249
886
  }
2250
887
 
2251
888
  export async function List_unzip$(self_, $task) {
2252
- function go_(pairs_, ks_, vs_) {
2253
- _tailcall: for(;;) {
2254
- {
2255
- const _1 = pairs_;
889
+ const first_ = ff_core_Array.make_();
890
+ const second_ = ff_core_Array.make_();
891
+ ff_core_List.List_each(self_, ((_1) => {
2256
892
  {
2257
- if(_1.Empty) {
2258
- return ff_core_Pair.Pair(ff_core_List.List_reverse(ks_), ff_core_List.List_reverse(vs_))
2259
- return
2260
- }
2261
- }
2262
- {
2263
- if(_1.Link) {
2264
- const k_ = _1.head_.first_;
2265
- const v_ = _1.head_.second_;
2266
- const tail_ = _1.tail_;
2267
- {
2268
- const pairs_r_ = tail_;
2269
- const ks_r_ = ff_core_List.Link(k_, ks_);
2270
- const vs_r_ = ff_core_List.Link(v_, vs_);
2271
- pairs_ = pairs_r_
2272
- ks_ = ks_r_
2273
- vs_ = vs_r_
2274
- continue _tailcall
2275
- }
2276
- return
2277
- }
2278
- }
2279
- }
893
+ const x_ = _1.first_;
894
+ const y_ = _1.second_;
895
+ ff_core_Array.Array_push(first_, x_);
896
+ ff_core_Array.Array_push(second_, y_)
2280
897
  return
2281
898
  }
2282
- }
2283
- return go_(self_, ff_core_List.Empty(), ff_core_List.Empty())
899
+ }));
900
+ return ff_core_Pair.Pair(ff_core_Array.Array_drain(first_), ff_core_Array.Array_drain(second_))
2284
901
  }
2285
902
 
2286
903
  export function List_join(self_, separator_ = "") {
2287
- return ff_core_Array.Array_join(ff_core_List.List_toArray(self_), separator_)
904
+ return self_.join(separator_)
2288
905
  }
2289
906
 
2290
907
  export async function List_join$(self_, separator_ = "", $task) {
2291
- return ff_core_Array.Array_join(ff_core_List.List_toArray(self_), separator_)
908
+ throw new Error('Function List_join is missing on this target in async context.');
2292
909
  }
2293
910
 
2294
- export function ff_core_Any_HasAnyTag$ff_core_List_List(ff_core_Any_HasAnyTag$T) { return {
2295
- anyTag_() {
2296
- return ff_core_Any.internalAnyTag_(((("ff:core/List.List" + "[") + ff_core_Any.AnyTag_show(ff_core_Any_HasAnyTag$T.anyTag_())) + "]"))
911
+ export function ff_core_Show_Show$ff_core_List_List(ff_core_Show_Show$T) { return {
912
+ show_(value_) {
913
+ const array_ = ff_core_Array.make_();
914
+ ff_core_Array.Array_push(array_, "[");
915
+ ff_core_List.List_each(value_, ((x_) => {
916
+ if((ff_core_Array.Array_size(array_) > 1)) {
917
+ ff_core_Array.Array_push(array_, ", ")
918
+ };
919
+ ff_core_Array.Array_push(array_, ff_core_Show_Show$T.show_(x_))
920
+ }));
921
+ ff_core_Array.Array_push(array_, "]");
922
+ return ff_core_Array.Array_join(array_, "")
2297
923
  },
2298
- async anyTag_$($task) {
2299
- return ff_core_Any.internalAnyTag_(((("ff:core/List.List" + "[") + ff_core_Any.AnyTag_show(ff_core_Any_HasAnyTag$T.anyTag_())) + "]"))
924
+ async show_$(value_, $task) {
925
+ const array_ = ff_core_Array.make_();
926
+ ff_core_Array.Array_push(array_, "[");
927
+ ff_core_List.List_each(value_, ((x_) => {
928
+ if((ff_core_Array.Array_size(array_) > 1)) {
929
+ ff_core_Array.Array_push(array_, ", ")
930
+ };
931
+ ff_core_Array.Array_push(array_, ff_core_Show_Show$T.show_(x_))
932
+ }));
933
+ ff_core_Array.Array_push(array_, "]");
934
+ return ff_core_Array.Array_join(array_, "")
2300
935
  }
2301
936
  }}
2302
937
 
2303
938
  export function ff_core_Equal_Equal$ff_core_List_List(ff_core_Equal_Equal$T) { return {
2304
939
  equals_(x_, y_) {
2305
- {
2306
- const x_a = x_;
2307
- const y_a = y_;
2308
- {
2309
- const _guard1 = (x_ === y_);
2310
- if(_guard1) {
940
+ if(ff_core_List.internalSame_(x_, y_)) {
2311
941
  return true
2312
- return
2313
- }
2314
- }
2315
- {
2316
- if(x_a.Link) {
2317
- const x_ = x_a;
2318
- if(y_a.Link) {
2319
- const y_ = y_a;
2320
- return (ff_core_Equal_Equal$T.equals_(x_.head_, y_.head_) && ff_core_List.ff_core_Equal_Equal$ff_core_List_List(ff_core_Equal_Equal$T).equals_(x_.tail_, y_.tail_))
2321
- return
2322
- }
2323
- }
2324
- }
2325
- {
942
+ } else {
943
+ if((ff_core_List.List_size(x_) !== ff_core_List.List_size(y_))) {
2326
944
  return false
2327
- return
945
+ } else {
946
+ let i_ = (-1);
947
+ return ff_core_List.List_all(x_, ((l_) => {
948
+ i_ += 1;
949
+ return ff_core_Equal_Equal$T.equals_(l_, ff_core_List.List_grab(y_, i_))
950
+ }))
2328
951
  }
2329
952
  }
2330
953
  },
2331
954
  async equals_$(x_, y_, $task) {
2332
- {
2333
- const x_a = x_;
2334
- const y_a = y_;
2335
- {
2336
- const _guard1 = (x_ === y_);
2337
- if(_guard1) {
955
+ if(ff_core_List.internalSame_(x_, y_)) {
2338
956
  return true
2339
- return
957
+ } else {
958
+ if((ff_core_List.List_size(x_) !== ff_core_List.List_size(y_))) {
959
+ return false
960
+ } else {
961
+ let i_ = (-1);
962
+ return ff_core_List.List_all(x_, ((l_) => {
963
+ i_ += 1;
964
+ return ff_core_Equal_Equal$T.equals_(l_, ff_core_List.List_grab(y_, i_))
965
+ }))
2340
966
  }
2341
967
  }
2342
- {
2343
- if(x_a.Link) {
2344
- const x_ = x_a;
2345
- if(y_a.Link) {
2346
- const y_ = y_a;
2347
- return (ff_core_Equal_Equal$T.equals_(x_.head_, y_.head_) && ff_core_List.ff_core_Equal_Equal$ff_core_List_List(ff_core_Equal_Equal$T).equals_(x_.tail_, y_.tail_))
2348
- return
2349
968
  }
969
+ }}
970
+
971
+ export function ff_core_Ordering_Order$ff_core_List_List(ff_core_Ordering_Order$T) { return {
972
+ compare_(x_, y_) {
973
+ if(ff_core_List.internalSame_(x_, y_)) {
974
+ return ff_core_Ordering.OrderingSame()
975
+ } else {
976
+ const size_ = ff_core_Int.Int_min(ff_core_List.List_size(x_), ff_core_List.List_size(y_));
977
+ let i_ = 0;
978
+ let ordering_ = ff_core_Ordering.OrderingSame();
979
+ while(((ordering_ === ff_core_Ordering.OrderingSame()) && (i_ < size_))) {
980
+ ordering_ = ff_core_Ordering_Order$T.compare_(ff_core_List.List_grab(x_, i_), ff_core_List.List_grab(y_, i_));
981
+ i_ += 1
982
+ };
983
+ if((ordering_ !== ff_core_Ordering.OrderingSame())) {
984
+ return ordering_
985
+ } else {
986
+ return ff_core_Ordering.ff_core_Ordering_Order$ff_core_Int_Int.compare_(ff_core_List.List_size(x_), ff_core_List.List_size(y_))
2350
987
  }
2351
988
  }
2352
- {
2353
- return false
2354
- return
989
+ },
990
+ async compare_$(x_, y_, $task) {
991
+ if(ff_core_List.internalSame_(x_, y_)) {
992
+ return ff_core_Ordering.OrderingSame()
993
+ } else {
994
+ const size_ = ff_core_Int.Int_min(ff_core_List.List_size(x_), ff_core_List.List_size(y_));
995
+ let i_ = 0;
996
+ let ordering_ = ff_core_Ordering.OrderingSame();
997
+ while(((ordering_ === ff_core_Ordering.OrderingSame()) && (i_ < size_))) {
998
+ ordering_ = ff_core_Ordering_Order$T.compare_(ff_core_List.List_grab(x_, i_), ff_core_List.List_grab(y_, i_));
999
+ i_ += 1
1000
+ };
1001
+ if((ordering_ !== ff_core_Ordering.OrderingSame())) {
1002
+ return ordering_
1003
+ } else {
1004
+ return ff_core_Ordering.ff_core_Ordering_Order$ff_core_Int_Int.compare_(ff_core_List.List_size(x_), ff_core_List.List_size(y_))
1005
+ }
2355
1006
  }
2356
1007
  }
1008
+ }}
1009
+
1010
+ export function ff_core_Any_HasAnyTag$ff_core_List_List(ff_core_Any_HasAnyTag$T) { return {
1011
+ anyTag_() {
1012
+ return ff_core_Any.internalAnyTag_(((("ff:core/List.List" + "[") + ff_core_Any.AnyTag_show(ff_core_Any_HasAnyTag$T.anyTag_())) + "]"))
1013
+ },
1014
+ async anyTag_$($task) {
1015
+ return ff_core_Any.internalAnyTag_(((("ff:core/List.List" + "[") + ff_core_Any.AnyTag_show(ff_core_Any_HasAnyTag$T.anyTag_())) + "]"))
2357
1016
  }
2358
1017
  }}
2359
1018