firefly-compiler 0.4.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (221) hide show
  1. package/.firefly-workspace +1 -0
  2. package/.vscode/settings.json +5 -0
  3. package/LICENSE.txt +21 -0
  4. package/README.md +96 -0
  5. package/bin/firefly.mjs +2 -0
  6. package/compiler/.firefly/package.ff +1 -0
  7. package/compiler/Builder.ff +218 -0
  8. package/compiler/Compiler.ff +241 -0
  9. package/compiler/Dependencies.ff +179 -0
  10. package/compiler/Deriver.ff +647 -0
  11. package/compiler/Dictionaries.ff +205 -0
  12. package/compiler/Environment.ff +166 -0
  13. package/compiler/Inference.ff +1117 -0
  14. package/compiler/JsEmitter.ff +861 -0
  15. package/compiler/JsImporter.ff +56 -0
  16. package/compiler/LspHook.ff +188 -0
  17. package/compiler/Main.ff +237 -0
  18. package/compiler/Parser.ff +1383 -0
  19. package/compiler/Patterns.ff +111 -0
  20. package/compiler/Resolver.ff +620 -0
  21. package/compiler/Substitution.ff +178 -0
  22. package/compiler/Syntax.ff +299 -0
  23. package/compiler/Token.ff +180 -0
  24. package/compiler/Tokenizer.ff +278 -0
  25. package/compiler/Unification.ff +220 -0
  26. package/compiler/Wildcards.ff +50 -0
  27. package/compiler/Workspace.ff +88 -0
  28. package/core/.firefly/package.ff +2 -0
  29. package/core/Any.ff +30 -0
  30. package/core/Array.ff +249 -0
  31. package/core/AssetSystem.ff +61 -0
  32. package/core/Atomic.ff +64 -0
  33. package/core/Bool.ff +13 -0
  34. package/core/BrowserSystem.ff +14 -0
  35. package/core/Buffer.ff +211 -0
  36. package/core/BuildSystem.ff +144 -0
  37. package/core/Channel.ff +131 -0
  38. package/core/Char.ff +18 -0
  39. package/core/Core.ff +58 -0
  40. package/core/Duration.ff +15 -0
  41. package/core/Equal.ff +52 -0
  42. package/core/Error.ff +20 -0
  43. package/core/FileHandle.ff +41 -0
  44. package/core/Float.ff +41 -0
  45. package/core/HttpClient.ff +84 -0
  46. package/core/Instant.ff +9 -0
  47. package/core/Int.ff +61 -0
  48. package/core/IntMap.ff +85 -0
  49. package/core/JsSystem.ff +66 -0
  50. package/core/JsValue.ff +240 -0
  51. package/core/List.ff +440 -0
  52. package/core/Lock.ff +144 -0
  53. package/core/Log.ff +24 -0
  54. package/core/Map.ff +126 -0
  55. package/core/NodeSystem.ff +88 -0
  56. package/core/Nothing.ff +1 -0
  57. package/core/Option.ff +133 -0
  58. package/core/Ordering.ff +157 -0
  59. package/core/Pair.ff +55 -0
  60. package/core/Path.ff +393 -0
  61. package/core/RbMap.ff +216 -0
  62. package/core/Serializable.ff +173 -0
  63. package/core/Set.ff +38 -0
  64. package/core/Show.ff +43 -0
  65. package/core/Stack.ff +263 -0
  66. package/core/Stream.ff +406 -0
  67. package/core/String.ff +175 -0
  68. package/core/StringMap.ff +85 -0
  69. package/core/Task.ff +138 -0
  70. package/core/Try.ff +81 -0
  71. package/core/Unit.ff +3 -0
  72. package/experimental/random/AltGeneric.ff +44 -0
  73. package/experimental/random/Async.ff +68 -0
  74. package/experimental/random/Buffer2.ff +77 -0
  75. package/experimental/random/Cat.ff +12 -0
  76. package/experimental/random/Dictionary.ff +52 -0
  77. package/experimental/random/Example.ff +46 -0
  78. package/experimental/random/Generic.ff +102 -0
  79. package/experimental/random/HappyEyeballs.ff +40 -0
  80. package/experimental/random/HashMap.ff +72 -0
  81. package/experimental/random/IfElseUnit.ff +9 -0
  82. package/experimental/random/InputOutput.ff +23 -0
  83. package/experimental/random/ListVsArray.ff +45 -0
  84. package/experimental/random/Main.ff +44 -0
  85. package/experimental/random/MapTest.ff +67 -0
  86. package/experimental/random/OldTaskSystem.ff +210 -0
  87. package/experimental/random/PatternTest.ff +39 -0
  88. package/experimental/random/Patterns.ff +226 -0
  89. package/experimental/random/ReadBytesTest.ff +10 -0
  90. package/experimental/random/RunLength.ff +65 -0
  91. package/experimental/random/Scrape.ff +51 -0
  92. package/experimental/random/Serialization.ff +217 -0
  93. package/experimental/random/SerializationTest.ff +46 -0
  94. package/experimental/random/Serializer.ff +36 -0
  95. package/experimental/random/StdInOutErr.ff +4 -0
  96. package/experimental/random/Symbols.ff +74 -0
  97. package/experimental/random/Tag.ff +49 -0
  98. package/experimental/random/Tensor.ff +52 -0
  99. package/experimental/random/Try.ff +56 -0
  100. package/experimental/random/Tsv.ff +9 -0
  101. package/experimental/random/TypesAreModules.ff +87 -0
  102. package/experimental/random/blueprints/Blueprint.ff +52 -0
  103. package/experimental/random/blueprints/Main.ff +11 -0
  104. package/experimental/random/blueprints/Pretty.ff +58 -0
  105. package/experimental/random/blueprints/User.ff +64 -0
  106. package/experimental/random/blueprintsystem/BlueprintSystem.ff +48 -0
  107. package/experimental/random/blueprintsystem/Deserialize.ff +53 -0
  108. package/experimental/random/blueprintsystem/ReadJs.ff +13 -0
  109. package/experimental/random/blueprintsystem/User.ff +2 -0
  110. package/experimental/random/kahrs/Kahrs.ff +112 -0
  111. package/experimental/random/kahrs/TestKahrs.ff +22 -0
  112. package/experimental/random/kahrs/TestMap.ff +18 -0
  113. package/experimental/random/streaming/Gzip.ff +3 -0
  114. package/experimental/random/streaming/Main.ff +34 -0
  115. package/experimental/random/streaming/S3Bucket.ff +11 -0
  116. package/experimental/random/streaming/Tar.ff +5 -0
  117. package/experimental/rhymeapp/Main.ff +81 -0
  118. package/experimental/rhymeapp/index.html +14 -0
  119. package/firefly.sh +5 -0
  120. package/fireflysite/Main.ff +13 -0
  121. package/httpserver/.firefly/package.ff +1 -0
  122. package/httpserver/HttpServer.ff +184 -0
  123. package/lsp/.firefly/package.ff +1 -0
  124. package/lsp/CompletionHandler.ff +814 -0
  125. package/lsp/Handler.ff +551 -0
  126. package/lsp/HoverHandler.ff +82 -0
  127. package/lsp/LanguageServer.ff +229 -0
  128. package/lsp/SignatureHelpHandler.ff +55 -0
  129. package/lsp/SymbolHandler.ff +167 -0
  130. package/output/js/ff/compiler/Builder.mjs +483 -0
  131. package/output/js/ff/compiler/Compiler.mjs +410 -0
  132. package/output/js/ff/compiler/Dependencies.mjs +388 -0
  133. package/output/js/ff/compiler/Deriver.mjs +1166 -0
  134. package/output/js/ff/compiler/Dictionaries.mjs +1305 -0
  135. package/output/js/ff/compiler/Environment.mjs +1005 -0
  136. package/output/js/ff/compiler/Inference.mjs +4264 -0
  137. package/output/js/ff/compiler/JsEmitter.mjs +5353 -0
  138. package/output/js/ff/compiler/JsImporter.mjs +262 -0
  139. package/output/js/ff/compiler/LspHook.mjs +789 -0
  140. package/output/js/ff/compiler/Main.mjs +1695 -0
  141. package/output/js/ff/compiler/Parser.mjs +4004 -0
  142. package/output/js/ff/compiler/Patterns.mjs +923 -0
  143. package/output/js/ff/compiler/Resolver.mjs +2303 -0
  144. package/output/js/ff/compiler/Substitution.mjs +1146 -0
  145. package/output/js/ff/compiler/Syntax.mjs +12430 -0
  146. package/output/js/ff/compiler/Token.mjs +3092 -0
  147. package/output/js/ff/compiler/Tokenizer.mjs +589 -0
  148. package/output/js/ff/compiler/Unification.mjs +1748 -0
  149. package/output/js/ff/compiler/Wildcards.mjs +604 -0
  150. package/output/js/ff/compiler/Workspace.mjs +683 -0
  151. package/output/js/ff/core/Any.mjs +139 -0
  152. package/output/js/ff/core/Array.mjs +594 -0
  153. package/output/js/ff/core/AssetSystem.mjs +270 -0
  154. package/output/js/ff/core/Atomic.mjs +186 -0
  155. package/output/js/ff/core/Bool.mjs +141 -0
  156. package/output/js/ff/core/BrowserSystem.mjs +122 -0
  157. package/output/js/ff/core/Buffer.mjs +467 -0
  158. package/output/js/ff/core/BuildSystem.mjs +320 -0
  159. package/output/js/ff/core/Channel.mjs +268 -0
  160. package/output/js/ff/core/Char.mjs +145 -0
  161. package/output/js/ff/core/Core.mjs +300 -0
  162. package/output/js/ff/core/Duration.mjs +112 -0
  163. package/output/js/ff/core/Equal.mjs +175 -0
  164. package/output/js/ff/core/Error.mjs +138 -0
  165. package/output/js/ff/core/FileHandle.mjs +164 -0
  166. package/output/js/ff/core/Float.mjs +214 -0
  167. package/output/js/ff/core/HttpClient.mjs +210 -0
  168. package/output/js/ff/core/Instant.mjs +105 -0
  169. package/output/js/ff/core/Int.mjs +254 -0
  170. package/output/js/ff/core/IntMap.mjs +282 -0
  171. package/output/js/ff/core/JsSystem.mjs +234 -0
  172. package/output/js/ff/core/JsValue.mjs +678 -0
  173. package/output/js/ff/core/List.mjs +2335 -0
  174. package/output/js/ff/core/Lock.mjs +322 -0
  175. package/output/js/ff/core/Log.mjs +159 -0
  176. package/output/js/ff/core/Map.mjs +358 -0
  177. package/output/js/ff/core/NodeSystem.mjs +288 -0
  178. package/output/js/ff/core/Nothing.mjs +100 -0
  179. package/output/js/ff/core/Option.mjs +1002 -0
  180. package/output/js/ff/core/Ordering.mjs +734 -0
  181. package/output/js/ff/core/Pair.mjs +318 -0
  182. package/output/js/ff/core/Path.mjs +768 -0
  183. package/output/js/ff/core/RbMap.mjs +1936 -0
  184. package/output/js/ff/core/Serializable.mjs +434 -0
  185. package/output/js/ff/core/Set.mjs +250 -0
  186. package/output/js/ff/core/Show.mjs +201 -0
  187. package/output/js/ff/core/Stack.mjs +595 -0
  188. package/output/js/ff/core/Stream.mjs +1300 -0
  189. package/output/js/ff/core/String.mjs +433 -0
  190. package/output/js/ff/core/StringMap.mjs +282 -0
  191. package/output/js/ff/core/Task.mjs +345 -0
  192. package/output/js/ff/core/Try.mjs +503 -0
  193. package/output/js/ff/core/Unit.mjs +103 -0
  194. package/package.json +29 -0
  195. package/postgresql/.firefly/include/package-lock.json +250 -0
  196. package/postgresql/.firefly/include/package.json +5 -0
  197. package/postgresql/.firefly/include/prepare.sh +2 -0
  198. package/postgresql/.firefly/package.ff +3 -0
  199. package/postgresql/Pg.ff +530 -0
  200. package/unsafejs/.firefly/package.ff +1 -0
  201. package/unsafejs/UnsafeJs.ff +19 -0
  202. package/vscode/.vscode/launch.json +18 -0
  203. package/vscode/.vscode/tasks.json +33 -0
  204. package/vscode/LICENSE.txt +21 -0
  205. package/vscode/Prepublish.ff +15 -0
  206. package/vscode/README.md +17 -0
  207. package/vscode/client/package-lock.json +544 -0
  208. package/vscode/client/package.json +22 -0
  209. package/vscode/client/src/extension.ts +64 -0
  210. package/vscode/client/tsconfig.json +12 -0
  211. package/vscode/icons/firefly-icon.png +0 -0
  212. package/vscode/icons/firefly-icon.svg +10 -0
  213. package/vscode/icons/firefly-logo-notext.png +0 -0
  214. package/vscode/icons/firefly-logo.png +0 -0
  215. package/vscode/language-configuration.json +39 -0
  216. package/vscode/package-lock.json +3623 -0
  217. package/vscode/package.json +144 -0
  218. package/vscode/snippets-none.json +1 -0
  219. package/vscode/snippets.json +241 -0
  220. package/vscode/syntaxes/firefly.tmLanguage.json +294 -0
  221. package/vscode/tsconfig.json +20 -0
