@glutinum/cli 0.14.0 → 0.14.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/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 +1 -1
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
|
|
2
|
+
import { Exception } from "../fable-library-js.5.17.2/Util.js";
|
|
3
|
+
import { fromContinuations, cancellationToken, startWithContinuations } from "../fable-library-js.5.17.2/Async.js";
|
|
4
|
+
import { FSharpChoice$3 } from "../fable-library-js.5.17.2/Choice.js";
|
|
5
|
+
import { singleton } from "../fable-library-js.5.17.2/AsyncBuilder.js";
|
|
6
|
+
|
|
7
|
+
export function Microsoft_FSharp_Control_FSharpAsync__Async_TryFinallyAsync_Static_Z753D11A1(comp, deferred) {
|
|
8
|
+
const finish = (tupledArg, tupledArg_1) => {
|
|
9
|
+
const compResult = tupledArg[0];
|
|
10
|
+
const deferredResult = tupledArg[1];
|
|
11
|
+
const econt = tupledArg_1[1];
|
|
12
|
+
let matchResult, x, compExn, compExn_1, deferredExn, compExn_2, deferredExn_1, compExn_3, deferredExn_2, deferredExn_3;
|
|
13
|
+
switch (compResult.tag) {
|
|
14
|
+
case 1: {
|
|
15
|
+
switch (deferredResult.tag) {
|
|
16
|
+
case 1: {
|
|
17
|
+
matchResult = 4;
|
|
18
|
+
compExn_2 = compResult.fields[0];
|
|
19
|
+
deferredExn_1 = deferredResult.fields[0];
|
|
20
|
+
break;
|
|
21
|
+
}
|
|
22
|
+
case 2: {
|
|
23
|
+
matchResult = 6;
|
|
24
|
+
deferredExn_3 = deferredResult.fields[0];
|
|
25
|
+
break;
|
|
26
|
+
}
|
|
27
|
+
default: {
|
|
28
|
+
matchResult = 1;
|
|
29
|
+
compExn = compResult.fields[0];
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
break;
|
|
33
|
+
}
|
|
34
|
+
case 2: {
|
|
35
|
+
switch (deferredResult.tag) {
|
|
36
|
+
case 1: {
|
|
37
|
+
matchResult = 5;
|
|
38
|
+
compExn_3 = compResult.fields[0];
|
|
39
|
+
deferredExn_2 = deferredResult.fields[0];
|
|
40
|
+
break;
|
|
41
|
+
}
|
|
42
|
+
case 2: {
|
|
43
|
+
matchResult = 6;
|
|
44
|
+
deferredExn_3 = deferredResult.fields[0];
|
|
45
|
+
break;
|
|
46
|
+
}
|
|
47
|
+
default: {
|
|
48
|
+
matchResult = 2;
|
|
49
|
+
compExn_1 = compResult.fields[0];
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
break;
|
|
53
|
+
}
|
|
54
|
+
default:
|
|
55
|
+
switch (deferredResult.tag) {
|
|
56
|
+
case 1: {
|
|
57
|
+
matchResult = 3;
|
|
58
|
+
deferredExn = deferredResult.fields[0];
|
|
59
|
+
break;
|
|
60
|
+
}
|
|
61
|
+
case 2: {
|
|
62
|
+
matchResult = 6;
|
|
63
|
+
deferredExn_3 = deferredResult.fields[0];
|
|
64
|
+
break;
|
|
65
|
+
}
|
|
66
|
+
default: {
|
|
67
|
+
matchResult = 0;
|
|
68
|
+
x = compResult.fields[0];
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
switch (matchResult) {
|
|
73
|
+
case 0: {
|
|
74
|
+
tupledArg_1[0](x);
|
|
75
|
+
break;
|
|
76
|
+
}
|
|
77
|
+
case 1: {
|
|
78
|
+
econt(compExn);
|
|
79
|
+
break;
|
|
80
|
+
}
|
|
81
|
+
case 2: {
|
|
82
|
+
tupledArg_1[2](compExn_1);
|
|
83
|
+
break;
|
|
84
|
+
}
|
|
85
|
+
case 3: {
|
|
86
|
+
econt(deferredExn);
|
|
87
|
+
break;
|
|
88
|
+
}
|
|
89
|
+
case 4: {
|
|
90
|
+
econt(new Exception([compExn_2, deferredExn_1]));
|
|
91
|
+
break;
|
|
92
|
+
}
|
|
93
|
+
case 5: {
|
|
94
|
+
econt(deferredExn_2);
|
|
95
|
+
break;
|
|
96
|
+
}
|
|
97
|
+
case 6: {
|
|
98
|
+
econt(new Exception("Unexpected cancellation.", deferredExn_3));
|
|
99
|
+
break;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
const startDeferred = (compResult_1, tupledArg_2) => {
|
|
104
|
+
const cont_1 = tupledArg_2[0];
|
|
105
|
+
const econt_1 = tupledArg_2[1];
|
|
106
|
+
const ccont_1 = tupledArg_2[2];
|
|
107
|
+
startWithContinuations(deferred, () => {
|
|
108
|
+
finish([compResult_1, new FSharpChoice$3(/* Choice1Of3 */ 0, [undefined])], [cont_1, econt_1, ccont_1]);
|
|
109
|
+
}, (exn) => {
|
|
110
|
+
finish([compResult_1, new FSharpChoice$3(/* Choice2Of3 */ 1, [exn])], [cont_1, econt_1, ccont_1]);
|
|
111
|
+
}, (exn_1) => {
|
|
112
|
+
finish([compResult_1, new FSharpChoice$3(/* Choice3Of3 */ 2, [exn_1])], [cont_1, econt_1, ccont_1]);
|
|
113
|
+
});
|
|
114
|
+
};
|
|
115
|
+
return singleton.Delay(() => singleton.Bind(cancellationToken(), (_arg) => singleton.ReturnFrom(fromContinuations((tupledArg_3) => {
|
|
116
|
+
const cont_2 = tupledArg_3[0];
|
|
117
|
+
const econt_2 = tupledArg_3[1];
|
|
118
|
+
const ccont_2 = tupledArg_3[2];
|
|
119
|
+
startWithContinuations(comp, (x_1) => {
|
|
120
|
+
startDeferred(new FSharpChoice$3(/* Choice1Of3 */ 0, [x_1]), [cont_2, econt_2, ccont_2]);
|
|
121
|
+
}, (exn_2) => {
|
|
122
|
+
startDeferred(new FSharpChoice$3(/* Choice2Of3 */ 1, [exn_2]), [cont_2, econt_2, ccont_2]);
|
|
123
|
+
}, (exn_3) => {
|
|
124
|
+
startDeferred(new FSharpChoice$3(/* Choice3Of3 */ 2, [exn_3]), [cont_2, econt_2, ccont_2]);
|
|
125
|
+
}, _arg);
|
|
126
|
+
}))));
|
|
127
|
+
}
|
|
128
|
+
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
namespace FsToolkit.ErrorHandling
|
|
2
|
+
|
|
3
|
+
[<RequireQualifiedAccess>]
|
|
4
|
+
module AsyncOption =
|
|
5
|
+
|
|
6
|
+
let inline map
|
|
7
|
+
([<InlineIfLambda>] mapper: 'input -> 'output)
|
|
8
|
+
(input: Async<'input option>)
|
|
9
|
+
: Async<'output option> =
|
|
10
|
+
Async.map (Option.map mapper) input
|
|
11
|
+
|
|
12
|
+
let inline bind
|
|
13
|
+
([<InlineIfLambda>] binder: 'input -> Async<'output option>)
|
|
14
|
+
(input: Async<'input option>)
|
|
15
|
+
: Async<'output option> =
|
|
16
|
+
Async.bind
|
|
17
|
+
(fun x ->
|
|
18
|
+
match x with
|
|
19
|
+
| Some x -> binder x
|
|
20
|
+
| None -> Async.singleton None
|
|
21
|
+
)
|
|
22
|
+
input
|
|
23
|
+
|
|
24
|
+
let inline some (value: 'value) : Async<'value option> = Async.singleton (Some value)
|
|
25
|
+
|
|
26
|
+
let inline apply
|
|
27
|
+
(applier: Async<('input -> 'output) option>)
|
|
28
|
+
(input: Async<'input option>)
|
|
29
|
+
: Async<'output option> =
|
|
30
|
+
bind (fun f' -> bind (fun x' -> some (f' x')) input) applier
|
|
31
|
+
|
|
32
|
+
/// <summary>
|
|
33
|
+
/// Returns result of running <paramref name="onSome"/> if it is <c>Some</c>, otherwise returns result of running <paramref name="onNone"/>
|
|
34
|
+
/// </summary>
|
|
35
|
+
/// <param name="onSome">The function to run if <paramref name="input"/> is <c>Some</c></param>
|
|
36
|
+
/// <param name="onNone">The function to run if <paramref name="input"/> is <c>None</c></param>
|
|
37
|
+
/// <param name="input">The input option.</param>
|
|
38
|
+
/// <returns>
|
|
39
|
+
/// The result of running <paramref name="onSome"/> if the input is <c>Some</c>, else returns result of running <paramref name="onNone"/>.
|
|
40
|
+
/// </returns>
|
|
41
|
+
let inline either
|
|
42
|
+
([<InlineIfLambda>] onSome: 'input -> Async<'output>)
|
|
43
|
+
(onNone: Async<'output>)
|
|
44
|
+
(input: Async<'input option>)
|
|
45
|
+
: Async<'output> =
|
|
46
|
+
input
|
|
47
|
+
|> Async.bind (
|
|
48
|
+
function
|
|
49
|
+
| Some v -> onSome v
|
|
50
|
+
| None -> onNone
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
/// <summary>
|
|
54
|
+
/// Gets the value of the option if the option is <c>Some</c>, otherwise returns the specified default value.
|
|
55
|
+
/// </summary>
|
|
56
|
+
/// <param name="value">The specified default value.</param>
|
|
57
|
+
/// <param name="asyncOption">The input option.</param>
|
|
58
|
+
/// <returns>
|
|
59
|
+
/// The option if the option is <c>Some</c>, else the default value.
|
|
60
|
+
/// </returns>
|
|
61
|
+
let inline defaultValue (value: 'value) (asyncOption: Async<'value option>) =
|
|
62
|
+
asyncOption
|
|
63
|
+
|> Async.map (Option.defaultValue value)
|
|
64
|
+
|
|
65
|
+
/// <summary>
|
|
66
|
+
/// Gets the value of the option if the option is <c>Some</c>, otherwise evaluates <paramref name="defThunk"/> and returns the result.
|
|
67
|
+
/// </summary>
|
|
68
|
+
/// <param name="defThunk">A thunk that provides a default value when evaluated.</param>
|
|
69
|
+
/// <param name="asyncOption">The input option.</param>
|
|
70
|
+
/// <returns>
|
|
71
|
+
/// The option if the option is <c>Some</c>, else the result of evaluating <paramref name="defThunk"/>.
|
|
72
|
+
/// </returns>
|
|
73
|
+
let inline defaultWith
|
|
74
|
+
([<InlineIfLambda>] defThunk: unit -> 'value)
|
|
75
|
+
(asyncOption: Async<'value option>)
|
|
76
|
+
: Async<'value> =
|
|
77
|
+
asyncOption
|
|
78
|
+
|> Async.map (Option.defaultWith defThunk)
|
|
79
|
+
|
|
80
|
+
/// <summary>
|
|
81
|
+
/// Returns <paramref name="input"/> if it is <c>Some</c>, otherwise returns <paramref name="ifNone"/>
|
|
82
|
+
/// </summary>
|
|
83
|
+
/// <param name="ifNone">The value to use if <paramref name="input"/> is <c>None</c></param>
|
|
84
|
+
/// <param name="input">The input option.</param>
|
|
85
|
+
/// <remarks>
|
|
86
|
+
/// </remarks>
|
|
87
|
+
/// <example>
|
|
88
|
+
/// <code>
|
|
89
|
+
/// None |> Async.singleton |> AsyncOption.orElse (AsyncOption.some "Second") // evaluates to Some ("Second")
|
|
90
|
+
/// None |> Async.singleton |> AsyncOption.orElse (None |> Async.singleton) // evaluates to None
|
|
91
|
+
/// AsyncOption.some "First" |> AsyncOption.orElse (AsyncOption.some "Second") // evaluates to Some ("First")
|
|
92
|
+
/// AsyncOption.some "First" |> AsyncOption.orElse (None |> Async.singleton) // evaluates to Some ("First")
|
|
93
|
+
/// </code>
|
|
94
|
+
/// </example>
|
|
95
|
+
/// <returns>
|
|
96
|
+
/// The option if the option is Some, else returns <paramref name="ifNone"/>.
|
|
97
|
+
/// </returns>
|
|
98
|
+
let inline orElse
|
|
99
|
+
(ifNone: Async<'value option>)
|
|
100
|
+
(input: Async<'value option>)
|
|
101
|
+
: Async<'value option> =
|
|
102
|
+
Async.bind (Option.either some (fun _ -> ifNone)) input
|
|
103
|
+
|
|
104
|
+
/// <summary>
|
|
105
|
+
/// Returns <paramref name="input"/> if it is <c>Some</c>, otherwise executes <paramref name="ifNoneFunc"/> and returns the result.
|
|
106
|
+
/// </summary>
|
|
107
|
+
/// <param name="ifNoneFunc">A function that provides an alternate option when evaluated.</param>
|
|
108
|
+
/// <param name="input">The input option.</param>
|
|
109
|
+
/// <remarks>
|
|
110
|
+
/// <paramref name="ifNoneFunc"/> is not executed unless <paramref name="input"/> is a <c>None</c>.
|
|
111
|
+
/// </remarks>
|
|
112
|
+
/// <example>
|
|
113
|
+
/// <code>
|
|
114
|
+
/// None |> Async.singleton |> AsyncOption.orElseWith (fun _ -> AsyncOption.some "Second") // evaluates to Some ("Second")
|
|
115
|
+
/// None |> Async.singleton |> AsyncOption.orElseWith (fun _ -> None |> Async.singleton) // evaluates to None
|
|
116
|
+
/// AsyncOption.some "First" |> AsyncOption.orElseWith (fun _ -> AsyncOption.some "Second") // evaluates to Some ("First")
|
|
117
|
+
/// AsyncOption.some "First" |> AsyncOption.orElseWith (fun _ -> None |> Async.singleton) // evaluates to Ok ("First")
|
|
118
|
+
/// </code>
|
|
119
|
+
/// </example>
|
|
120
|
+
/// <returns>
|
|
121
|
+
/// The option if the option is Some, else the result of executing <paramref name="ifNoneFunc"/>.
|
|
122
|
+
/// </returns>
|
|
123
|
+
let inline orElseWith
|
|
124
|
+
([<InlineIfLambda>] ifNoneFunc: unit -> Async<'value option>)
|
|
125
|
+
(input: Async<'value option>)
|
|
126
|
+
: Async<'value option> =
|
|
127
|
+
Async.bind (Option.either some ifNoneFunc) input
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
namespace FsToolkit.ErrorHandling
|
|
2
|
+
|
|
3
|
+
open System.Threading.Tasks
|
|
4
|
+
open System
|
|
5
|
+
|
|
6
|
+
[<AutoOpen>]
|
|
7
|
+
module AsyncOptionCE =
|
|
8
|
+
type AsyncOptionBuilder() =
|
|
9
|
+
|
|
10
|
+
member inline _.Return(value: 'value) : Async<'value option> = AsyncOption.some value
|
|
11
|
+
|
|
12
|
+
member inline _.ReturnFrom(value: Async<'value option>) : Async<'value option> = value
|
|
13
|
+
|
|
14
|
+
member inline _.Zero() : Async<unit option> =
|
|
15
|
+
Some()
|
|
16
|
+
|> async.Return
|
|
17
|
+
|
|
18
|
+
member inline _.Bind
|
|
19
|
+
(input: Async<'input option>, [<InlineIfLambda>] binder: 'input -> Async<'output option>) : Async<
|
|
20
|
+
'output option
|
|
21
|
+
>
|
|
22
|
+
=
|
|
23
|
+
AsyncOption.bind binder input
|
|
24
|
+
|
|
25
|
+
member inline _.Delay(generator: unit -> Async<'value option>) : Async<'value option> =
|
|
26
|
+
async.Delay generator
|
|
27
|
+
|
|
28
|
+
member inline this.Combine
|
|
29
|
+
(computation1: Async<_ option>, computation2: Async<_ option>)
|
|
30
|
+
: Async<_ option> =
|
|
31
|
+
this.Bind(computation1, (fun () -> computation2))
|
|
32
|
+
|
|
33
|
+
member inline _.TryWith
|
|
34
|
+
(
|
|
35
|
+
computation: Async<'value option>,
|
|
36
|
+
[<InlineIfLambda>] handler: System.Exception -> Async<'value option>
|
|
37
|
+
) : Async<_ option> =
|
|
38
|
+
async.TryWith(computation, handler)
|
|
39
|
+
|
|
40
|
+
member inline _.TryFinally
|
|
41
|
+
(computation: Async<'value option>, [<InlineIfLambda>] compensation: unit -> unit)
|
|
42
|
+
: Async<'value option> =
|
|
43
|
+
async.TryFinally(computation, compensation)
|
|
44
|
+
#if !FABLE_COMPILER
|
|
45
|
+
member inline _.TryFinallyAsync
|
|
46
|
+
(computation: Async<'value option>, [<InlineIfLambda>] compensation: unit -> ValueTask)
|
|
47
|
+
: Async<'value option> =
|
|
48
|
+
let compensation =
|
|
49
|
+
async {
|
|
50
|
+
let vTask = compensation ()
|
|
51
|
+
|
|
52
|
+
if vTask.IsCompletedSuccessfully then
|
|
53
|
+
return ()
|
|
54
|
+
else
|
|
55
|
+
return!
|
|
56
|
+
vTask.AsTask()
|
|
57
|
+
|> Async.AwaitTask
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
Async.TryFinallyAsync(computation, compensation)
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
member inline this.Using
|
|
64
|
+
(
|
|
65
|
+
resource: 'ok :> IAsyncDisposable,
|
|
66
|
+
[<InlineIfLambda>] binder: 'ok -> Async<'value option>
|
|
67
|
+
) : Async<'value option> =
|
|
68
|
+
this.TryFinallyAsync(
|
|
69
|
+
binder resource,
|
|
70
|
+
(fun () ->
|
|
71
|
+
if not (isNull (box resource)) then
|
|
72
|
+
resource.DisposeAsync()
|
|
73
|
+
else
|
|
74
|
+
ValueTask()
|
|
75
|
+
)
|
|
76
|
+
)
|
|
77
|
+
#endif
|
|
78
|
+
|
|
79
|
+
member this.While
|
|
80
|
+
(guard: unit -> bool, computation: Async<unit option>)
|
|
81
|
+
: Async<unit option> =
|
|
82
|
+
if not (guard ()) then
|
|
83
|
+
this.Zero()
|
|
84
|
+
else
|
|
85
|
+
this.Bind(computation, (fun () -> this.While(guard, computation)))
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
/// <summary>
|
|
89
|
+
/// Method lets us transform data types into our internal representation. This is the identity method to recognize the self type.
|
|
90
|
+
///
|
|
91
|
+
/// See https://stackoverflow.com/questions/35286541/why-would-you-use-builder-source-in-a-custom-computation-expression-builder
|
|
92
|
+
/// </summary>
|
|
93
|
+
member inline _.Source(async: Async<'value option>) : Async<'value option> = async
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
let asyncOption = AsyncOptionBuilder()
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
[<AutoOpen>]
|
|
100
|
+
// Having members as extensions gives them lower priority in
|
|
101
|
+
// overload resolution and allows skipping more type annotations.
|
|
102
|
+
module AsyncOptionCEExtensions =
|
|
103
|
+
|
|
104
|
+
type AsyncOptionBuilder with
|
|
105
|
+
|
|
106
|
+
/// <summary>
|
|
107
|
+
/// Needed to allow `for..in` and `for..do` functionality
|
|
108
|
+
/// </summary>
|
|
109
|
+
member inline _.Source(s: #seq<_>) : #seq<_> = s
|
|
110
|
+
|
|
111
|
+
/// <summary>
|
|
112
|
+
/// Method lets us transform data types into our internal representation.
|
|
113
|
+
/// </summary>
|
|
114
|
+
member inline _.Source(r: 'value option) : Async<option<'value>> = Async.singleton r
|
|
115
|
+
|
|
116
|
+
/// <summary>
|
|
117
|
+
/// Method lets us transform data types into our internal representation.
|
|
118
|
+
/// </summary>
|
|
119
|
+
member inline _.Source(a: Async<'value>) : Async<option<'value>> =
|
|
120
|
+
a
|
|
121
|
+
|> Async.map Some
|
|
122
|
+
|
|
123
|
+
member inline this.Using
|
|
124
|
+
(
|
|
125
|
+
resource: 'disposable :> IDisposable,
|
|
126
|
+
[<InlineIfLambda>] binder: 'disposable -> Async<'output option>
|
|
127
|
+
) : Async<'output option> =
|
|
128
|
+
this.TryFinally(
|
|
129
|
+
(binder resource),
|
|
130
|
+
(fun () ->
|
|
131
|
+
if not (obj.ReferenceEquals(resource, null)) then
|
|
132
|
+
resource.Dispose()
|
|
133
|
+
)
|
|
134
|
+
)
|
|
135
|
+
|
|
136
|
+
member inline this.For
|
|
137
|
+
(sequence: #seq<'input>, binder: 'input -> Async<unit option>)
|
|
138
|
+
: Async<unit option> =
|
|
139
|
+
this.Using(
|
|
140
|
+
sequence.GetEnumerator(),
|
|
141
|
+
fun enum -> this.While(enum.MoveNext, this.Delay(fun () -> binder enum.Current))
|
|
142
|
+
)
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
#if !FABLE_COMPILER
|
|
146
|
+
/// <summary>
|
|
147
|
+
/// Method lets us transform data types into our internal representation.
|
|
148
|
+
/// </summary>
|
|
149
|
+
member inline _.Source(a: Task<'value>) : Async<option<'value>> =
|
|
150
|
+
a
|
|
151
|
+
|> Async.AwaitTask
|
|
152
|
+
|> Async.map Some
|
|
153
|
+
|
|
154
|
+
/// <summary>
|
|
155
|
+
/// Method lets us transform data types into our internal representation.
|
|
156
|
+
/// </summary>
|
|
157
|
+
member inline _.Source(a: Task) : Async<option<unit>> =
|
|
158
|
+
a
|
|
159
|
+
|> Async.AwaitTask
|
|
160
|
+
|> Async.map Some
|
|
161
|
+
|
|
162
|
+
[<AutoOpen>]
|
|
163
|
+
module AsyncOptionCEExtensionsHigher =
|
|
164
|
+
|
|
165
|
+
type AsyncOptionBuilder with
|
|
166
|
+
|
|
167
|
+
/// <summary>
|
|
168
|
+
/// Method lets us transform data types into our internal representation.
|
|
169
|
+
/// </summary>
|
|
170
|
+
member inline _.Source(task: Task<'value option>) : Async<'value option> =
|
|
171
|
+
task
|
|
172
|
+
|> Async.AwaitTask
|
|
173
|
+
|
|
174
|
+
#endif
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
|
|
2
|
+
import { class_type } from "../fable-library-js.5.17.2/Reflection.js";
|
|
3
|
+
import { singleton } from "../fable-library-js.5.17.2/AsyncBuilder.js";
|
|
4
|
+
import { value as value_2, some } from "../fable-library-js.5.17.2/Option.js";
|
|
5
|
+
|
|
6
|
+
export class AsyncOptionCE_AsyncOptionBuilder {
|
|
7
|
+
constructor() {
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function AsyncOptionCE_AsyncOptionBuilder_$reflection() {
|
|
12
|
+
return class_type("FsToolkit.ErrorHandling.AsyncOptionCE.AsyncOptionBuilder", undefined, AsyncOptionCE_AsyncOptionBuilder);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function AsyncOptionCE_AsyncOptionBuilder_$ctor() {
|
|
16
|
+
return new AsyncOptionCE_AsyncOptionBuilder();
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function AsyncOptionCE_AsyncOptionBuilder__While_78DDE493(this$, guard, computation) {
|
|
20
|
+
if (!guard()) {
|
|
21
|
+
return singleton.Return(some(undefined));
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
return singleton.Bind(computation, (x) => {
|
|
25
|
+
if (x == null) {
|
|
26
|
+
return singleton.Return(undefined);
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
value_2(x);
|
|
30
|
+
return AsyncOptionCE_AsyncOptionBuilder__While_78DDE493(this$, guard, computation);
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export const AsyncOptionCE_asyncOption = AsyncOptionCE_AsyncOptionBuilder_$ctor();
|
|
37
|
+
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
namespace FsToolkit.ErrorHandling.Operator.AsyncOption
|
|
2
|
+
|
|
3
|
+
open FsToolkit.ErrorHandling
|
|
4
|
+
|
|
5
|
+
[<AutoOpen>]
|
|
6
|
+
module AsyncOption =
|
|
7
|
+
|
|
8
|
+
let inline (<!>)
|
|
9
|
+
(([<InlineIfLambda>] mapper: 'input -> 'output))
|
|
10
|
+
(input: Async<'input option>)
|
|
11
|
+
: Async<'output option> =
|
|
12
|
+
AsyncOption.map mapper input
|
|
13
|
+
|
|
14
|
+
let inline (<*>)
|
|
15
|
+
(applier: Async<('input -> 'output) option>)
|
|
16
|
+
(input: Async<'input option>)
|
|
17
|
+
: Async<'output option> =
|
|
18
|
+
AsyncOption.apply applier input
|
|
19
|
+
|
|
20
|
+
let inline (>>=)
|
|
21
|
+
(input: Async<'input option>)
|
|
22
|
+
([<InlineIfLambda>] binder: 'input -> Async<'output option>)
|
|
23
|
+
: Async<'output option> =
|
|
24
|
+
AsyncOption.bind binder input
|