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