@glutinum/cli 0.14.0 → 1.0.0-beta.1
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/dist/Glutinum.Converter/FsharpAST.js +38 -4
- package/dist/Glutinum.Converter/Generate.js +15 -7
- package/dist/Glutinum.Converter/GlueAST.js +45 -36
- package/dist/Glutinum.Converter/Hosting.js +918 -0
- package/dist/Glutinum.Converter/Merge.js +218 -82
- package/dist/Glutinum.Converter/Packages.js +44 -8
- package/dist/Glutinum.Converter/Printer.js +77 -49
- package/dist/Glutinum.Converter/Read.js +8 -8
- package/dist/Glutinum.Converter/Reader/ClassDeclaration.js +7 -7
- package/dist/Glutinum.Converter/Reader/Declaration.js +26 -26
- package/dist/Glutinum.Converter/Reader/Documentation.js +37 -36
- package/dist/Glutinum.Converter/Reader/ExportAssignment.js +5 -5
- package/dist/Glutinum.Converter/Reader/ExportDeclaration.js +31 -19
- package/dist/Glutinum.Converter/Reader/FunctionDeclaration.js +6 -7
- package/dist/Glutinum.Converter/Reader/IndexedAccessType.js +36 -29
- package/dist/Glutinum.Converter/Reader/InterfaceDeclaration.js +3 -3
- package/dist/Glutinum.Converter/Reader/MappedTypeNode.js +82 -4
- package/dist/Glutinum.Converter/Reader/ModuleDeclaration.js +3 -3
- package/dist/Glutinum.Converter/Reader/Node.js +20 -20
- package/dist/Glutinum.Converter/Reader/Parameters.js +7 -7
- package/dist/Glutinum.Converter/Reader/TypeAliasDeclaration.js +5 -5
- package/dist/Glutinum.Converter/Reader/TypeNode.js +291 -232
- package/dist/Glutinum.Converter/Reader/TypeOperatorNode.js +8 -8
- package/dist/Glutinum.Converter/Reader/TypeQueryNode.js +108 -40
- package/dist/Glutinum.Converter/Reader/TypeScriptReader.js +2 -2
- package/dist/Glutinum.Converter/Reader/Types.js +6 -6
- package/dist/Glutinum.Converter/Reader/UnionTypeNode.js +7 -6
- package/dist/Glutinum.Converter/Reader/Utils.js +106 -56
- package/dist/Glutinum.Converter/Transform.js +2057 -700
- package/dist/Glutinum.Converter/TypeScript.Extensions.js +194 -202
- package/dist/Glutinum.Converter/Utils/Naming.js +7 -0
- package/dist/Glutinum.Converter/Utils/String.js +2 -2
- package/dist/Program.js +38 -26
- package/dist/fable_modules/Fable.Promise.3.2.1/AsyncIterable.fs +89 -0
- package/dist/fable_modules/Fable.Promise.3.2.1/AsyncIterable.fs.js +105 -0
- package/dist/fable_modules/Fable.Promise.3.2.1/Fable.Promise.fableproj +25 -0
- package/dist/fable_modules/Fable.Promise.3.2.1/Promise.fs +842 -0
- package/dist/fable_modules/Fable.Promise.3.2.1/Promise.fs.js +232 -0
- package/dist/fable_modules/Fable.Promise.3.2.1/PromiseImpl.fs +31 -0
- package/dist/fable_modules/Fable.Promise.3.2.1/PromiseImpl.fs.js +20 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Array.fs +235 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Array.fs.js +384 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AssemblyInfo.fs +19 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Async.fs +287 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Async.fs.js +128 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncOption.fs +127 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncOptionCE.fs +174 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncOptionCE.fs.js +37 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncOptionOp.fs +24 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncResult.fs +483 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncResultCE.fs +201 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncResultCE.fs.js +18 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncResultOp.fs +24 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncResultOption.fs +87 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncResultOption.fs.js +26 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncResultOptionCE.fs +236 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncResultOptionCE.fs.js +18 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncResultOptionOp.fs +24 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncValidation.fs +185 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncValidationCE.fs +186 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncValidationCE.fs.js +18 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncValidationOp.fs +35 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/FsToolkit.ErrorHandling.fableproj +69 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/List.fs +276 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/List.fs.js +364 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Nullness.fs +81 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Option.fs +462 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/OptionCE.fs +139 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/OptionCE.fs.js +48 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/OptionOp.fs +21 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ParallelAsyncResult.fs +88 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ParallelAsyncResult.fs.js +30 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ParallelAsyncResultCE.fs +200 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ParallelAsyncResultCE.fs.js +18 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ParallelAsyncValidation.fs +34 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ParallelAsyncValidationCE.fs +244 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ParallelAsyncValidationCE.fs.js +18 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Result.fs +731 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Result.fs.js +45 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ResultCE.fs +140 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ResultCE.fs.js +23 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ResultOp.fs +45 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ResultOption.fs +201 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ResultOption.fs.js +65 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ResultOptionCE.fs +135 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ResultOptionCE.fs.js +18 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ResultOptionOp.fs +57 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Seq.fs +503 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Seq.fs.js +295 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Validation.fs +167 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ValidationCE.fs +142 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ValidationCE.fs.js +18 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ValidationOp.fs +35 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ValueOption.fs +148 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ValueTaskValueOption.fs +102 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ValueTaskValueOptionCE.fs +587 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ValueTaskValueOptionOp.fs +10 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/obj/Debug/netstandard2.1/.NETStandard,Version=v2.1.AssemblyAttributes.fs +3 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/obj/Debug/netstandard2.1/FsToolkit.ErrorHandling.AssemblyInfo.fs +20 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/obj/Release/net9.0/.NETCoreApp,Version=v9.0.AssemblyAttributes.fs +3 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/obj/Release/net9.0/FsToolkit.ErrorHandling.AssemblyInfo.fs +20 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/obj/Release/netstandard2.0/.NETStandard,Version=v2.0.AssemblyAttributes.fs +3 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/obj/Release/netstandard2.0/FsToolkit.ErrorHandling.AssemblyInfo.fs +20 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/obj/Release/netstandard2.1/.NETStandard,Version=v2.1.AssemblyAttributes.fs +3 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/obj/Release/netstandard2.1/FsToolkit.ErrorHandling.AssemblyInfo.fs +20 -0
- package/dist/fable_modules/fable-library-js.5.17.2/Array.js +1348 -0
- package/dist/fable_modules/fable-library-js.5.17.2/Async.js +163 -0
- package/dist/fable_modules/fable-library-js.5.17.2/AsyncBuilder.js +204 -0
- package/dist/fable_modules/fable-library-js.5.17.2/BigInt.js +307 -0
- package/dist/fable_modules/fable-library-js.5.17.2/BitConverter.js +138 -0
- package/dist/fable_modules/fable-library-js.5.17.2/Boolean.js +22 -0
- package/dist/fable_modules/fable-library-js.5.17.2/CHANGELOG.md +348 -0
- package/dist/fable_modules/fable-library-js.5.17.2/Char.js +202 -0
- package/dist/fable_modules/fable-library-js.5.17.2/Choice.js +184 -0
- package/dist/fable_modules/fable-library-js.5.17.2/CollectionUtil.js +182 -0
- package/dist/fable_modules/fable-library-js.5.17.2/ConditionalWeakTable.js +21 -0
- package/dist/fable_modules/fable-library-js.5.17.2/Date.js +834 -0
- package/dist/fable_modules/fable-library-js.5.17.2/DateOffset.js +252 -0
- package/dist/fable_modules/fable-library-js.5.17.2/DateOnly.js +124 -0
- package/dist/fable_modules/fable-library-js.5.17.2/DateOnlyTemporal.js +146 -0
- package/dist/fable_modules/fable-library-js.5.17.2/DateTimeFormat.js +523 -0
- package/dist/fable_modules/fable-library-js.5.17.2/DateTimeOffsetTemporal.js +283 -0
- package/dist/fable_modules/fable-library-js.5.17.2/DateTimeTemporal.js +243 -0
- package/dist/fable_modules/fable-library-js.5.17.2/Decimal.js +238 -0
- package/dist/fable_modules/fable-library-js.5.17.2/Directory.js +11 -0
- package/dist/fable_modules/fable-library-js.5.17.2/Double.js +53 -0
- package/dist/fable_modules/fable-library-js.5.17.2/Encoding.js +185 -0
- package/dist/fable_modules/fable-library-js.5.17.2/Environment.js +3 -0
- package/dist/fable_modules/fable-library-js.5.17.2/Event.js +102 -0
- package/dist/fable_modules/fable-library-js.5.17.2/FSharp.Collections.js +45 -0
- package/dist/fable_modules/fable-library-js.5.17.2/FSharp.Core.CompilerServices.js +27 -0
- package/dist/fable_modules/fable-library-js.5.17.2/FSharp.Core.js +156 -0
- package/dist/fable_modules/fable-library-js.5.17.2/File.js +27 -0
- package/dist/fable_modules/fable-library-js.5.17.2/Global.js +29 -0
- package/dist/fable_modules/fable-library-js.5.17.2/Guid.js +163 -0
- package/dist/fable_modules/fable-library-js.5.17.2/Int32.js +135 -0
- package/dist/fable_modules/fable-library-js.5.17.2/List.js +1337 -0
- package/dist/fable_modules/fable-library-js.5.17.2/Long.js +38 -0
- package/dist/fable_modules/fable-library-js.5.17.2/MailboxProcessor.js +100 -0
- package/dist/fable_modules/fable-library-js.5.17.2/Map.js +1400 -0
- package/dist/fable_modules/fable-library-js.5.17.2/MapUtil.js +130 -0
- package/dist/fable_modules/fable-library-js.5.17.2/MutableMap.js +339 -0
- package/dist/fable_modules/fable-library-js.5.17.2/MutableSet.js +233 -0
- package/dist/fable_modules/fable-library-js.5.17.2/Native.js +14 -0
- package/dist/fable_modules/fable-library-js.5.17.2/Numeric.js +112 -0
- package/dist/fable_modules/fable-library-js.5.17.2/Observable.js +115 -0
- package/dist/fable_modules/fable-library-js.5.17.2/Option.js +87 -0
- package/dist/fable_modules/fable-library-js.5.17.2/Path.js +31 -0
- package/dist/fable_modules/fable-library-js.5.17.2/README.md +3 -0
- package/dist/fable_modules/fable-library-js.5.17.2/Random.js +172 -0
- package/dist/fable_modules/fable-library-js.5.17.2/Range.js +45 -0
- package/dist/fable_modules/fable-library-js.5.17.2/Reflection.js +489 -0
- package/dist/fable_modules/fable-library-js.5.17.2/RegExp.js +170 -0
- package/dist/fable_modules/fable-library-js.5.17.2/Result.js +165 -0
- package/dist/fable_modules/fable-library-js.5.17.2/Seq.js +1504 -0
- package/dist/fable_modules/fable-library-js.5.17.2/Seq2.js +111 -0
- package/dist/fable_modules/fable-library-js.5.17.2/Set.js +1829 -0
- package/dist/fable_modules/fable-library-js.5.17.2/String.js +731 -0
- package/dist/fable_modules/fable-library-js.5.17.2/System.Collections.Generic.js +333 -0
- package/dist/fable_modules/fable-library-js.5.17.2/System.Text.js +200 -0
- package/dist/fable_modules/fable-library-js.5.17.2/System.js +289 -0
- package/dist/fable_modules/fable-library-js.5.17.2/Task.js +27 -0
- package/dist/fable_modules/fable-library-js.5.17.2/TaskBuilder.js +72 -0
- package/dist/fable_modules/fable-library-js.5.17.2/TimeOnly.js +122 -0
- package/dist/fable_modules/fable-library-js.5.17.2/TimeOnlyTemporal.js +142 -0
- package/dist/fable_modules/fable-library-js.5.17.2/TimeSpan.js +180 -0
- package/dist/fable_modules/fable-library-js.5.17.2/TimeSpanTemporal.js +259 -0
- package/dist/fable_modules/fable-library-js.5.17.2/Timer.js +67 -0
- package/dist/fable_modules/fable-library-js.5.17.2/Types.js +198 -0
- package/dist/fable_modules/fable-library-js.5.17.2/Unicode.13.0.0.js +4 -0
- package/dist/fable_modules/fable-library-js.5.17.2/Uri.js +165 -0
- package/dist/fable_modules/fable-library-js.5.17.2/Util.js +807 -0
- package/dist/fable_modules/fable-library-js.5.17.2/big.d.ts +338 -0
- package/dist/fable_modules/fable-library-js.5.17.2/lib/big.js +829 -0
- package/dist/fable_modules/fable-library-js.5.17.2/package.json +24 -0
- package/dist/fable_modules/fable-library-js.5.17.2/quotation.js +682 -0
- package/package.json +2 -2
- package/dist/Glutinum.Converter/TypeScript.js +0 -12
- package/src/Glutinum.Converter/js/bootstrap.js +0 -123
- package/src/Glutinum.Converter/js/host.js +0 -144
- package/src/Glutinum.Converter/js/npm.js +0 -137
- package/src/Glutinum.Converter/js/resolve.js +0 -402
|
@@ -0,0 +1,384 @@
|
|
|
1
|
+
|
|
2
|
+
import { append, skip, head, reverse, equalsWith } from "../fable-library-js.5.17.2/Array.js";
|
|
3
|
+
import { defaultOf, equals } from "../fable-library-js.5.17.2/Util.js";
|
|
4
|
+
import { FSharpResult$2 } from "../fable-library-js.5.17.2/Result.js";
|
|
5
|
+
import { singleton } from "../fable-library-js.5.17.2/AsyncBuilder.js";
|
|
6
|
+
import { some, value as value_10 } from "../fable-library-js.5.17.2/Option.js";
|
|
7
|
+
|
|
8
|
+
function traverseResultM$0027(state_mut, f_mut, xs_mut) {
|
|
9
|
+
traverseResultM$0027:
|
|
10
|
+
while (true) {
|
|
11
|
+
const state = state_mut, f = f_mut, xs = xs_mut;
|
|
12
|
+
if (!equalsWith(equals, xs, defaultOf()) && (xs.length === 0)) {
|
|
13
|
+
const input_1 = state;
|
|
14
|
+
if (input_1.tag === 1) {
|
|
15
|
+
return new FSharpResult$2(/* Error */ 1, [input_1.fields[0]]);
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
return new FSharpResult$2(/* Ok */ 0, [reverse(input_1.fields[0])]);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
const arr = xs;
|
|
23
|
+
const x_2 = head(arr);
|
|
24
|
+
const xs_1 = skip(1, arr);
|
|
25
|
+
let res;
|
|
26
|
+
const input_4 = f(x_2);
|
|
27
|
+
if (input_4.tag === 1) {
|
|
28
|
+
res = (new FSharpResult$2(/* Error */ 1, [input_4.fields[0]]));
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
const input_2 = state;
|
|
32
|
+
res = ((input_2.tag === 1) ? (new FSharpResult$2(/* Error */ 1, [input_2.fields[0]])) : (new FSharpResult$2(/* Ok */ 0, [append([input_4.fields[0]], input_2.fields[0])])));
|
|
33
|
+
}
|
|
34
|
+
if (res.tag === 1) {
|
|
35
|
+
return res;
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
state_mut = res;
|
|
39
|
+
f_mut = f;
|
|
40
|
+
xs_mut = xs_1;
|
|
41
|
+
continue traverseResultM$0027;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
break;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function traverseAsyncResultM$0027(state, f, xs) {
|
|
49
|
+
if (!equalsWith(equals, xs, defaultOf()) && (xs.length === 0)) {
|
|
50
|
+
return singleton.Bind(state, (x$0027) => {
|
|
51
|
+
let value;
|
|
52
|
+
const input_2 = x$0027;
|
|
53
|
+
value = ((input_2.tag === 1) ? (new FSharpResult$2(/* Error */ 1, [input_2.fields[0]])) : (new FSharpResult$2(/* Ok */ 0, [reverse(input_2.fields[0])])));
|
|
54
|
+
return singleton.Return(value);
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
const arr = xs;
|
|
59
|
+
const x_2 = head(arr);
|
|
60
|
+
const xs_1 = skip(1, arr);
|
|
61
|
+
return singleton.Delay(() => singleton.Bind(singleton.Delay(() => singleton.Bind(state, (input_1_3) => {
|
|
62
|
+
const input_10 = input_1_3;
|
|
63
|
+
if (input_10.tag === 1) {
|
|
64
|
+
return singleton.Return(new FSharpResult$2(/* Error */ 1, [input_10.fields[0]]));
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
const x_3 = f(x_2);
|
|
68
|
+
return singleton.Bind(x_3, (x$0027_1) => {
|
|
69
|
+
let value_2;
|
|
70
|
+
const input_6 = x$0027_1;
|
|
71
|
+
value_2 = ((input_6.tag === 1) ? (new FSharpResult$2(/* Error */ 1, [input_6.fields[0]])) : (new FSharpResult$2(/* Ok */ 0, [append([input_6.fields[0]], input_10.fields[0])])));
|
|
72
|
+
return singleton.Return(value_2);
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
})), (_arg_2) => {
|
|
76
|
+
const r = _arg_2;
|
|
77
|
+
return (r.tag === 1) ? singleton.Return(r) : singleton.ReturnFrom(traverseAsyncResultM$0027(singleton.Return(r), f, xs_1));
|
|
78
|
+
}));
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export function traverseResultM(f, xs) {
|
|
83
|
+
return traverseResultM$0027(new FSharpResult$2(/* Ok */ 0, [[]]), f, xs);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export function sequenceResultM(xs) {
|
|
87
|
+
return traverseResultM((x) => x, xs);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export function traverseAsyncResultM(f, xs) {
|
|
91
|
+
return traverseAsyncResultM$0027(singleton.Return(new FSharpResult$2(/* Ok */ 0, [[]])), f, xs);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export function sequenceAsyncResultM(xs) {
|
|
95
|
+
return traverseAsyncResultM((x) => x, xs);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function traverseResultA$0027(state_mut, f_mut, xs_mut) {
|
|
99
|
+
traverseResultA$0027:
|
|
100
|
+
while (true) {
|
|
101
|
+
const state = state_mut, f = f_mut, xs = xs_mut;
|
|
102
|
+
if (!equalsWith(equals, xs, defaultOf()) && (xs.length === 0)) {
|
|
103
|
+
const input_1 = state;
|
|
104
|
+
if (input_1.tag === 1) {
|
|
105
|
+
return new FSharpResult$2(/* Error */ 1, [reverse(input_1.fields[0])]);
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
return new FSharpResult$2(/* Ok */ 0, [reverse(input_1.fields[0])]);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
const arr = xs;
|
|
113
|
+
const x_2 = head(arr);
|
|
114
|
+
const xs_1 = skip(1, arr);
|
|
115
|
+
const matchValue = f(x_2);
|
|
116
|
+
const copyOfStruct = state;
|
|
117
|
+
if (copyOfStruct.tag === 1) {
|
|
118
|
+
const copyOfStruct_1 = matchValue;
|
|
119
|
+
if (copyOfStruct_1.tag === 0) {
|
|
120
|
+
state_mut = (new FSharpResult$2(/* Error */ 1, [copyOfStruct.fields[0]]));
|
|
121
|
+
f_mut = f;
|
|
122
|
+
xs_mut = xs_1;
|
|
123
|
+
continue traverseResultA$0027;
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
state_mut = (new FSharpResult$2(/* Error */ 1, [append([copyOfStruct_1.fields[0]], copyOfStruct.fields[0])]));
|
|
127
|
+
f_mut = f;
|
|
128
|
+
xs_mut = xs_1;
|
|
129
|
+
continue traverseResultA$0027;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
const copyOfStruct_2 = matchValue;
|
|
134
|
+
if (copyOfStruct_2.tag === 1) {
|
|
135
|
+
state_mut = (new FSharpResult$2(/* Error */ 1, [[copyOfStruct_2.fields[0]]]));
|
|
136
|
+
f_mut = f;
|
|
137
|
+
xs_mut = xs_1;
|
|
138
|
+
continue traverseResultA$0027;
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
state_mut = (new FSharpResult$2(/* Ok */ 0, [append([copyOfStruct_2.fields[0]], copyOfStruct.fields[0])]));
|
|
142
|
+
f_mut = f;
|
|
143
|
+
xs_mut = xs_1;
|
|
144
|
+
continue traverseResultA$0027;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
break;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
function traverseAsyncResultA$0027(state, f, xs) {
|
|
153
|
+
if (!equalsWith(equals, xs, defaultOf()) && (xs.length === 0)) {
|
|
154
|
+
return singleton.Bind(state, (x$0027) => {
|
|
155
|
+
let value;
|
|
156
|
+
const input_2 = x$0027;
|
|
157
|
+
value = ((input_2.tag === 1) ? (new FSharpResult$2(/* Error */ 1, [reverse(input_2.fields[0])])) : (new FSharpResult$2(/* Ok */ 0, [reverse(input_2.fields[0])])));
|
|
158
|
+
return singleton.Return(value);
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
else {
|
|
162
|
+
const arr = xs;
|
|
163
|
+
const x_2 = head(arr);
|
|
164
|
+
const xs_1 = skip(1, arr);
|
|
165
|
+
return singleton.Delay(() => singleton.Bind(state, (_arg) => singleton.Bind(f(x_2), (_arg_1) => {
|
|
166
|
+
let value_4, value_6, value_1_2;
|
|
167
|
+
const fR = _arg_1;
|
|
168
|
+
const copyOfStruct = _arg;
|
|
169
|
+
if (copyOfStruct.tag === 1) {
|
|
170
|
+
const copyOfStruct_1 = fR;
|
|
171
|
+
return (copyOfStruct_1.tag === 0) ? singleton.ReturnFrom(traverseAsyncResultA$0027(singleton.Return(new FSharpResult$2(/* Error */ 1, [copyOfStruct.fields[0]])), f, xs_1)) : singleton.ReturnFrom(traverseAsyncResultA$0027((value_4 = (new FSharpResult$2(/* Error */ 1, [append([copyOfStruct_1.fields[0]], copyOfStruct.fields[0])])), singleton.Return(value_4)), f, xs_1));
|
|
172
|
+
}
|
|
173
|
+
else {
|
|
174
|
+
const copyOfStruct_2 = fR;
|
|
175
|
+
return (copyOfStruct_2.tag === 1) ? singleton.ReturnFrom(traverseAsyncResultA$0027((value_6 = (new FSharpResult$2(/* Error */ 1, [[copyOfStruct_2.fields[0]]])), singleton.Return(value_6)), f, xs_1)) : singleton.ReturnFrom(traverseAsyncResultA$0027((value_1_2 = (new FSharpResult$2(/* Ok */ 0, [append([copyOfStruct_2.fields[0]], copyOfStruct.fields[0])])), singleton.Return(value_1_2)), f, xs_1));
|
|
176
|
+
}
|
|
177
|
+
})));
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
export function traverseResultA(f, xs) {
|
|
182
|
+
return traverseResultA$0027(new FSharpResult$2(/* Ok */ 0, [[]]), f, xs);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
export function sequenceResultA(xs) {
|
|
186
|
+
return traverseResultA((x) => x, xs);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
function traverseValidationA$0027(state_mut, f_mut, xs_mut) {
|
|
190
|
+
traverseValidationA$0027:
|
|
191
|
+
while (true) {
|
|
192
|
+
const state = state_mut, f = f_mut, xs = xs_mut;
|
|
193
|
+
if (!equalsWith(equals, xs, defaultOf()) && (xs.length === 0)) {
|
|
194
|
+
const input_1 = state;
|
|
195
|
+
if (input_1.tag === 1) {
|
|
196
|
+
return new FSharpResult$2(/* Error */ 1, [reverse(input_1.fields[0])]);
|
|
197
|
+
}
|
|
198
|
+
else {
|
|
199
|
+
return new FSharpResult$2(/* Ok */ 0, [reverse(input_1.fields[0])]);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
else {
|
|
203
|
+
const arr = xs;
|
|
204
|
+
const x_2 = head(arr);
|
|
205
|
+
const xs_1 = skip(1, arr);
|
|
206
|
+
const fR = f(x_2);
|
|
207
|
+
let matchResult, y_1, ys, errs1, errs2, errs_1;
|
|
208
|
+
const copyOfStruct = state;
|
|
209
|
+
if (copyOfStruct.tag === 1) {
|
|
210
|
+
const copyOfStruct_1 = fR;
|
|
211
|
+
if (copyOfStruct_1.tag === 0) {
|
|
212
|
+
matchResult = 2;
|
|
213
|
+
errs_1 = copyOfStruct.fields[0];
|
|
214
|
+
}
|
|
215
|
+
else {
|
|
216
|
+
matchResult = 1;
|
|
217
|
+
errs1 = copyOfStruct.fields[0];
|
|
218
|
+
errs2 = copyOfStruct_1.fields[0];
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
else {
|
|
222
|
+
const copyOfStruct_2 = fR;
|
|
223
|
+
if (copyOfStruct_2.tag === 1) {
|
|
224
|
+
matchResult = 2;
|
|
225
|
+
errs_1 = copyOfStruct_2.fields[0];
|
|
226
|
+
}
|
|
227
|
+
else {
|
|
228
|
+
matchResult = 0;
|
|
229
|
+
y_1 = copyOfStruct_2.fields[0];
|
|
230
|
+
ys = copyOfStruct.fields[0];
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
switch (matchResult) {
|
|
234
|
+
case 0: {
|
|
235
|
+
state_mut = (new FSharpResult$2(/* Ok */ 0, [append([y_1], ys)]));
|
|
236
|
+
f_mut = f;
|
|
237
|
+
xs_mut = xs_1;
|
|
238
|
+
continue traverseValidationA$0027;
|
|
239
|
+
}
|
|
240
|
+
case 1: {
|
|
241
|
+
state_mut = (new FSharpResult$2(/* Error */ 1, [append(errs2, errs1)]));
|
|
242
|
+
f_mut = f;
|
|
243
|
+
xs_mut = xs_1;
|
|
244
|
+
continue traverseValidationA$0027;
|
|
245
|
+
}
|
|
246
|
+
default: {
|
|
247
|
+
state_mut = (new FSharpResult$2(/* Error */ 1, [errs_1]));
|
|
248
|
+
f_mut = f;
|
|
249
|
+
xs_mut = xs_1;
|
|
250
|
+
continue traverseValidationA$0027;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
break;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
export function traverseValidationA(f, xs) {
|
|
259
|
+
return traverseValidationA$0027(new FSharpResult$2(/* Ok */ 0, [[]]), f, xs);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
export function sequenceValidationA(xs) {
|
|
263
|
+
return traverseValidationA((x) => x, xs);
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
export function traverseAsyncResultA(f, xs) {
|
|
267
|
+
return traverseAsyncResultA$0027(singleton.Return(new FSharpResult$2(/* Ok */ 0, [[]])), f, xs);
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
export function sequenceAsyncResultA(xs) {
|
|
271
|
+
return traverseAsyncResultA((x) => x, xs);
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
function traverseOptionM$0027(state_mut, f_mut, xs_mut) {
|
|
275
|
+
traverseOptionM$0027:
|
|
276
|
+
while (true) {
|
|
277
|
+
const state = state_mut, f = f_mut, xs = xs_mut;
|
|
278
|
+
if (!equalsWith(equals, xs, defaultOf()) && (xs.length === 0)) {
|
|
279
|
+
const input_1 = state;
|
|
280
|
+
if (input_1 == null) {
|
|
281
|
+
return undefined;
|
|
282
|
+
}
|
|
283
|
+
else {
|
|
284
|
+
return reverse(input_1);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
else {
|
|
288
|
+
const arr = xs;
|
|
289
|
+
const x_1 = head(arr);
|
|
290
|
+
const xs_1 = skip(1, arr);
|
|
291
|
+
let r;
|
|
292
|
+
let matchValue;
|
|
293
|
+
let x_5;
|
|
294
|
+
const opt = f(x_1);
|
|
295
|
+
x_5 = ((opt == null) ? undefined : some(value_10(opt)));
|
|
296
|
+
if (x_5 == null) {
|
|
297
|
+
matchValue = undefined;
|
|
298
|
+
}
|
|
299
|
+
else {
|
|
300
|
+
const _arg = value_10(x_5);
|
|
301
|
+
let x_3;
|
|
302
|
+
const opt_1 = state;
|
|
303
|
+
x_3 = ((opt_1 == null) ? undefined : opt_1);
|
|
304
|
+
matchValue = ((x_3 == null) ? undefined : append([_arg], x_3));
|
|
305
|
+
}
|
|
306
|
+
r = ((matchValue == null) ? undefined : matchValue);
|
|
307
|
+
if (r == null) {
|
|
308
|
+
return r;
|
|
309
|
+
}
|
|
310
|
+
else {
|
|
311
|
+
state_mut = r;
|
|
312
|
+
f_mut = f;
|
|
313
|
+
xs_mut = xs_1;
|
|
314
|
+
continue traverseOptionM$0027;
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
break;
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
function traverseAsyncOptionM$0027(state, f, xs) {
|
|
322
|
+
if (!equalsWith(equals, xs, defaultOf()) && (xs.length === 0)) {
|
|
323
|
+
return singleton.Bind(state, (x$0027) => {
|
|
324
|
+
let value;
|
|
325
|
+
const input_2 = x$0027;
|
|
326
|
+
value = ((input_2 == null) ? undefined : reverse(input_2));
|
|
327
|
+
return singleton.Return(value);
|
|
328
|
+
});
|
|
329
|
+
}
|
|
330
|
+
else {
|
|
331
|
+
const arr = xs;
|
|
332
|
+
const x_1 = head(arr);
|
|
333
|
+
const xs_1 = skip(1, arr);
|
|
334
|
+
return singleton.Delay(() => singleton.Bind(singleton.Delay(() => {
|
|
335
|
+
const input_8 = f(x_1);
|
|
336
|
+
return singleton.Bind(input_8, (x_3) => {
|
|
337
|
+
if (x_3 == null) {
|
|
338
|
+
return singleton.Return(undefined);
|
|
339
|
+
}
|
|
340
|
+
else {
|
|
341
|
+
const _arg = value_10(x_3);
|
|
342
|
+
return singleton.Bind(state, (x_2) => {
|
|
343
|
+
if (x_2 == null) {
|
|
344
|
+
return singleton.Return(undefined);
|
|
345
|
+
}
|
|
346
|
+
else {
|
|
347
|
+
const value_1_2 = append([_arg], x_2);
|
|
348
|
+
return singleton.Return(value_1_2);
|
|
349
|
+
}
|
|
350
|
+
});
|
|
351
|
+
}
|
|
352
|
+
});
|
|
353
|
+
}), (_arg_2) => {
|
|
354
|
+
const o = _arg_2;
|
|
355
|
+
return (o == null) ? singleton.Return(o) : singleton.ReturnFrom(traverseAsyncOptionM$0027(singleton.Return(o), f, xs_1));
|
|
356
|
+
}));
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
/**
|
|
361
|
+
* Applies the given function <paramref name="f"/> to each element in the input list <paramref name="xs"/>,
|
|
362
|
+
* and returns an option containing a list of the results. If any of the function applications return None,
|
|
363
|
+
* the entire result will be None.
|
|
364
|
+
*/
|
|
365
|
+
export function traverseOptionM(f, xs) {
|
|
366
|
+
return traverseOptionM$0027([], f, xs);
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
/**
|
|
370
|
+
* Applies the monadic function <paramref name="id"/> to each element in the input list <paramref name="xs"/>,
|
|
371
|
+
* and returns the result as an option. If any element in the list is None, the entire result will be None.
|
|
372
|
+
*/
|
|
373
|
+
export function sequenceOptionM(xs) {
|
|
374
|
+
return traverseOptionM((x) => x, xs);
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
export function traverseAsyncOptionM(f, xs) {
|
|
378
|
+
return traverseAsyncOptionM$0027(singleton.Return([]), f, xs);
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
export function sequenceAsyncOptionM(xs) {
|
|
382
|
+
return traverseAsyncOptionM((x) => x, xs);
|
|
383
|
+
}
|
|
384
|
+
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// Auto-Generated by FAKE; do not edit
|
|
2
|
+
namespace System
|
|
3
|
+
open System.Reflection
|
|
4
|
+
|
|
5
|
+
[<assembly: AssemblyTitleAttribute("FsToolkit.ErrorHandling")>]
|
|
6
|
+
[<assembly: AssemblyProductAttribute("FsToolkit.ErrorHandling")>]
|
|
7
|
+
[<assembly: AssemblyDescriptionAttribute("FsToolkit.ErrorHandling is a utility library to work with the Result type in F#, and allows you to do clear, simple and powerful error handling.")>]
|
|
8
|
+
[<assembly: AssemblyVersionAttribute("5.2.0")>]
|
|
9
|
+
[<assembly: AssemblyFileVersionAttribute("5.2.0")>]
|
|
10
|
+
[<assembly: AssemblyConfigurationAttribute("Release")>]
|
|
11
|
+
do ()
|
|
12
|
+
|
|
13
|
+
module internal AssemblyVersionInformation =
|
|
14
|
+
let [<Literal>] AssemblyTitle = "FsToolkit.ErrorHandling"
|
|
15
|
+
let [<Literal>] AssemblyProduct = "FsToolkit.ErrorHandling"
|
|
16
|
+
let [<Literal>] AssemblyDescription = "FsToolkit.ErrorHandling is a utility library to work with the Result type in F#, and allows you to do clear, simple and powerful error handling."
|
|
17
|
+
let [<Literal>] AssemblyVersion = "5.2.0"
|
|
18
|
+
let [<Literal>] AssemblyFileVersion = "5.2.0"
|
|
19
|
+
let [<Literal>] AssemblyConfiguration = "Release"
|
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
namespace FsToolkit.ErrorHandling
|
|
2
|
+
|
|
3
|
+
/// <summary>
|
|
4
|
+
/// Helper functions for working with the <c>Async</c> type.
|
|
5
|
+
/// </summary>
|
|
6
|
+
[<RequireQualifiedAccess>]
|
|
7
|
+
module Async =
|
|
8
|
+
|
|
9
|
+
/// <summary>
|
|
10
|
+
/// Converts a value to an <c>Async</c> value
|
|
11
|
+
/// </summary>
|
|
12
|
+
/// <param name="value">The value to convert to an <c>Async</c> value.</param>
|
|
13
|
+
/// <returns>The <c>Async</c> value.</returns>
|
|
14
|
+
let inline singleton (value: 'value) : Async<'value> =
|
|
15
|
+
value
|
|
16
|
+
|> async.Return
|
|
17
|
+
|
|
18
|
+
/// <summary>
|
|
19
|
+
/// Takes a transformation function and applies it to the value of an <c>Async</c> value.
|
|
20
|
+
/// </summary>
|
|
21
|
+
/// <param name="binder">The function to bind over the <c>Async</c> value.</param>
|
|
22
|
+
/// <param name="input">The <c>Async</c> value to bind over.</param>
|
|
23
|
+
/// <returns>The result of binding the function over the <c>Async</c> value.</returns>
|
|
24
|
+
let inline bind
|
|
25
|
+
([<InlineIfLambda>] binder: 'input -> Async<'output>)
|
|
26
|
+
(input: Async<'input>)
|
|
27
|
+
: Async<'output> =
|
|
28
|
+
async.Bind(input, binder)
|
|
29
|
+
|
|
30
|
+
/// <summary>
|
|
31
|
+
/// Applies an <c>Async</c> function to an <c>Async</c> value.
|
|
32
|
+
/// </summary>
|
|
33
|
+
/// <param name="applier">The <c>Async</c> function to apply.</param>
|
|
34
|
+
/// <param name="input">The <c>Async</c> value to apply the function to.</param>
|
|
35
|
+
/// <returns>The result of applying the function to the value.</returns>
|
|
36
|
+
let inline apply (applier: Async<'input -> 'output>) (input: Async<'input>) : Async<'output> =
|
|
37
|
+
bind (fun f' -> bind (fun x' -> singleton (f' x')) input) applier
|
|
38
|
+
|
|
39
|
+
/// <summary>
|
|
40
|
+
/// Applies a transformation to the value of an <c>Async</c> value to a new <c>Async</c> value using the provided function.
|
|
41
|
+
/// </summary>
|
|
42
|
+
/// <param name="mapper">The function to apply to the value of the <c>Async</c> value.</param>
|
|
43
|
+
/// <param name="input">The <c>Async</c> value to transform.</param>
|
|
44
|
+
/// <returns>The transformed <c>Async</c> value.</returns>
|
|
45
|
+
let inline map
|
|
46
|
+
([<InlineIfLambda>] mapper: 'input -> 'output)
|
|
47
|
+
(input: Async<'input>)
|
|
48
|
+
: Async<'output> =
|
|
49
|
+
bind
|
|
50
|
+
(fun x' ->
|
|
51
|
+
mapper x'
|
|
52
|
+
|> singleton
|
|
53
|
+
)
|
|
54
|
+
input
|
|
55
|
+
|
|
56
|
+
/// <summary>
|
|
57
|
+
/// Applies a transformation to the values of two <c>Async</c> values to a new <c>Async</c> value using the provided function.
|
|
58
|
+
/// </summary>
|
|
59
|
+
/// <param name="mapper">The function to apply to the values of the <c>Async</c> values.</param>
|
|
60
|
+
/// <param name="input1">The first <c>Async</c> value to transform.</param>
|
|
61
|
+
/// <param name="input2">The second <c>Async</c> value to transform.</param>
|
|
62
|
+
/// <returns>The transformed <c>Async</c> value.</returns>
|
|
63
|
+
let inline map2
|
|
64
|
+
([<InlineIfLambda>] mapper: 'input1 -> 'input2 -> 'output)
|
|
65
|
+
(input1: Async<'input1>)
|
|
66
|
+
(input2: Async<'input2>)
|
|
67
|
+
: Async<'output> =
|
|
68
|
+
bind
|
|
69
|
+
(fun x ->
|
|
70
|
+
bind
|
|
71
|
+
(fun y ->
|
|
72
|
+
mapper x y
|
|
73
|
+
|> singleton
|
|
74
|
+
)
|
|
75
|
+
input2
|
|
76
|
+
)
|
|
77
|
+
input1
|
|
78
|
+
|
|
79
|
+
/// <summary>
|
|
80
|
+
/// Applies a transformation to the values of three <c>Async</c> values to a new <c>Async</c> value using the provided function.
|
|
81
|
+
/// </summary>
|
|
82
|
+
/// <param name="mapper">The function to apply to the values of the <c>Async</c> values.</param>
|
|
83
|
+
/// <param name="input1">The first <c>Async</c> value to transform.</param>
|
|
84
|
+
/// <param name="input2">The second <c>Async</c> value to transform.</param>
|
|
85
|
+
/// <param name="input3">The third <c>Async</c> value to transform.</param>
|
|
86
|
+
/// <returns>The transformed <c>Async</c> value.</returns>
|
|
87
|
+
let inline map3
|
|
88
|
+
([<InlineIfLambda>] mapper: 'input1 -> 'input2 -> 'input3 -> 'output)
|
|
89
|
+
(input1: Async<'input1>)
|
|
90
|
+
(input2: Async<'input2>)
|
|
91
|
+
(input3: Async<'input3>)
|
|
92
|
+
: Async<'output> =
|
|
93
|
+
bind
|
|
94
|
+
(fun x ->
|
|
95
|
+
bind
|
|
96
|
+
(fun y ->
|
|
97
|
+
bind
|
|
98
|
+
(fun z ->
|
|
99
|
+
mapper x y z
|
|
100
|
+
|> singleton
|
|
101
|
+
)
|
|
102
|
+
input3
|
|
103
|
+
)
|
|
104
|
+
input2
|
|
105
|
+
)
|
|
106
|
+
input1
|
|
107
|
+
|
|
108
|
+
/// <summary>
|
|
109
|
+
/// Takes two asyncs and returns a tuple of the pair
|
|
110
|
+
/// </summary>
|
|
111
|
+
/// <param name="left">The first async value.</param>
|
|
112
|
+
/// <param name="right">The second async value.</param>
|
|
113
|
+
/// <returns>The tuple of the pair.</returns>
|
|
114
|
+
let inline zip (left: Async<'left>) (right: Async<'right>) : Async<'left * 'right> =
|
|
115
|
+
bind (fun l -> bind (fun r -> singleton (l, r)) right) left
|
|
116
|
+
|
|
117
|
+
/// <summary>
|
|
118
|
+
/// Executes two asyncs concurrently <see cref='M:Microsoft.FSharp.Control.FSharpAsync.Parallel``1'/> and returns a mapping of the values
|
|
119
|
+
/// </summary>
|
|
120
|
+
/// <param name="mapper">The function to apply to the values of the <c>Async</c> values.</param>
|
|
121
|
+
/// <param name="input1">The first <c>Async</c> to execute</param>
|
|
122
|
+
/// <param name="input2">The second <c>Async</c> to execute</param>
|
|
123
|
+
/// <returns>The transformed <c>Async</c> value.</returns>
|
|
124
|
+
let inline parallelMap2
|
|
125
|
+
([<InlineIfLambda>] mapper: 'input1 -> 'input2 -> 'output)
|
|
126
|
+
(input1: Async<'input1>)
|
|
127
|
+
(input2: Async<'input2>)
|
|
128
|
+
: Async<'output> =
|
|
129
|
+
|
|
130
|
+
#if FABLE_COMPILER && FABLE_COMPILER_PYTHON
|
|
131
|
+
Async.Parallel(
|
|
132
|
+
[|
|
|
133
|
+
map box input1
|
|
134
|
+
map box input2
|
|
135
|
+
|]
|
|
136
|
+
)
|
|
137
|
+
#else
|
|
138
|
+
Async.Parallel(
|
|
139
|
+
[|
|
|
140
|
+
map box input1
|
|
141
|
+
map box input2
|
|
142
|
+
|],
|
|
143
|
+
maxDegreeOfParallelism = 2
|
|
144
|
+
)
|
|
145
|
+
#endif
|
|
146
|
+
|> map (fun results ->
|
|
147
|
+
let a =
|
|
148
|
+
results[0]
|
|
149
|
+
|> unbox<'input1>
|
|
150
|
+
|
|
151
|
+
let b =
|
|
152
|
+
results[1]
|
|
153
|
+
|> unbox<'input2>
|
|
154
|
+
|
|
155
|
+
mapper a b
|
|
156
|
+
)
|
|
157
|
+
|
|
158
|
+
/// <summary>
|
|
159
|
+
/// Executes three asyncs concurrently <see cref='M:Microsoft.FSharp.Control.FSharpAsync.Parallel``1'/> and returns a mapping of the values
|
|
160
|
+
/// </summary>
|
|
161
|
+
/// <param name="mapper">The function to apply to the values of the <c>Async</c> values.</param>
|
|
162
|
+
/// <param name="input1">The first <c>Async</c> to execute</param>
|
|
163
|
+
/// <param name="input2">The second <c>Async</c> to execute</param>
|
|
164
|
+
/// <param name="input3">The third <c>Async</c> value to transform.</param>
|
|
165
|
+
/// <returns>The transformed <c>Async</c> value.</returns>
|
|
166
|
+
let inline parallelMap3
|
|
167
|
+
([<InlineIfLambda>] mapper: 'input1 -> 'input2 -> 'input3 -> 'output)
|
|
168
|
+
(input1: Async<'input1>)
|
|
169
|
+
(input2: Async<'input2>)
|
|
170
|
+
(input3: Async<'input3>)
|
|
171
|
+
: Async<'output> =
|
|
172
|
+
#if FABLE_COMPILER && FABLE_COMPILER_PYTHON
|
|
173
|
+
Async.Parallel(
|
|
174
|
+
[|
|
|
175
|
+
map box input1
|
|
176
|
+
map box input2
|
|
177
|
+
map box input3
|
|
178
|
+
|]
|
|
179
|
+
)
|
|
180
|
+
#else
|
|
181
|
+
Async.Parallel(
|
|
182
|
+
[|
|
|
183
|
+
map box input1
|
|
184
|
+
map box input2
|
|
185
|
+
map box input3
|
|
186
|
+
|],
|
|
187
|
+
maxDegreeOfParallelism = 3
|
|
188
|
+
)
|
|
189
|
+
#endif
|
|
190
|
+
|> map (fun results ->
|
|
191
|
+
let a =
|
|
192
|
+
results[0]
|
|
193
|
+
|> unbox<'input1>
|
|
194
|
+
|
|
195
|
+
let b =
|
|
196
|
+
results[1]
|
|
197
|
+
|> unbox<'input2>
|
|
198
|
+
|
|
199
|
+
let c =
|
|
200
|
+
results[2]
|
|
201
|
+
|> unbox<'input3>
|
|
202
|
+
|
|
203
|
+
mapper a b c
|
|
204
|
+
)
|
|
205
|
+
|
|
206
|
+
/// <summary>
|
|
207
|
+
/// Operators for working with the <c>Async</c> type.
|
|
208
|
+
/// </summary>
|
|
209
|
+
module AsyncOperators =
|
|
210
|
+
|
|
211
|
+
/// <summary>
|
|
212
|
+
/// Shorthand for <c>Async.map</c>
|
|
213
|
+
/// </summary>
|
|
214
|
+
/// <param name="mapper">The function to map over the <c>Async</c> value.</param>
|
|
215
|
+
/// <param name="input">The <c>Async</c> value to map over.</param>
|
|
216
|
+
/// <returns>The result of mapping the function over the <c>Async</c> value.</returns>
|
|
217
|
+
let inline (<!>)
|
|
218
|
+
([<InlineIfLambda>] mapper: 'input -> 'output)
|
|
219
|
+
(input: Async<'input>)
|
|
220
|
+
: Async<'output> =
|
|
221
|
+
Async.map mapper input
|
|
222
|
+
|
|
223
|
+
/// <summary>
|
|
224
|
+
/// Shorthand for <c>Async.apply</c>
|
|
225
|
+
/// </summary>
|
|
226
|
+
/// <param name="applier">The <c>Async</c> function to apply.</param>
|
|
227
|
+
/// <param name="input">The <c>Async</c> value to apply the function to.</param>
|
|
228
|
+
/// <returns>The result of applying the function to the value.</returns>
|
|
229
|
+
let inline (<*>) (applier: Async<'input -> 'output>) (input: Async<'input>) : Async<'output> =
|
|
230
|
+
Async.apply applier input
|
|
231
|
+
|
|
232
|
+
/// <summary>
|
|
233
|
+
/// Shorthand for <c>Async.bind</c>
|
|
234
|
+
/// </summary>
|
|
235
|
+
/// <param name="input">The <c>Async</c> value to bind over.</param>
|
|
236
|
+
/// <param name="binder">The function to bind over the <c>Async</c> value.</param>
|
|
237
|
+
/// <returns>The result of binding the function over the <c>Async</c> value.</returns>
|
|
238
|
+
let inline (>>=)
|
|
239
|
+
(input: Async<'input>)
|
|
240
|
+
([<InlineIfLambda>] binder: 'input -> Async<'output>)
|
|
241
|
+
: Async<'output> =
|
|
242
|
+
Async.bind binder input
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
[<AutoOpen>]
|
|
246
|
+
module AsyncExt =
|
|
247
|
+
open System
|
|
248
|
+
|
|
249
|
+
type Microsoft.FSharp.Control.Async with
|
|
250
|
+
|
|
251
|
+
static member TryFinallyAsync(comp: Async<'T>, deferred) : Async<'T> =
|
|
252
|
+
|
|
253
|
+
let finish (compResult, deferredResult) (cont, (econt: exn -> unit), ccont) =
|
|
254
|
+
match (compResult, deferredResult) with
|
|
255
|
+
| (Choice1Of3 x, Choice1Of3()) -> cont x
|
|
256
|
+
| (Choice2Of3 compExn, Choice1Of3()) -> econt compExn
|
|
257
|
+
| (Choice3Of3 compExn, Choice1Of3()) -> ccont compExn
|
|
258
|
+
| (Choice1Of3 _, Choice2Of3 deferredExn) -> econt deferredExn
|
|
259
|
+
| (Choice2Of3 compExn, Choice2Of3 deferredExn) ->
|
|
260
|
+
econt
|
|
261
|
+
<| new AggregateException(compExn, deferredExn)
|
|
262
|
+
| (Choice3Of3 compExn, Choice2Of3 deferredExn) -> econt deferredExn
|
|
263
|
+
| (_, Choice3Of3 deferredExn) ->
|
|
264
|
+
econt
|
|
265
|
+
<| new Exception("Unexpected cancellation.", deferredExn)
|
|
266
|
+
|
|
267
|
+
let startDeferred compResult (cont, econt, ccont) =
|
|
268
|
+
Async.StartWithContinuations(
|
|
269
|
+
deferred,
|
|
270
|
+
(fun () -> finish (compResult, Choice1Of3()) (cont, econt, ccont)),
|
|
271
|
+
(fun exn -> finish (compResult, Choice2Of3 exn) (cont, econt, ccont)),
|
|
272
|
+
(fun exn -> finish (compResult, Choice3Of3 exn) (cont, econt, ccont))
|
|
273
|
+
)
|
|
274
|
+
|
|
275
|
+
let startComp ct (cont, econt, ccont) =
|
|
276
|
+
Async.StartWithContinuations(
|
|
277
|
+
comp,
|
|
278
|
+
(fun x -> startDeferred (Choice1Of3(x)) (cont, econt, ccont)),
|
|
279
|
+
(fun exn -> startDeferred (Choice2Of3 exn) (cont, econt, ccont)),
|
|
280
|
+
(fun exn -> startDeferred (Choice3Of3 exn) (cont, econt, ccont)),
|
|
281
|
+
ct
|
|
282
|
+
)
|
|
283
|
+
|
|
284
|
+
async {
|
|
285
|
+
let! ct = Async.CancellationToken
|
|
286
|
+
return! Async.FromContinuations(startComp ct)
|
|
287
|
+
}
|