@@ -0,0 +1,1300 @@
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 Stream
88
+ export function Stream(next_, close_) {
89
+ return {next_, close_};
90
+ }
91
+
92
+
93
+
94
+ export function make_(next_, close_ = (() => {
95
+
96
+ })) {
97
+ return ff_core_Stream.Stream(next_, close_)
98
+ }
99
+
100
+ export function init_(body_) {
101
+ let initialized_ = false;
102
+ let stream_ = ff_core_Stream.Stream((() => {
103
+ return ff_core_Option.None()
104
+ }), (() => {
105
+
106
+ }));
107
+ return ff_core_Stream.Stream((() => {
108
+ if(initialized_) {
109
+ return stream_.next_()
110
+ } else {
111
+ initialized_ = true;
112
+ stream_ = body_();
113
+ return stream_.next_()
114
+ }
115
+ }), (() => {
116
+ initialized_ = true;
117
+ stream_.close_()
118
+ }))
119
+ }
120
+
121
+ export async function make_$(next_, close_ = (async ($task) => {
122
+
123
+ }), $task) {
124
+ return ff_core_Stream.Stream(next_, close_)
125
+ }
126
+
127
+ export async function init_$(body_, $task) {
128
+ let initialized_ = false;
129
+ let stream_ = ff_core_Stream.Stream((async ($task) => {
130
+ return ff_core_Option.None()
131
+ }), (async ($task) => {
132
+
133
+ }));
134
+ return ff_core_Stream.Stream((async ($task) => {
135
+ if(initialized_) {
136
+ return (await stream_.next_($task))
137
+ } else {
138
+ initialized_ = true;
139
+ stream_ = (await body_($task));
140
+ return (await stream_.next_($task))
141
+ }
142
+ }), (async ($task) => {
143
+ initialized_ = true;
144
+ (await stream_.close_($task))
145
+ }))
146
+ }
147
+
148
+ export function Stream_addAll(self_, that_) {
149
+ let firstDone_ = false;
150
+ return ff_core_Stream.Stream((() => {
151
+ if(firstDone_) {
152
+ return that_.next_()
153
+ } else {
154
+ return ff_core_Option.Option_orElse(self_.next_(), (() => {
155
+ firstDone_ = true;
156
+ return that_.next_()
157
+ }))
158
+ }
159
+ }), (() => {
160
+ try {
161
+ self_.close_()
162
+ } finally {
163
+ that_.close_()
164
+ }
165
+ }))
166
+ }
167
+
168
+ export function Stream_map(self_, body_) {
169
+ return ff_core_Stream.Stream((() => {
170
+ return ff_core_Option.Option_map(self_.next_(), body_)
171
+ }), (() => {
172
+ self_.close_()
173
+ }))
174
+ }
175
+
176
+ export function Stream_flatMap(self_, body_) {
177
+ let inner_ = ff_core_Stream.Stream((() => {
178
+ return ff_core_Option.None()
179
+ }), (() => {
180
+
181
+ }));
182
+ return ff_core_Stream.Stream((() => {
183
+ let result_ = ff_core_Option.None();
184
+ while(ff_core_Option.Option_isEmpty(result_)) {
185
+ do {
186
+ const _1 = inner_.next_();
187
+ {
188
+ const i_ = _1;
189
+ if(_1.Some) {
190
+ result_ = ff_core_Option.Some(i_)
191
+ break
192
+ }
193
+ }
194
+ {
195
+ if(_1.None) {
196
+ do {
197
+ const _1 = self_.next_();
198
+ {
199
+ if(_1.None) {
200
+ result_ = ff_core_Option.Some(ff_core_Option.None())
201
+ break
202
+ }
203
+ }
204
+ {
205
+ if(_1.Some) {
206
+ const o_ = _1.value_;
207
+ inner_.close_();
208
+ inner_ = body_(o_)
209
+ break
210
+ }
211
+ }
212
+ } while(false)
213
+ break
214
+ }
215
+ }
216
+ } while(false)
217
+ };
218
+ return ff_core_Option.Option_grab(result_)
219
+ }), (() => {
220
+ try {
221
+ inner_.close_()
222
+ } finally {
223
+ self_.close_()
224
+ }
225
+ }))
226
+ }
227
+
228
+ export function Stream_collect(self_, body_) {
229
+ return ff_core_Stream.Stream_flatMap(self_, ((_w1) => {
230
+ return ff_core_Option.Option_toStream(body_(_w1), false)
231
+ }))
232
+ }
233
+
234
+ export function Stream_filter(self_, body_) {
235
+ return ff_core_Stream.Stream((() => {
236
+ let result_ = ff_core_Option.None();
237
+ while(ff_core_Option.Option_isEmpty(result_)) {
238
+ do {
239
+ const _1 = self_.next_();
240
+ {
241
+ if(_1.Some) {
242
+ const x_ = _1.value_;
243
+ const _guard1 = body_(x_);
244
+ if(_guard1) {
245
+ result_ = ff_core_Option.Some(ff_core_Option.Some(x_))
246
+ break
247
+ }
248
+ }
249
+ }
250
+ {
251
+ if(_1.Some) {
252
+
253
+ break
254
+ }
255
+ }
256
+ {
257
+ if(_1.None) {
258
+ result_ = ff_core_Option.Some(ff_core_Option.None())
259
+ break
260
+ }
261
+ }
262
+ } while(false)
263
+ };
264
+ return ff_core_Option.Option_grab(result_)
265
+ }), (() => {
266
+ self_.close_()
267
+ }))
268
+ }
269
+
270
+ export function Stream_zip(self_, that_) {
271
+ return ff_core_Stream.Stream((() => {
272
+ {
273
+ const _1 = ff_core_Pair.Pair(self_.next_(), that_.next_());
274
+ {
275
+ if(_1.first_.Some) {
276
+ const x_ = _1.first_.value_;
277
+ if(_1.second_.Some) {
278
+ const y_ = _1.second_.value_;
279
+ return ff_core_Option.Some(ff_core_Pair.Pair(x_, y_))
280
+ return
281
+ }
282
+ }
283
+ }
284
+ {
285
+ return ff_core_Option.None()
286
+ return
287
+ }
288
+ }
289
+ }), (() => {
290
+ try {
291
+ self_.close_()
292
+ } finally {
293
+ that_.close_()
294
+ }
295
+ }))
296
+ }
297
+
298
+ export function Stream_takeFirst(self_, count_ = 1) {
299
+ let remaining_ = count_;
300
+ return ff_core_Stream.Stream((() => {
301
+ return ff_core_Option.Option_filter(self_.next_(), ((_) => {
302
+ remaining_ -= 1;
303
+ return (remaining_ >= 0)
304
+ }))
305
+ }), (() => {
306
+ self_.close_()
307
+ }))
308
+ }
309
+
310
+ export function Stream_dropFirst(self_, count_ = 1) {
311
+ let remaining_ = count_;
312
+ return ff_core_Stream.Stream((() => {
313
+ while((remaining_ >= 1)) {
314
+ do {
315
+ const _1 = self_.next_();
316
+ {
317
+ if(_1.None) {
318
+ remaining_ = 0
319
+ break
320
+ }
321
+ }
322
+ {
323
+ if(_1.Some) {
324
+ remaining_ -= 1
325
+ break
326
+ }
327
+ }
328
+ } while(false)
329
+ };
330
+ return self_.next_()
331
+ }), (() => {
332
+ self_.close_()
333
+ }))
334
+ }
335
+
336
+ export function Stream_takeWhile(self_, body_) {
337
+ let done_ = false;
338
+ return ff_core_Stream.Stream((() => {
339
+ if(done_) {
340
+ return ff_core_Option.None()
341
+ } else {
342
+ {
343
+ const _1 = self_.next_();
344
+ {
345
+ if(_1.None) {
346
+ done_ = true;
347
+ return ff_core_Option.None()
348
+ return
349
+ }
350
+ }
351
+ {
352
+ const o_ = _1;
353
+ if(_1.Some) {
354
+ const x_ = _1.value_;
355
+ done_ = (!body_(x_));
356
+ if(done_) {
357
+ return ff_core_Option.None()
358
+ } else {
359
+ return o_
360
+ }
361
+ return
362
+ }
363
+ }
364
+ }
365
+ }
366
+ }), (() => {
367
+ self_.close_()
368
+ }))
369
+ }
370
+
371
+ export function Stream_dropWhile(self_, body_) {
372
+ let done_ = false;
373
+ return ff_core_Stream.Stream((() => {
374
+ if((!done_)) {
375
+ let result_ = ff_core_Option.None();
376
+ while((!done_)) {
377
+ do {
378
+ const _1 = self_.next_();
379
+ {
380
+ if(_1.None) {
381
+ done_ = true
382
+ break
383
+ }
384
+ }
385
+ {
386
+ if(_1.Some) {
387
+ const x_ = _1.value_;
388
+ const _guard1 = body_(x_);
389
+ if(_guard1) {
390
+
391
+ break
392
+ }
393
+ }
394
+ }
395
+ {
396
+ const o_ = _1;
397
+ if(_1.Some) {
398
+ const x_ = _1.value_;
399
+ result_ = o_;
400
+ done_ = true
401
+ break
402
+ }
403
+ }
404
+ } while(false)
405
+ };
406
+ return result_
407
+ } else {
408
+ return self_.next_()
409
+ }
410
+ }), (() => {
411
+ self_.close_()
412
+ }))
413
+ }
414
+
415
+ export function Stream_pairs(self_) {
416
+ let i_ = 0;
417
+ return ff_core_Stream.Stream_map(self_, ((x_) => {
418
+ const r_ = ff_core_Pair.Pair(i_, x_);
419
+ i_ += 1;
420
+ return r_
421
+ }))
422
+ }
423
+
424
+ export function Stream_chunked(self_, size_) {
425
+ let remaining_ = size_;
426
+ return ff_core_Stream.Stream((() => {
427
+ if((remaining_ <= 0)) {
428
+ return ff_core_Option.None()
429
+ } else {
430
+ {
431
+ const _1 = self_.next_();
432
+ {
433
+ if(_1.None) {
434
+ remaining_ = (-1);
435
+ return ff_core_Option.None()
436
+ return
437
+ }
438
+ }
439
+ {
440
+ if(_1.Some) {
441
+ const x_ = _1.value_;
442
+ let list_ = ff_core_List.Link(x_, ff_core_List.Empty());
443
+ remaining_ -= 1;
444
+ while((remaining_ > 0)) {
445
+ remaining_ -= 1;
446
+ do {
447
+ const _1 = self_.next_();
448
+ {
449
+ if(_1.None) {
450
+ remaining_ = (-1)
451
+ break
452
+ }
453
+ }
454
+ {
455
+ if(_1.Some) {
456
+ const x_ = _1.value_;
457
+ list_ = ff_core_List.Link(x_, list_)
458
+ break
459
+ }
460
+ }
461
+ } while(false)
462
+ };
463
+ if((remaining_ !== (-1))) {
464
+ remaining_ = size_
465
+ };
466
+ return ff_core_Option.Some(ff_core_List.List_reverse(list_))
467
+ return
468
+ }
469
+ }
470
+ }
471
+ }
472
+ }), (() => {
473
+ self_.close_()
474
+ }))
475
+ }
476
+
477
+ export function Stream_use(self_, body_) {
478
+ try {
479
+ return body_(self_)
480
+ } finally {
481
+ self_.close_()
482
+ }
483
+ }
484
+
485
+ export function Stream_each(self_, body_) {
486
+ try {
487
+ let done_ = false;
488
+ while((!done_)) {
489
+ do {
490
+ const _1 = self_.next_();
491
+ {
492
+ if(_1.None) {
493
+ done_ = true
494
+ break
495
+ }
496
+ }
497
+ {
498
+ if(_1.Some) {
499
+ const x_ = _1.value_;
500
+ body_(x_)
501
+ break
502
+ }
503
+ }
504
+ } while(false)
505
+ }
506
+ } finally {
507
+ self_.close_()
508
+ }
509
+ }
510
+
511
+ export function Stream_eachWhile(self_, body_) {
512
+ try {
513
+ let done_ = false;
514
+ while((!done_)) {
515
+ do {
516
+ const _1 = self_.next_();
517
+ {
518
+ if(_1.None) {
519
+ done_ = true
520
+ break
521
+ }
522
+ }
523
+ {
524
+ if(_1.Some) {
525
+ const x_ = _1.value_;
526
+ done_ = (!body_(x_))
527
+ break
528
+ }
529
+ }
530
+ } while(false)
531
+ }
532
+ } finally {
533
+ self_.close_()
534
+ }
535
+ }
536
+
537
+ export function Stream_all(self_, body_) {
538
+ let result_ = true;
539
+ ff_core_Stream.Stream_eachWhile(self_, ((x_) => {
540
+ result_ = (result_ && body_(x_));
541
+ return result_
542
+ }));
543
+ return result_
544
+ }
545
+
546
+ export function Stream_any(self_, body_) {
547
+ let result_ = false;
548
+ ff_core_Stream.Stream_eachWhile(self_, ((x_) => {
549
+ result_ = (result_ || body_(x_));
550
+ return (!result_)
551
+ }));
552
+ return result_
553
+ }
554
+
555
+ export function Stream_first(self_) {
556
+ try {
557
+ return self_.next_()
558
+ } finally {
559
+ self_.close_()
560
+ }
561
+ }
562
+
563
+ export function Stream_last(self_) {
564
+ try {
565
+ let done_ = false;
566
+ let result_ = ff_core_Option.None();
567
+ while((!done_)) {
568
+ do {
569
+ const _1 = self_.next_();
570
+ {
571
+ if(_1.None) {
572
+ done_ = true
573
+ break
574
+ }
575
+ }
576
+ {
577
+ const o_ = _1;
578
+ if(_1.Some) {
579
+ const x_ = _1.value_;
580
+ result_ = o_
581
+ break
582
+ }
583
+ }
584
+ } while(false)
585
+ };
586
+ return result_
587
+ } finally {
588
+ self_.close_()
589
+ }
590
+ }
591
+
592
+ export function Stream_grabFirst(self_) {
593
+ return ff_core_Option.Option_else(ff_core_Stream.Stream_first(self_), (() => {
594
+ return ff_core_Core.panic_("grabFirst() on empty iterator")
595
+ }))
596
+ }
597
+
598
+ export function Stream_grabLast(self_) {
599
+ return ff_core_Option.Option_else(ff_core_Stream.Stream_last(self_), (() => {
600
+ return ff_core_Core.panic_("grabLast() on empty iterator")
601
+ }))
602
+ }
603
+
604
+ export function Stream_collectFirst(self_, body_) {
605
+ try {
606
+ let done_ = false;
607
+ let result_ = ff_core_Option.None();
608
+ while((!done_)) {
609
+ do {
610
+ const _1 = self_.next_();
611
+ {
612
+ if(_1.None) {
613
+ done_ = true
614
+ break
615
+ }
616
+ }
617
+ {
618
+ if(_1.Some) {
619
+ const x_ = _1.value_;
620
+ do {
621
+ const _1 = body_(x_);
622
+ {
623
+ if(_1.None) {
624
+
625
+ break
626
+ }
627
+ }
628
+ {
629
+ const o_ = _1;
630
+ done_ = true;
631
+ result_ = o_
632
+ break
633
+ }
634
+ } while(false)
635
+ break
636
+ }
637
+ }
638
+ } while(false)
639
+ };
640
+ return result_
641
+ } finally {
642
+ self_.close_()
643
+ }
644
+ }
645
+
646
+ export function Stream_find(self_, body_) {
647
+ return ff_core_Stream.Stream_first(ff_core_Stream.Stream_filter(self_, body_))
648
+ }
649
+
650
+ export function Stream_foldLeft(self_, initial_, body_) {
651
+ let result_ = initial_;
652
+ ff_core_Stream.Stream_each(self_, ((_w1) => {
653
+ result_ = body_(result_, _w1)
654
+ }));
655
+ return result_
656
+ }
657
+
658
+ export function Stream_toStack(self_) {
659
+ const stack_ = ff_core_Stack.make_();
660
+ ff_core_Stream.Stream_each(self_, ((_w1) => {
661
+ ff_core_Stack.Stack_push(stack_, _w1)
662
+ }));
663
+ return stack_
664
+ }
665
+
666
+ export function Stream_toArray(self_) {
667
+ return ff_core_Stack.Stack_drain(ff_core_Stream.Stream_toStack(self_))
668
+ }
669
+
670
+ export function Stream_toList(self_) {
671
+ return ff_core_Stack.Stack_toList(ff_core_Stream.Stream_toStack(self_), 0, 9007199254740991)
672
+ }
673
+
674
+ export async function Stream_addAll$(self_, that_, $task) {
675
+ let firstDone_ = false;
676
+ return ff_core_Stream.Stream((async ($task) => {
677
+ if(firstDone_) {
678
+ return (await that_.next_($task))
679
+ } else {
680
+ return (await ff_core_Option.Option_orElse$((await self_.next_($task)), (async ($task) => {
681
+ firstDone_ = true;
682
+ return (await that_.next_($task))
683
+ }), $task))
684
+ }
685
+ }), (async ($task) => {
686
+ try {
687
+ (await self_.close_($task))
688
+ } finally {
689
+ (await that_.close_($task))
690
+ }
691
+ }))
692
+ }
693
+
694
+ export async function Stream_map$(self_, body_, $task) {
695
+ return ff_core_Stream.Stream((async ($task) => {
696
+ return (await ff_core_Option.Option_map$((await self_.next_($task)), body_, $task))
697
+ }), (async ($task) => {
698
+ (await self_.close_($task))
699
+ }))
700
+ }
701
+
702
+ export async function Stream_flatMap$(self_, body_, $task) {
703
+ let inner_ = ff_core_Stream.Stream((async ($task) => {
704
+ return ff_core_Option.None()
705
+ }), (async ($task) => {
706
+
707
+ }));
708
+ return ff_core_Stream.Stream((async ($task) => {
709
+ let result_ = ff_core_Option.None();
710
+ while(ff_core_Option.Option_isEmpty(result_)) {
711
+ do {
712
+ const _1 = (await inner_.next_($task));
713
+ {
714
+ const i_ = _1;
715
+ if(_1.Some) {
716
+ result_ = ff_core_Option.Some(i_)
717
+ break
718
+ }
719
+ }
720
+ {
721
+ if(_1.None) {
722
+ do {
723
+ const _1 = (await self_.next_($task));
724
+ {
725
+ if(_1.None) {
726
+ result_ = ff_core_Option.Some(ff_core_Option.None())
727
+ break
728
+ }
729
+ }
730
+ {
731
+ if(_1.Some) {
732
+ const o_ = _1.value_;
733
+ (await inner_.close_($task));
734
+ inner_ = (await body_(o_, $task))
735
+ break
736
+ }
737
+ }
738
+ } while(false)
739
+ break
740
+ }
741
+ }
742
+ } while(false)
743
+ };
744
+ return ff_core_Option.Option_grab(result_)
745
+ }), (async ($task) => {
746
+ try {
747
+ (await inner_.close_($task))
748
+ } finally {
749
+ (await self_.close_($task))
750
+ }
751
+ }))
752
+ }
753
+
754
+ export async function Stream_collect$(self_, body_, $task) {
755
+ return (await ff_core_Stream.Stream_flatMap$(self_, (async (_w1, $task) => {
756
+ return (await ff_core_Option.Option_toStream$((await body_(_w1, $task)), false, $task))
757
+ }), $task))
758
+ }
759
+
760
+ export async function Stream_filter$(self_, body_, $task) {
761
+ return ff_core_Stream.Stream((async ($task) => {
762
+ let result_ = ff_core_Option.None();
763
+ while(ff_core_Option.Option_isEmpty(result_)) {
764
+ do {
765
+ const _1 = (await self_.next_($task));
766
+ {
767
+ if(_1.Some) {
768
+ const x_ = _1.value_;
769
+ const _guard1 = (await body_(x_, $task));
770
+ if(_guard1) {
771
+ result_ = ff_core_Option.Some(ff_core_Option.Some(x_))
772
+ break
773
+ }
774
+ }
775
+ }
776
+ {
777
+ if(_1.Some) {
778
+
779
+ break
780
+ }
781
+ }
782
+ {
783
+ if(_1.None) {
784
+ result_ = ff_core_Option.Some(ff_core_Option.None())
785
+ break
786
+ }
787
+ }
788
+ } while(false)
789
+ };
790
+ return ff_core_Option.Option_grab(result_)
791
+ }), (async ($task) => {
792
+ (await self_.close_($task))
793
+ }))
794
+ }
795
+
796
+ export async function Stream_zip$(self_, that_, $task) {
797
+ return ff_core_Stream.Stream((async ($task) => {
798
+ {
799
+ const _1 = ff_core_Pair.Pair((await self_.next_($task)), (await that_.next_($task)));
800
+ {
801
+ if(_1.first_.Some) {
802
+ const x_ = _1.first_.value_;
803
+ if(_1.second_.Some) {
804
+ const y_ = _1.second_.value_;
805
+ return ff_core_Option.Some(ff_core_Pair.Pair(x_, y_))
806
+ return
807
+ }
808
+ }
809
+ }
810
+ {
811
+ return ff_core_Option.None()
812
+ return
813
+ }
814
+ }
815
+ }), (async ($task) => {
816
+ try {
817
+ (await self_.close_($task))
818
+ } finally {
819
+ (await that_.close_($task))
820
+ }
821
+ }))
822
+ }
823
+
824
+ export async function Stream_takeFirst$(self_, count_ = 1, $task) {
825
+ let remaining_ = count_;
826
+ return ff_core_Stream.Stream((async ($task) => {
827
+ return ff_core_Option.Option_filter((await self_.next_($task)), ((_) => {
828
+ remaining_ -= 1;
829
+ return (remaining_ >= 0)
830
+ }))
831
+ }), (async ($task) => {
832
+ (await self_.close_($task))
833
+ }))
834
+ }
835
+
836
+ export async function Stream_dropFirst$(self_, count_ = 1, $task) {
837
+ let remaining_ = count_;
838
+ return ff_core_Stream.Stream((async ($task) => {
839
+ while((remaining_ >= 1)) {
840
+ do {
841
+ const _1 = (await self_.next_($task));
842
+ {
843
+ if(_1.None) {
844
+ remaining_ = 0
845
+ break
846
+ }
847
+ }
848
+ {
849
+ if(_1.Some) {
850
+ remaining_ -= 1
851
+ break
852
+ }
853
+ }
854
+ } while(false)
855
+ };
856
+ return (await self_.next_($task))
857
+ }), (async ($task) => {
858
+ (await self_.close_($task))
859
+ }))
860
+ }
861
+
862
+ export async function Stream_takeWhile$(self_, body_, $task) {
863
+ let done_ = false;
864
+ return ff_core_Stream.Stream((async ($task) => {
865
+ if(done_) {
866
+ return ff_core_Option.None()
867
+ } else {
868
+ {
869
+ const _1 = (await self_.next_($task));
870
+ {
871
+ if(_1.None) {
872
+ done_ = true;
873
+ return ff_core_Option.None()
874
+ return
875
+ }
876
+ }
877
+ {
878
+ const o_ = _1;
879
+ if(_1.Some) {
880
+ const x_ = _1.value_;
881
+ done_ = (!(await body_(x_, $task)));
882
+ if(done_) {
883
+ return ff_core_Option.None()
884
+ } else {
885
+ return o_
886
+ }
887
+ return
888
+ }
889
+ }
890
+ }
891
+ }
892
+ }), (async ($task) => {
893
+ (await self_.close_($task))
894
+ }))
895
+ }
896
+
897
+ export async function Stream_dropWhile$(self_, body_, $task) {
898
+ let done_ = false;
899
+ return ff_core_Stream.Stream((async ($task) => {
900
+ if((!done_)) {
901
+ let result_ = ff_core_Option.None();
902
+ while((!done_)) {
903
+ do {
904
+ const _1 = (await self_.next_($task));
905
+ {
906
+ if(_1.None) {
907
+ done_ = true
908
+ break
909
+ }
910
+ }
911
+ {
912
+ if(_1.Some) {
913
+ const x_ = _1.value_;
914
+ const _guard1 = (await body_(x_, $task));
915
+ if(_guard1) {
916
+
917
+ break
918
+ }
919
+ }
920
+ }
921
+ {
922
+ const o_ = _1;
923
+ if(_1.Some) {
924
+ const x_ = _1.value_;
925
+ result_ = o_;
926
+ done_ = true
927
+ break
928
+ }
929
+ }
930
+ } while(false)
931
+ };
932
+ return result_
933
+ } else {
934
+ return (await self_.next_($task))
935
+ }
936
+ }), (async ($task) => {
937
+ (await self_.close_($task))
938
+ }))
939
+ }
940
+
941
+ export async function Stream_pairs$(self_, $task) {
942
+ let i_ = 0;
943
+ return (await ff_core_Stream.Stream_map$(self_, (async (x_, $task) => {
944
+ const r_ = ff_core_Pair.Pair(i_, x_);
945
+ i_ += 1;
946
+ return r_
947
+ }), $task))
948
+ }
949
+
950
+ export async function Stream_chunked$(self_, size_, $task) {
951
+ let remaining_ = size_;
952
+ return ff_core_Stream.Stream((async ($task) => {
953
+ if((remaining_ <= 0)) {
954
+ return ff_core_Option.None()
955
+ } else {
956
+ {
957
+ const _1 = (await self_.next_($task));
958
+ {
959
+ if(_1.None) {
960
+ remaining_ = (-1);
961
+ return ff_core_Option.None()
962
+ return
963
+ }
964
+ }
965
+ {
966
+ if(_1.Some) {
967
+ const x_ = _1.value_;
968
+ let list_ = ff_core_List.Link(x_, ff_core_List.Empty());
969
+ remaining_ -= 1;
970
+ while((remaining_ > 0)) {
971
+ remaining_ -= 1;
972
+ do {
973
+ const _1 = (await self_.next_($task));
974
+ {
975
+ if(_1.None) {
976
+ remaining_ = (-1)
977
+ break
978
+ }
979
+ }
980
+ {
981
+ if(_1.Some) {
982
+ const x_ = _1.value_;
983
+ list_ = ff_core_List.Link(x_, list_)
984
+ break
985
+ }
986
+ }
987
+ } while(false)
988
+ };
989
+ if((remaining_ !== (-1))) {
990
+ remaining_ = size_
991
+ };
992
+ return ff_core_Option.Some(ff_core_List.List_reverse(list_))
993
+ return
994
+ }
995
+ }
996
+ }
997
+ }
998
+ }), (async ($task) => {
999
+ (await self_.close_($task))
1000
+ }))
1001
+ }
1002
+
1003
+ export async function Stream_use$(self_, body_, $task) {
1004
+ try {
1005
+ return (await body_(self_, $task))
1006
+ } finally {
1007
+ (await self_.close_($task))
1008
+ }
1009
+ }
1010
+
1011
+ export async function Stream_each$(self_, body_, $task) {
1012
+ try {
1013
+ let done_ = false;
1014
+ while((!done_)) {
1015
+ do {
1016
+ const _1 = (await self_.next_($task));
1017
+ {
1018
+ if(_1.None) {
1019
+ done_ = true
1020
+ break
1021
+ }
1022
+ }
1023
+ {
1024
+ if(_1.Some) {
1025
+ const x_ = _1.value_;
1026
+ (await body_(x_, $task))
1027
+ break
1028
+ }
1029
+ }
1030
+ } while(false)
1031
+ }
1032
+ } finally {
1033
+ (await self_.close_($task))
1034
+ }
1035
+ }
1036
+
1037
+ export async function Stream_eachWhile$(self_, body_, $task) {
1038
+ try {
1039
+ let done_ = false;
1040
+ while((!done_)) {
1041
+ do {
1042
+ const _1 = (await self_.next_($task));
1043
+ {
1044
+ if(_1.None) {
1045
+ done_ = true
1046
+ break
1047
+ }
1048
+ }
1049
+ {
1050
+ if(_1.Some) {
1051
+ const x_ = _1.value_;
1052
+ done_ = (!(await body_(x_, $task)))
1053
+ break
1054
+ }
1055
+ }
1056
+ } while(false)
1057
+ }
1058
+ } finally {
1059
+ (await self_.close_($task))
1060
+ }
1061
+ }
1062
+
1063
+ export async function Stream_all$(self_, body_, $task) {
1064
+ let result_ = true;
1065
+ (await ff_core_Stream.Stream_eachWhile$(self_, (async (x_, $task) => {
1066
+ result_ = (result_ && (await body_(x_, $task)));
1067
+ return result_
1068
+ }), $task));
1069
+ return result_
1070
+ }
1071
+
1072
+ export async function Stream_any$(self_, body_, $task) {
1073
+ let result_ = false;
1074
+ (await ff_core_Stream.Stream_eachWhile$(self_, (async (x_, $task) => {
1075
+ result_ = (result_ || (await body_(x_, $task)));
1076
+ return (!result_)
1077
+ }), $task));
1078
+ return result_
1079
+ }
1080
+
1081
+ export async function Stream_first$(self_, $task) {
1082
+ try {
1083
+ return (await self_.next_($task))
1084
+ } finally {
1085
+ (await self_.close_($task))
1086
+ }
1087
+ }
1088
+
1089
+ export async function Stream_last$(self_, $task) {
1090
+ try {
1091
+ let done_ = false;
1092
+ let result_ = ff_core_Option.None();
1093
+ while((!done_)) {
1094
+ do {
1095
+ const _1 = (await self_.next_($task));
1096
+ {
1097
+ if(_1.None) {
1098
+ done_ = true
1099
+ break
1100
+ }
1101
+ }
1102
+ {
1103
+ const o_ = _1;
1104
+ if(_1.Some) {
1105
+ const x_ = _1.value_;
1106
+ result_ = o_
1107
+ break
1108
+ }
1109
+ }
1110
+ } while(false)
1111
+ };
1112
+ return result_
1113
+ } finally {
1114
+ (await self_.close_($task))
1115
+ }
1116
+ }
1117
+
1118
+ export async function Stream_grabFirst$(self_, $task) {
1119
+ return ff_core_Option.Option_else((await ff_core_Stream.Stream_first$(self_, $task)), (() => {
1120
+ return ff_core_Core.panic_("grabFirst() on empty iterator")
1121
+ }))
1122
+ }
1123
+
1124
+ export async function Stream_grabLast$(self_, $task) {
1125
+ return ff_core_Option.Option_else((await ff_core_Stream.Stream_last$(self_, $task)), (() => {
1126
+ return ff_core_Core.panic_("grabLast() on empty iterator")
1127
+ }))
1128
+ }
1129
+
1130
+ export async function Stream_collectFirst$(self_, body_, $task) {
1131
+ try {
1132
+ let done_ = false;
1133
+ let result_ = ff_core_Option.None();
1134
+ while((!done_)) {
1135
+ do {
1136
+ const _1 = (await self_.next_($task));
1137
+ {
1138
+ if(_1.None) {
1139
+ done_ = true
1140
+ break
1141
+ }
1142
+ }
1143
+ {
1144
+ if(_1.Some) {
1145
+ const x_ = _1.value_;
1146
+ do {
1147
+ const _1 = (await body_(x_, $task));
1148
+ {
1149
+ if(_1.None) {
1150
+
1151
+ break
1152
+ }
1153
+ }
1154
+ {
1155
+ const o_ = _1;
1156
+ done_ = true;
1157
+ result_ = o_
1158
+ break
1159
+ }
1160
+ } while(false)
1161
+ break
1162
+ }
1163
+ }
1164
+ } while(false)
1165
+ };
1166
+ return result_
1167
+ } finally {
1168
+ (await self_.close_($task))
1169
+ }
1170
+ }
1171
+
1172
+ export async function Stream_find$(self_, body_, $task) {
1173
+ return (await ff_core_Stream.Stream_first$((await ff_core_Stream.Stream_filter$(self_, body_, $task)), $task))
1174
+ }
1175
+
1176
+ export async function Stream_foldLeft$(self_, initial_, body_, $task) {
1177
+ let result_ = initial_;
1178
+ (await ff_core_Stream.Stream_each$(self_, (async (_w1, $task) => {
1179
+ result_ = (await body_(result_, _w1, $task))
1180
+ }), $task));
1181
+ return result_
1182
+ }
1183
+
1184
+ export async function Stream_toStack$(self_, $task) {
1185
+ const stack_ = ff_core_Stack.make_();
1186
+ (await ff_core_Stream.Stream_each$(self_, (async (_w1, $task) => {
1187
+ ff_core_Stack.Stack_push(stack_, _w1)
1188
+ }), $task));
1189
+ return stack_
1190
+ }
1191
+
1192
+ export async function Stream_toArray$(self_, $task) {
1193
+ return ff_core_Stack.Stack_drain((await ff_core_Stream.Stream_toStack$(self_, $task)))
1194
+ }
1195
+
1196
+ export async function Stream_toList$(self_, $task) {
1197
+ return ff_core_Stack.Stack_toList((await ff_core_Stream.Stream_toStack$(self_, $task)), 0, 9007199254740991)
1198
+ }
1199
+
1200
+ export function Stream_flatten(self_) {
1201
+ return ff_core_Stream.Stream_flatMap(self_, ((_w1) => {
1202
+ return _w1
1203
+ }))
1204
+ }
1205
+
1206
+ export async function Stream_flatten$(self_, $task) {
1207
+ return (await ff_core_Stream.Stream_flatMap$(self_, (async (_w1, $task) => {
1208
+ return _w1
1209
+ }), $task))
1210
+ }
1211
+
1212
+ export function Stream_toSet(self_, ff_core_Ordering_Order$T) {
1213
+ return ff_core_Array.Array_toSet(ff_core_Stream.Stream_toArray(self_), ff_core_Ordering_Order$T)
1214
+ }
1215
+
1216
+ export async function Stream_toSet$(self_, ff_core_Ordering_Order$T, $task) {
1217
+ return ff_core_Array.Array_toSet((await ff_core_Stream.Stream_toArray$(self_, $task)), ff_core_Ordering_Order$T)
1218
+ }
1219
+
1220
+ export function Stream_toMap(self_, ff_core_Ordering_Order$K) {
1221
+ return ff_core_Array.Array_toMap(ff_core_Stream.Stream_toArray(self_), ff_core_Ordering_Order$K)
1222
+ }
1223
+
1224
+ export async function Stream_toMap$(self_, ff_core_Ordering_Order$K, $task) {
1225
+ return ff_core_Array.Array_toMap((await ff_core_Stream.Stream_toArray$(self_, $task)), ff_core_Ordering_Order$K)
1226
+ }
1227
+
1228
+ export function Stream_toBuffer(self_) {
1229
+ const builder_ = ff_core_Stack.make_();
1230
+ ff_core_Stream.Stream_each(self_, ((_w1) => {
1231
+ ff_core_Stack.Stack_push(builder_, _w1)
1232
+ }));
1233
+ return ff_core_Buffer.fromBufferArray_(ff_core_Stack.Stack_drain(builder_))
1234
+ }
1235
+
1236
+ export function Stream_toString(self_, encoding_ = "utf8") {
1237
+ return ff_core_Buffer.Buffer_toString(ff_core_Stream.Stream_toBuffer(self_), encoding_)
1238
+ }
1239
+
1240
+ export function Stream_readBytes(self_, bytes_) {
1241
+ if((bytes_ <= 0)) {
1242
+ return ff_core_Pair.Pair(ff_core_List.List_toArray(ff_core_List.Empty()), self_)
1243
+ } else {
1244
+ const buffers_ = ff_core_Stack.make_();
1245
+ let buffer_ = ff_core_Option.Option_grab(self_.next_());
1246
+ let taken_ = 0;
1247
+ let remainder_ = ff_core_Option.None();
1248
+ while(ff_core_Option.ff_core_Equal_Equal$ff_core_Option_Option(ff_core_Buffer.ff_core_Equal_Equal$ff_core_Buffer_Buffer).equals_(remainder_, ff_core_Option.None())) {
1249
+ const needed_ = (bytes_ - taken_);
1250
+ if((needed_ > ff_core_Buffer.Buffer_size(buffer_))) {
1251
+ ff_core_Stack.Stack_push(buffers_, buffer_);
1252
+ taken_ += ff_core_Buffer.Buffer_size(buffer_);
1253
+ buffer_ = ff_core_Option.Option_grab(self_.next_())
1254
+ } else {
1255
+ ff_core_Stack.Stack_push(buffers_, ff_core_Buffer.Buffer_view(buffer_, 0, needed_));
1256
+ remainder_ = ff_core_Option.Some(ff_core_Buffer.Buffer_view(buffer_, needed_, ff_core_Buffer.Buffer_size(buffer_)))
1257
+ }
1258
+ };
1259
+ return ff_core_Pair.Pair(ff_core_Stack.Stack_drain(buffers_), ff_core_Stream.Stream_addAll(ff_core_Option.Option_toStream(remainder_, false), self_))
1260
+ }
1261
+ }
1262
+
1263
+ export async function Stream_toBuffer$(self_, $task) {
1264
+ const builder_ = ff_core_Stack.make_();
1265
+ (await ff_core_Stream.Stream_each$(self_, (async (_w1, $task) => {
1266
+ ff_core_Stack.Stack_push(builder_, _w1)
1267
+ }), $task));
1268
+ return ff_core_Buffer.fromBufferArray_(ff_core_Stack.Stack_drain(builder_))
1269
+ }
1270
+
1271
+ export async function Stream_toString$(self_, encoding_ = "utf8", $task) {
1272
+ return ff_core_Buffer.Buffer_toString((await ff_core_Stream.Stream_toBuffer$(self_, $task)), encoding_)
1273
+ }
1274
+
1275
+ export async function Stream_readBytes$(self_, bytes_, $task) {
1276
+ if((bytes_ <= 0)) {
1277
+ return ff_core_Pair.Pair(ff_core_List.List_toArray(ff_core_List.Empty()), self_)
1278
+ } else {
1279
+ const buffers_ = ff_core_Stack.make_();
1280
+ let buffer_ = ff_core_Option.Option_grab((await self_.next_($task)));
1281
+ let taken_ = 0;
1282
+ let remainder_ = ff_core_Option.None();
1283
+ while(ff_core_Option.ff_core_Equal_Equal$ff_core_Option_Option(ff_core_Buffer.ff_core_Equal_Equal$ff_core_Buffer_Buffer).equals_(remainder_, ff_core_Option.None())) {
1284
+ const needed_ = (bytes_ - taken_);
1285
+ if((needed_ > ff_core_Buffer.Buffer_size(buffer_))) {
1286
+ ff_core_Stack.Stack_push(buffers_, buffer_);
1287
+ taken_ += ff_core_Buffer.Buffer_size(buffer_);
1288
+ buffer_ = ff_core_Option.Option_grab((await self_.next_($task)))
1289
+ } else {
1290
+ ff_core_Stack.Stack_push(buffers_, ff_core_Buffer.Buffer_view(buffer_, 0, needed_));
1291
+ remainder_ = ff_core_Option.Some(ff_core_Buffer.Buffer_view(buffer_, needed_, ff_core_Buffer.Buffer_size(buffer_)))
1292
+ }
1293
+ };
1294
+ return ff_core_Pair.Pair(ff_core_Stack.Stack_drain(buffers_), (await ff_core_Stream.Stream_addAll$((await ff_core_Option.Option_toStream$(remainder_, false, $task)), self_, $task)))
1295
+ }
1296
+ }
1297
+
1298
+
1299
+
1300
+