@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,587 @@
|
|
|
1
|
+
namespace FsToolkit.ErrorHandling
|
|
2
|
+
|
|
3
|
+
open System
|
|
4
|
+
open System.Runtime.CompilerServices
|
|
5
|
+
open System.Threading
|
|
6
|
+
open System.Threading.Tasks
|
|
7
|
+
open Microsoft.FSharp.Core
|
|
8
|
+
open Microsoft.FSharp.Core.CompilerServices
|
|
9
|
+
open Microsoft.FSharp.Core.CompilerServices.StateMachineHelpers
|
|
10
|
+
open Microsoft.FSharp.Core.LanguagePrimitives.IntrinsicOperators
|
|
11
|
+
open Microsoft.FSharp.Control
|
|
12
|
+
open Microsoft.FSharp.Collections
|
|
13
|
+
|
|
14
|
+
/// ValueTask<'T voption>
|
|
15
|
+
type ValueTaskValueOption<'T> = ValueTask<'T voption>
|
|
16
|
+
|
|
17
|
+
[<Struct; NoComparison; NoEquality>]
|
|
18
|
+
type ValueTaskValueOptionStateMachineData<'T> =
|
|
19
|
+
|
|
20
|
+
[<DefaultValue(false)>]
|
|
21
|
+
val mutable Result: 'T voption voption
|
|
22
|
+
|
|
23
|
+
[<DefaultValue(false)>]
|
|
24
|
+
val mutable MethodBuilder: AsyncValueTaskValueOptionMethodBuilder<'T>
|
|
25
|
+
|
|
26
|
+
member this.IsResultNone =
|
|
27
|
+
match this.Result with
|
|
28
|
+
| ValueNone -> false
|
|
29
|
+
| ValueSome(ValueNone) -> true
|
|
30
|
+
| ValueSome _ -> false
|
|
31
|
+
|
|
32
|
+
member this.SetResult() =
|
|
33
|
+
match this.Result with
|
|
34
|
+
| ValueNone -> this.MethodBuilder.SetResult ValueNone
|
|
35
|
+
| ValueSome x -> this.MethodBuilder.SetResult x
|
|
36
|
+
|
|
37
|
+
member this.IsTaskCompleted = this.MethodBuilder.Task.IsCompleted
|
|
38
|
+
|
|
39
|
+
and AsyncValueTaskValueOptionMethodBuilder<'TOverall> =
|
|
40
|
+
AsyncValueTaskMethodBuilder<'TOverall voption>
|
|
41
|
+
|
|
42
|
+
and ValueTaskValueOptionStateMachine<'TOverall> =
|
|
43
|
+
ResumableStateMachine<ValueTaskValueOptionStateMachineData<'TOverall>>
|
|
44
|
+
|
|
45
|
+
and ValueTaskValueOptionResumptionFunc<'TOverall> =
|
|
46
|
+
ResumptionFunc<ValueTaskValueOptionStateMachineData<'TOverall>>
|
|
47
|
+
|
|
48
|
+
and ValueTaskValueOptionResumptionDynamicInfo<'TOverall> =
|
|
49
|
+
ResumptionDynamicInfo<ValueTaskValueOptionStateMachineData<'TOverall>>
|
|
50
|
+
|
|
51
|
+
and ValueTaskValueOptionCode<'TOverall, 'T> =
|
|
52
|
+
ResumableCode<ValueTaskValueOptionStateMachineData<'TOverall>, 'T>
|
|
53
|
+
|
|
54
|
+
type ValueTaskValueOptionBuilderBase() =
|
|
55
|
+
|
|
56
|
+
member inline _.Delay
|
|
57
|
+
(generator: unit -> ValueTaskValueOptionCode<'TOverall, 'T>)
|
|
58
|
+
: ValueTaskValueOptionCode<'TOverall, 'T> =
|
|
59
|
+
ValueTaskValueOptionCode<'TOverall, 'T>(fun sm -> (generator ()).Invoke(&sm))
|
|
60
|
+
|
|
61
|
+
/// Used to represent no-ops like the implicit empty "else" branch of an "if" expression.
|
|
62
|
+
[<DefaultValue>]
|
|
63
|
+
member inline _.Zero<'TOverall>() : ValueTaskValueOptionCode<'TOverall, unit> =
|
|
64
|
+
ValueTaskValueOptionCode<_, _>(fun sm ->
|
|
65
|
+
sm.Data.Result <- ValueSome(ValueSome Unchecked.defaultof<'TOverall>)
|
|
66
|
+
true
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
member inline _.Return(value: 'T) : ValueTaskValueOptionCode<'T, 'T> =
|
|
70
|
+
ValueTaskValueOptionCode<'T, _>(fun sm ->
|
|
71
|
+
sm.Data.Result <- ValueSome(ValueSome value)
|
|
72
|
+
true
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
/// Chains together a step with its following step.
|
|
76
|
+
/// Note that this requires that the first step has no result.
|
|
77
|
+
/// This prevents constructs like `task { return 1; return 2; }`.
|
|
78
|
+
member inline _.Combine
|
|
79
|
+
(
|
|
80
|
+
task1: ValueTaskValueOptionCode<'TOverall, unit>,
|
|
81
|
+
task2: ValueTaskValueOptionCode<'TOverall, 'T>
|
|
82
|
+
) : ValueTaskValueOptionCode<'TOverall, 'T> =
|
|
83
|
+
|
|
84
|
+
ResumableCode.Combine(
|
|
85
|
+
task1,
|
|
86
|
+
ValueTaskValueOptionCode<'TOverall, 'T>(fun sm ->
|
|
87
|
+
if sm.Data.IsResultNone then true else task2.Invoke(&sm)
|
|
88
|
+
)
|
|
89
|
+
)
|
|
90
|
+
|
|
91
|
+
/// Builds a step that executes the body while the condition predicate is true.
|
|
92
|
+
member inline _.While
|
|
93
|
+
([<InlineIfLambda>] condition: unit -> bool, body: ValueTaskValueOptionCode<'TOverall, unit>) : ValueTaskValueOptionCode<
|
|
94
|
+
'TOverall,
|
|
95
|
+
unit
|
|
96
|
+
>
|
|
97
|
+
=
|
|
98
|
+
let mutable keepGoing = true
|
|
99
|
+
|
|
100
|
+
ResumableCode.While(
|
|
101
|
+
(fun () ->
|
|
102
|
+
keepGoing
|
|
103
|
+
&& condition ()
|
|
104
|
+
),
|
|
105
|
+
ValueTaskValueOptionCode<_, _>(fun sm ->
|
|
106
|
+
if sm.Data.IsResultNone then
|
|
107
|
+
keepGoing <- false
|
|
108
|
+
sm.Data.SetResult()
|
|
109
|
+
true
|
|
110
|
+
else
|
|
111
|
+
body.Invoke(&sm)
|
|
112
|
+
)
|
|
113
|
+
)
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
/// Wraps a step in a try/with. This catches exceptions both in the evaluation of the function
|
|
117
|
+
/// to retrieve the step, and in the continuation of the step (if any).
|
|
118
|
+
member inline _.TryWith
|
|
119
|
+
(
|
|
120
|
+
body: ValueTaskValueOptionCode<'TOverall, 'T>,
|
|
121
|
+
catch: exn -> ValueTaskValueOptionCode<'TOverall, 'T>
|
|
122
|
+
) : ValueTaskValueOptionCode<'TOverall, 'T> =
|
|
123
|
+
ResumableCode.TryWith(body, catch)
|
|
124
|
+
|
|
125
|
+
/// Wraps a step in a try/finally. This catches exceptions both in the evaluation of the function
|
|
126
|
+
/// to retrieve the step, and in the continuation of the step (if any).
|
|
127
|
+
member inline _.TryFinally
|
|
128
|
+
(
|
|
129
|
+
body: ValueTaskValueOptionCode<'TOverall, 'T>,
|
|
130
|
+
[<InlineIfLambda>] compensation: unit -> unit
|
|
131
|
+
) : ValueTaskValueOptionCode<'TOverall, 'T> =
|
|
132
|
+
ResumableCode.TryFinally(
|
|
133
|
+
body,
|
|
134
|
+
ResumableCode<_, _>(fun _sm ->
|
|
135
|
+
compensation ()
|
|
136
|
+
true
|
|
137
|
+
)
|
|
138
|
+
)
|
|
139
|
+
|
|
140
|
+
member inline this.For
|
|
141
|
+
(sequence: seq<'T>, body: 'T -> ValueTaskValueOptionCode<'TOverall, unit>)
|
|
142
|
+
: ValueTaskValueOptionCode<'TOverall, unit> =
|
|
143
|
+
ResumableCode.Using(
|
|
144
|
+
sequence.GetEnumerator(),
|
|
145
|
+
// ... and its body is a while loop that advances the enumerator and runs the body on each element.
|
|
146
|
+
(fun e ->
|
|
147
|
+
this.While(
|
|
148
|
+
(fun () -> e.MoveNext()),
|
|
149
|
+
ValueTaskValueOptionCode<'TOverall, unit>(fun sm ->
|
|
150
|
+
(body e.Current).Invoke(&sm)
|
|
151
|
+
)
|
|
152
|
+
)
|
|
153
|
+
)
|
|
154
|
+
)
|
|
155
|
+
|
|
156
|
+
member inline internal this.TryFinallyAsync
|
|
157
|
+
(body: ValueTaskValueOptionCode<'TOverall, 'T>, compensation: unit -> ValueTask)
|
|
158
|
+
: ValueTaskValueOptionCode<'TOverall, 'T> =
|
|
159
|
+
ResumableCode.TryFinallyAsync(
|
|
160
|
+
body,
|
|
161
|
+
ResumableCode<_, _>(fun sm ->
|
|
162
|
+
if __useResumableCode then
|
|
163
|
+
let mutable __stack_condition_fin = true
|
|
164
|
+
let __stack_vtask = compensation ()
|
|
165
|
+
|
|
166
|
+
if not __stack_vtask.IsCompleted then
|
|
167
|
+
let mutable awaiter = __stack_vtask.GetAwaiter()
|
|
168
|
+
let __stack_yield_fin = ResumableCode.Yield().Invoke(&sm)
|
|
169
|
+
__stack_condition_fin <- __stack_yield_fin
|
|
170
|
+
|
|
171
|
+
if not __stack_condition_fin then
|
|
172
|
+
sm.Data.MethodBuilder.AwaitUnsafeOnCompleted(&awaiter, &sm)
|
|
173
|
+
|
|
174
|
+
__stack_condition_fin
|
|
175
|
+
else
|
|
176
|
+
let vtask = compensation ()
|
|
177
|
+
let mutable awaiter = vtask.GetAwaiter()
|
|
178
|
+
|
|
179
|
+
let cont =
|
|
180
|
+
ValueTaskValueOptionResumptionFunc<'TOverall>(fun sm ->
|
|
181
|
+
awaiter.GetResult()
|
|
182
|
+
|> ignore
|
|
183
|
+
|
|
184
|
+
true
|
|
185
|
+
)
|
|
186
|
+
|
|
187
|
+
// shortcut to continue immediately
|
|
188
|
+
if awaiter.IsCompleted then
|
|
189
|
+
true
|
|
190
|
+
else
|
|
191
|
+
sm.ResumptionDynamicInfo.ResumptionData <-
|
|
192
|
+
(awaiter :> ICriticalNotifyCompletion)
|
|
193
|
+
|
|
194
|
+
sm.ResumptionDynamicInfo.ResumptionFunc <- cont
|
|
195
|
+
false
|
|
196
|
+
)
|
|
197
|
+
)
|
|
198
|
+
|
|
199
|
+
member inline this.Using<'Resource, 'TOverall, 'T when 'Resource :> IAsyncDisposableNull>
|
|
200
|
+
(resource: 'Resource, body: 'Resource -> ValueTaskValueOptionCode<'TOverall, 'T>)
|
|
201
|
+
: ValueTaskValueOptionCode<'TOverall, 'T> =
|
|
202
|
+
this.TryFinallyAsync(
|
|
203
|
+
(fun sm -> (body resource).Invoke(&sm)),
|
|
204
|
+
(fun () ->
|
|
205
|
+
if not (isNull (box resource)) then
|
|
206
|
+
resource.DisposeAsync()
|
|
207
|
+
else
|
|
208
|
+
ValueTask()
|
|
209
|
+
)
|
|
210
|
+
)
|
|
211
|
+
|
|
212
|
+
member inline this.Source
|
|
213
|
+
(valueTaskValueOption: ValueTaskValueOption<'T>)
|
|
214
|
+
: ValueTaskValueOption<'T> =
|
|
215
|
+
valueTaskValueOption
|
|
216
|
+
|
|
217
|
+
type ValueTaskValueOptionBuilder() =
|
|
218
|
+
|
|
219
|
+
inherit ValueTaskValueOptionBuilderBase()
|
|
220
|
+
|
|
221
|
+
// This is the dynamic implementation - this is not used
|
|
222
|
+
// for statically compiled tasks. An executor (resumptionFuncExecutor) is
|
|
223
|
+
// registered with the state machine, plus the initial resumption.
|
|
224
|
+
// The executor stays constant throughout the execution, it wraps each step
|
|
225
|
+
// of the execution in a try/with. The resumption is changed at each step
|
|
226
|
+
// to represent the continuation of the computation.
|
|
227
|
+
static member RunDynamic(code: ValueTaskValueOptionCode<'T, 'T>) : ValueTaskValueOption<'T> =
|
|
228
|
+
let mutable sm = ValueTaskValueOptionStateMachine<'T>()
|
|
229
|
+
|
|
230
|
+
let initialResumptionFunc =
|
|
231
|
+
ValueTaskValueOptionResumptionFunc<'T>(fun sm -> code.Invoke(&sm))
|
|
232
|
+
|
|
233
|
+
let resumptionInfo =
|
|
234
|
+
{ new ValueTaskValueOptionResumptionDynamicInfo<_>(initialResumptionFunc) with
|
|
235
|
+
member info.MoveNext(sm) =
|
|
236
|
+
let mutable savedExn = null
|
|
237
|
+
|
|
238
|
+
try
|
|
239
|
+
sm.ResumptionDynamicInfo.ResumptionData <- null
|
|
240
|
+
let step = info.ResumptionFunc.Invoke(&sm)
|
|
241
|
+
|
|
242
|
+
// If the `sm.Data.MethodBuilder` has already been set somewhere else (like While/WhileDynamic), we shouldn't continue
|
|
243
|
+
if sm.Data.IsTaskCompleted then
|
|
244
|
+
()
|
|
245
|
+
|
|
246
|
+
if step then
|
|
247
|
+
sm.Data.SetResult()
|
|
248
|
+
else
|
|
249
|
+
match sm.ResumptionDynamicInfo.ResumptionData with
|
|
250
|
+
| :? ICriticalNotifyCompletion as awaiter ->
|
|
251
|
+
let mutable awaiter = awaiter
|
|
252
|
+
sm.Data.MethodBuilder.AwaitUnsafeOnCompleted(&awaiter, &sm)
|
|
253
|
+
| awaiter -> assert not (isNull awaiter)
|
|
254
|
+
|
|
255
|
+
with exn ->
|
|
256
|
+
savedExn <- exn
|
|
257
|
+
// Run SetException outside the stack unwind, see https://github.com/dotnet/roslyn/issues/26567
|
|
258
|
+
match savedExn with
|
|
259
|
+
| null -> ()
|
|
260
|
+
| exn -> sm.Data.MethodBuilder.SetException exn
|
|
261
|
+
|
|
262
|
+
member _.SetStateMachine(sm, state) =
|
|
263
|
+
sm.Data.MethodBuilder.SetStateMachine(state)
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
sm.ResumptionDynamicInfo <- resumptionInfo
|
|
267
|
+
sm.Data.MethodBuilder <- AsyncValueTaskValueOptionMethodBuilder<'T>.Create()
|
|
268
|
+
sm.Data.MethodBuilder.Start(&sm)
|
|
269
|
+
sm.Data.MethodBuilder.Task
|
|
270
|
+
|
|
271
|
+
member inline _.Run(code: ValueTaskValueOptionCode<'T, 'T>) : ValueTaskValueOption<'T> =
|
|
272
|
+
if __useResumableCode then
|
|
273
|
+
__stateMachine<ValueTaskValueOptionStateMachineData<'T>, ValueTaskValueOption<'T>>
|
|
274
|
+
(MoveNextMethodImpl<_>(fun sm ->
|
|
275
|
+
//-- RESUMABLE CODE START
|
|
276
|
+
__resumeAt sm.ResumptionPoint
|
|
277
|
+
let mutable __stack_exn: ExceptionNull = null
|
|
278
|
+
|
|
279
|
+
try
|
|
280
|
+
let __stack_code_fin = code.Invoke(&sm)
|
|
281
|
+
|
|
282
|
+
if
|
|
283
|
+
__stack_code_fin
|
|
284
|
+
&& not sm.Data.IsTaskCompleted
|
|
285
|
+
then
|
|
286
|
+
sm.Data.SetResult()
|
|
287
|
+
with exn ->
|
|
288
|
+
__stack_exn <- exn
|
|
289
|
+
// Run SetException outside the stack unwind, see https://github.com/dotnet/roslyn/issues/26567
|
|
290
|
+
match __stack_exn with
|
|
291
|
+
| null -> ()
|
|
292
|
+
| exn -> sm.Data.MethodBuilder.SetException exn
|
|
293
|
+
//-- RESUMABLE CODE END
|
|
294
|
+
))
|
|
295
|
+
(SetStateMachineMethodImpl<_>(fun sm state ->
|
|
296
|
+
sm.Data.MethodBuilder.SetStateMachine(state)
|
|
297
|
+
))
|
|
298
|
+
(AfterCode<_, _>(fun sm ->
|
|
299
|
+
sm.Data.MethodBuilder <- AsyncValueTaskValueOptionMethodBuilder<'T>.Create()
|
|
300
|
+
sm.Data.MethodBuilder.Start(&sm)
|
|
301
|
+
sm.Data.MethodBuilder.Task
|
|
302
|
+
))
|
|
303
|
+
else
|
|
304
|
+
ValueTaskValueOptionBuilder.RunDynamic(code)
|
|
305
|
+
|
|
306
|
+
[<AutoOpen>]
|
|
307
|
+
module ValueTaskValueOptionBuilder =
|
|
308
|
+
|
|
309
|
+
/// <summary>
|
|
310
|
+
/// Builds a <c>ValueTask<'T voption></c> using the computation expression syntax.
|
|
311
|
+
/// </summary>
|
|
312
|
+
let valueTaskValueOption = ValueTaskValueOptionBuilder()
|
|
313
|
+
|
|
314
|
+
|
|
315
|
+
open Microsoft.FSharp.Control
|
|
316
|
+
open System
|
|
317
|
+
open System.Runtime.CompilerServices
|
|
318
|
+
open System.Threading.Tasks
|
|
319
|
+
open Microsoft.FSharp.Core
|
|
320
|
+
open Microsoft.FSharp.Core.CompilerServices
|
|
321
|
+
open Microsoft.FSharp.Core.CompilerServices.StateMachineHelpers
|
|
322
|
+
open Microsoft.FSharp.Core.LanguagePrimitives.IntrinsicOperators
|
|
323
|
+
|
|
324
|
+
[<AutoOpen>]
|
|
325
|
+
module ValueTaskValueOptionCEExtensionsLowPriority =
|
|
326
|
+
// Low priority extensions
|
|
327
|
+
type ValueTaskValueOptionBuilderBase with
|
|
328
|
+
|
|
329
|
+
[<NoEagerConstraintApplication>]
|
|
330
|
+
static member inline BindDynamic< ^TaskLike, 'TResult1, 'TResult2, ^Awaiter, 'TOverall
|
|
331
|
+
when ^TaskLike: (member GetAwaiter: unit -> ^Awaiter)
|
|
332
|
+
and ^Awaiter :> ICriticalNotifyCompletion
|
|
333
|
+
and ^Awaiter: (member get_IsCompleted: unit -> bool)
|
|
334
|
+
and ^Awaiter: (member GetResult: unit -> 'TResult1 voption)>
|
|
335
|
+
(
|
|
336
|
+
sm: byref<_>,
|
|
337
|
+
task: ^TaskLike,
|
|
338
|
+
continuation: ('TResult1 -> ValueTaskValueOptionCode<'TOverall, 'TResult2>)
|
|
339
|
+
) : bool =
|
|
340
|
+
|
|
341
|
+
let mutable awaiter = (^TaskLike: (member GetAwaiter: unit -> ^Awaiter) (task))
|
|
342
|
+
|
|
343
|
+
let cont =
|
|
344
|
+
(ValueTaskValueOptionResumptionFunc<'TOverall>(fun sm ->
|
|
345
|
+
let result =
|
|
346
|
+
(^Awaiter: (member GetResult: unit -> 'TResult1 voption) (awaiter))
|
|
347
|
+
|
|
348
|
+
match result with
|
|
349
|
+
| ValueSome result -> (continuation result).Invoke(&sm)
|
|
350
|
+
| ValueNone ->
|
|
351
|
+
sm.Data.Result <- ValueSome ValueNone
|
|
352
|
+
true
|
|
353
|
+
))
|
|
354
|
+
|
|
355
|
+
// shortcut to continue immediately
|
|
356
|
+
if (^Awaiter: (member get_IsCompleted: unit -> bool) (awaiter)) then
|
|
357
|
+
cont.Invoke(&sm)
|
|
358
|
+
else
|
|
359
|
+
sm.ResumptionDynamicInfo.ResumptionData <- (awaiter :> ICriticalNotifyCompletion)
|
|
360
|
+
sm.ResumptionDynamicInfo.ResumptionFunc <- cont
|
|
361
|
+
false
|
|
362
|
+
|
|
363
|
+
[<NoEagerConstraintApplication>]
|
|
364
|
+
member inline _.Bind< ^TaskLike, 'TResult1, 'TResult2, ^Awaiter, 'TOverall
|
|
365
|
+
when ^TaskLike: (member GetAwaiter: unit -> ^Awaiter)
|
|
366
|
+
and ^Awaiter :> ICriticalNotifyCompletion
|
|
367
|
+
and ^Awaiter: (member get_IsCompleted: unit -> bool)
|
|
368
|
+
and ^Awaiter: (member GetResult: unit -> 'TResult1 voption)>
|
|
369
|
+
(
|
|
370
|
+
task: ^TaskLike,
|
|
371
|
+
continuation: ('TResult1 -> ValueTaskValueOptionCode<'TOverall, 'TResult2>)
|
|
372
|
+
) : ValueTaskValueOptionCode<'TOverall, 'TResult2> =
|
|
373
|
+
|
|
374
|
+
ValueTaskValueOptionCode<'TOverall, _>(fun sm ->
|
|
375
|
+
if __useResumableCode then
|
|
376
|
+
//-- RESUMABLE CODE START
|
|
377
|
+
// Get an awaiter from the awaitable
|
|
378
|
+
let mutable awaiter = (^TaskLike: (member GetAwaiter: unit -> ^Awaiter) (task))
|
|
379
|
+
|
|
380
|
+
let mutable __stack_fin = true
|
|
381
|
+
|
|
382
|
+
if not (^Awaiter: (member get_IsCompleted: unit -> bool) (awaiter)) then
|
|
383
|
+
// This will yield with __stack_yield_fin = false
|
|
384
|
+
// This will resume with __stack_yield_fin = true
|
|
385
|
+
let __stack_yield_fin = ResumableCode.Yield().Invoke(&sm)
|
|
386
|
+
__stack_fin <- __stack_yield_fin
|
|
387
|
+
|
|
388
|
+
if __stack_fin then
|
|
389
|
+
let result =
|
|
390
|
+
(^Awaiter: (member GetResult: unit -> 'TResult1 voption) (awaiter))
|
|
391
|
+
|
|
392
|
+
match result with
|
|
393
|
+
| ValueSome result -> (continuation result).Invoke(&sm)
|
|
394
|
+
| ValueNone ->
|
|
395
|
+
sm.Data.Result <- ValueSome ValueNone
|
|
396
|
+
true
|
|
397
|
+
else
|
|
398
|
+
sm.Data.MethodBuilder.AwaitUnsafeOnCompleted(&awaiter, &sm)
|
|
399
|
+
false
|
|
400
|
+
else
|
|
401
|
+
ValueTaskValueOptionBuilderBase.BindDynamic<
|
|
402
|
+
^TaskLike,
|
|
403
|
+
'TResult1,
|
|
404
|
+
'TResult2,
|
|
405
|
+
^Awaiter,
|
|
406
|
+
'TOverall
|
|
407
|
+
>(
|
|
408
|
+
&sm,
|
|
409
|
+
task,
|
|
410
|
+
continuation
|
|
411
|
+
)
|
|
412
|
+
//-- RESUMABLE CODE END
|
|
413
|
+
)
|
|
414
|
+
|
|
415
|
+
[<NoEagerConstraintApplication>]
|
|
416
|
+
member inline this.ReturnFrom< ^TaskLike, ^Awaiter, 'T
|
|
417
|
+
when ^TaskLike: (member GetAwaiter: unit -> ^Awaiter)
|
|
418
|
+
and ^Awaiter :> ICriticalNotifyCompletion
|
|
419
|
+
and ^Awaiter: (member get_IsCompleted: unit -> bool)
|
|
420
|
+
and ^Awaiter: (member GetResult: unit -> 'T voption)>
|
|
421
|
+
(task: ^TaskLike)
|
|
422
|
+
: ValueTaskValueOptionCode<'T, 'T> =
|
|
423
|
+
|
|
424
|
+
this.Bind(task, (fun v -> this.Return v))
|
|
425
|
+
|
|
426
|
+
[<NoEagerConstraintApplication>]
|
|
427
|
+
member inline this.Source< ^TaskLike, ^Awaiter, 'T
|
|
428
|
+
when ^TaskLike: (member GetAwaiter: unit -> ^Awaiter)
|
|
429
|
+
and ^Awaiter :> ICriticalNotifyCompletion
|
|
430
|
+
and ^Awaiter: (member get_IsCompleted: unit -> bool)
|
|
431
|
+
and ^Awaiter: (member GetResult: unit -> 'T)>
|
|
432
|
+
(t: ^TaskLike)
|
|
433
|
+
: ValueTaskValueOption<'T> =
|
|
434
|
+
|
|
435
|
+
ValueTask<'T voption>(
|
|
436
|
+
task {
|
|
437
|
+
let! r = t
|
|
438
|
+
return ValueSome r
|
|
439
|
+
}
|
|
440
|
+
)
|
|
441
|
+
|
|
442
|
+
member inline _.Using<'Resource, 'TOverall, 'T when 'Resource :> IDisposableNull>
|
|
443
|
+
(resource: 'Resource, body: 'Resource -> ValueTaskValueOptionCode<'TOverall, 'T>)
|
|
444
|
+
=
|
|
445
|
+
ResumableCode.Using(resource, body)
|
|
446
|
+
|
|
447
|
+
[<AutoOpen>]
|
|
448
|
+
module ValueTaskValueOptionCEExtensionsHighPriority =
|
|
449
|
+
// High priority extensions
|
|
450
|
+
type ValueTaskValueOptionBuilderBase with
|
|
451
|
+
|
|
452
|
+
static member BindDynamic
|
|
453
|
+
(
|
|
454
|
+
sm: byref<_>,
|
|
455
|
+
task: ValueTaskValueOption<'TResult1>,
|
|
456
|
+
continuation: ('TResult1 -> ValueTaskValueOptionCode<'TOverall, 'TResult2>)
|
|
457
|
+
) : bool =
|
|
458
|
+
let mutable awaiter = task.GetAwaiter()
|
|
459
|
+
|
|
460
|
+
let cont =
|
|
461
|
+
(ValueTaskValueOptionResumptionFunc<'TOverall>(fun sm ->
|
|
462
|
+
let result = awaiter.GetResult()
|
|
463
|
+
|
|
464
|
+
match result with
|
|
465
|
+
| ValueSome result -> (continuation result).Invoke(&sm)
|
|
466
|
+
| ValueNone ->
|
|
467
|
+
sm.Data.Result <- ValueSome ValueNone
|
|
468
|
+
true
|
|
469
|
+
))
|
|
470
|
+
|
|
471
|
+
// shortcut to continue immediately
|
|
472
|
+
if awaiter.IsCompleted then
|
|
473
|
+
cont.Invoke(&sm)
|
|
474
|
+
else
|
|
475
|
+
sm.ResumptionDynamicInfo.ResumptionData <- (awaiter :> ICriticalNotifyCompletion)
|
|
476
|
+
sm.ResumptionDynamicInfo.ResumptionFunc <- cont
|
|
477
|
+
false
|
|
478
|
+
|
|
479
|
+
member inline _.Bind
|
|
480
|
+
(
|
|
481
|
+
task: ValueTaskValueOption<'TResult1>,
|
|
482
|
+
continuation: ('TResult1 -> ValueTaskValueOptionCode<'TOverall, 'TResult2>)
|
|
483
|
+
) : ValueTaskValueOptionCode<'TOverall, 'TResult2> =
|
|
484
|
+
|
|
485
|
+
ValueTaskValueOptionCode<'TOverall, _>(fun sm ->
|
|
486
|
+
if __useResumableCode then
|
|
487
|
+
//-- RESUMABLE CODE START
|
|
488
|
+
// Get an awaiter from the task
|
|
489
|
+
let mutable awaiter = task.GetAwaiter()
|
|
490
|
+
|
|
491
|
+
let mutable __stack_fin = true
|
|
492
|
+
|
|
493
|
+
if not awaiter.IsCompleted then
|
|
494
|
+
// This will yield with __stack_yield_fin = false
|
|
495
|
+
// This will resume with __stack_yield_fin = true
|
|
496
|
+
let __stack_yield_fin = ResumableCode.Yield().Invoke(&sm)
|
|
497
|
+
__stack_fin <- __stack_yield_fin
|
|
498
|
+
|
|
499
|
+
if __stack_fin then
|
|
500
|
+
let result = awaiter.GetResult()
|
|
501
|
+
|
|
502
|
+
match result with
|
|
503
|
+
| ValueSome result -> (continuation result).Invoke(&sm)
|
|
504
|
+
| ValueNone ->
|
|
505
|
+
sm.Data.Result <- ValueSome ValueNone
|
|
506
|
+
true
|
|
507
|
+
|
|
508
|
+
else
|
|
509
|
+
sm.Data.MethodBuilder.AwaitUnsafeOnCompleted(&awaiter, &sm)
|
|
510
|
+
false
|
|
511
|
+
|
|
512
|
+
else
|
|
513
|
+
ValueTaskValueOptionBuilderBase.BindDynamic(&sm, task, continuation)
|
|
514
|
+
//-- RESUMABLE CODE END
|
|
515
|
+
)
|
|
516
|
+
|
|
517
|
+
member inline this.BindReturn(x: ValueTaskValueOption<'T>, [<InlineIfLambda>] f) =
|
|
518
|
+
this.Bind(x, (fun x -> this.Return(f x)))
|
|
519
|
+
|
|
520
|
+
member inline _.MergeSources(t1: ValueTaskValueOption<'T>, t2: ValueTaskValueOption<'T1>) =
|
|
521
|
+
ValueTaskValueOption.zip t1 t2
|
|
522
|
+
|
|
523
|
+
member inline this.ReturnFrom
|
|
524
|
+
(task: ValueTaskValueOption<'T>)
|
|
525
|
+
: ValueTaskValueOptionCode<'T, 'T> =
|
|
526
|
+
this.Bind(task, (fun v -> this.Return v))
|
|
527
|
+
|
|
528
|
+
member inline _.Source(s: #seq<_>) = s
|
|
529
|
+
|
|
530
|
+
[<AutoOpen>]
|
|
531
|
+
module ValueTaskValueOptionCEExtensionsMediumPriority =
|
|
532
|
+
|
|
533
|
+
// Medium priority extensions
|
|
534
|
+
type ValueTaskValueOptionBuilderBase with
|
|
535
|
+
|
|
536
|
+
member inline this.Source(t: Task<'T>) : ValueTaskValueOption<'T> =
|
|
537
|
+
ValueTask<'T voption>(Task.map ValueSome t)
|
|
538
|
+
|
|
539
|
+
member inline this.Source(t: Task) : ValueTaskValueOption<unit> =
|
|
540
|
+
ValueTask<unit voption>(
|
|
541
|
+
task {
|
|
542
|
+
do! t
|
|
543
|
+
return ValueSome()
|
|
544
|
+
}
|
|
545
|
+
)
|
|
546
|
+
|
|
547
|
+
member inline this.Source(t: ValueTask<'T>) : ValueTaskValueOption<'T> =
|
|
548
|
+
ValueTask<'T voption>(
|
|
549
|
+
task {
|
|
550
|
+
let! r = t
|
|
551
|
+
return ValueSome r
|
|
552
|
+
}
|
|
553
|
+
)
|
|
554
|
+
|
|
555
|
+
member inline this.Source(t: ValueTask) : ValueTaskValueOption<unit> =
|
|
556
|
+
ValueTask<unit voption>(
|
|
557
|
+
task {
|
|
558
|
+
do! t
|
|
559
|
+
return ValueSome()
|
|
560
|
+
}
|
|
561
|
+
)
|
|
562
|
+
|
|
563
|
+
member inline this.Source(opt: 'T voption) : ValueTaskValueOption<'T> =
|
|
564
|
+
ValueTask<'T voption>(opt)
|
|
565
|
+
|
|
566
|
+
member inline this.Source(computation: Async<'T>) : ValueTaskValueOption<'T> =
|
|
567
|
+
ValueTask<'T voption>(
|
|
568
|
+
computation
|
|
569
|
+
|> Async.map ValueSome
|
|
570
|
+
|> Async.StartImmediateAsTask
|
|
571
|
+
)
|
|
572
|
+
|
|
573
|
+
|
|
574
|
+
[<AutoOpen>]
|
|
575
|
+
module ValueTaskValueOptionCEExtensionsHighPriority2 =
|
|
576
|
+
|
|
577
|
+
// High priority extensions 2
|
|
578
|
+
type ValueTaskValueOptionBuilderBase with
|
|
579
|
+
|
|
580
|
+
member inline this.Source(computation: Async<'T voption>) : ValueTaskValueOption<'T> =
|
|
581
|
+
ValueTask<'T voption>(
|
|
582
|
+
computation
|
|
583
|
+
|> Async.StartImmediateAsTask
|
|
584
|
+
)
|
|
585
|
+
|
|
586
|
+
member inline this.Source(taskValueOption: Task<'T voption>) : ValueTaskValueOption<'T> =
|
|
587
|
+
ValueTask<'T voption>(taskValueOption)
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
namespace FsToolkit.ErrorHandling.Operator.ValueTaskValueOption
|
|
2
|
+
|
|
3
|
+
open FsToolkit.ErrorHandling
|
|
4
|
+
|
|
5
|
+
[<AutoOpen>]
|
|
6
|
+
module ValueTaskValueOption =
|
|
7
|
+
|
|
8
|
+
let inline (<!>) ([<InlineIfLambda>] f) x = ValueTaskValueOption.map f x
|
|
9
|
+
let inline (<*>) f x = ValueTaskValueOption.apply f x
|
|
10
|
+
let inline (>>=) x ([<InlineIfLambda>] f) = ValueTaskValueOption.bind f x
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// <auto-generated>
|
|
2
|
+
// Generated by the FSharp WriteCodeFragment class.
|
|
3
|
+
// </auto-generated>
|
|
4
|
+
namespace FSharp
|
|
5
|
+
|
|
6
|
+
open System
|
|
7
|
+
open System.Reflection
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
[<assembly: System.Reflection.AssemblyCompanyAttribute("demystifyfp, TheAngryByrd")>]
|
|
11
|
+
[<assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")>]
|
|
12
|
+
[<assembly: System.Reflection.AssemblyCopyrightAttribute("Copyright © 2018-24")>]
|
|
13
|
+
[<assembly: System.Reflection.AssemblyDescriptionAttribute("FsToolkit.ErrorHandling is an extensive utility library based around the F# Result type, enabling consistent and powerful error handling.")>]
|
|
14
|
+
[<assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")>]
|
|
15
|
+
[<assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+eb57861f9f3f657d2c972313ef3ea843448fd5e4")>]
|
|
16
|
+
[<assembly: System.Reflection.AssemblyProductAttribute("FsToolkit.ErrorHandling")>]
|
|
17
|
+
[<assembly: System.Reflection.AssemblyTitleAttribute("FsToolkit.ErrorHandling")>]
|
|
18
|
+
[<assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")>]
|
|
19
|
+
[<assembly: System.Reflection.AssemblyMetadataAttribute("RepositoryUrl", "https://github.com/demystifyfp/FsToolkit.ErrorHandling.git")>]
|
|
20
|
+
do()
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// <auto-generated>
|
|
2
|
+
// Generated by the FSharp WriteCodeFragment class.
|
|
3
|
+
// </auto-generated>
|
|
4
|
+
namespace FSharp
|
|
5
|
+
|
|
6
|
+
open System
|
|
7
|
+
open System.Reflection
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
[<assembly: System.Reflection.AssemblyCompanyAttribute("demystifyfp, TheAngryByrd")>]
|
|
11
|
+
[<assembly: System.Reflection.AssemblyConfigurationAttribute("Release")>]
|
|
12
|
+
[<assembly: System.Reflection.AssemblyCopyrightAttribute("Copyright © 2018-24")>]
|
|
13
|
+
[<assembly: System.Reflection.AssemblyDescriptionAttribute("FsToolkit.ErrorHandling is an extensive utility library based around the F# Result type, enabling consistent and powerful error handling.")>]
|
|
14
|
+
[<assembly: System.Reflection.AssemblyFileVersionAttribute("5.2.0.0")>]
|
|
15
|
+
[<assembly: System.Reflection.AssemblyInformationalVersionAttribute("5.2.0+eb57861f9f3f657d2c972313ef3ea843448fd5e4")>]
|
|
16
|
+
[<assembly: System.Reflection.AssemblyProductAttribute("FsToolkit.ErrorHandling")>]
|
|
17
|
+
[<assembly: System.Reflection.AssemblyTitleAttribute("FsToolkit.ErrorHandling")>]
|
|
18
|
+
[<assembly: System.Reflection.AssemblyVersionAttribute("5.2.0.0")>]
|
|
19
|
+
[<assembly: System.Reflection.AssemblyMetadataAttribute("RepositoryUrl", "https://github.com/demystifyfp/FsToolkit.ErrorHandling.git")>]
|
|
20
|
+
do()
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// <auto-generated>
|
|
2
|
+
// Generated by the FSharp WriteCodeFragment class.
|
|
3
|
+
// </auto-generated>
|
|
4
|
+
namespace FSharp
|
|
5
|
+
|
|
6
|
+
open System
|
|
7
|
+
open System.Reflection
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
[<assembly: System.Reflection.AssemblyCompanyAttribute("demystifyfp, TheAngryByrd")>]
|
|
11
|
+
[<assembly: System.Reflection.AssemblyConfigurationAttribute("Release")>]
|
|
12
|
+
[<assembly: System.Reflection.AssemblyCopyrightAttribute("Copyright © 2018-24")>]
|
|
13
|
+
[<assembly: System.Reflection.AssemblyDescriptionAttribute("FsToolkit.ErrorHandling is an extensive utility library based around the F# Result type, enabling consistent and powerful error handling.")>]
|
|
14
|
+
[<assembly: System.Reflection.AssemblyFileVersionAttribute("5.2.0.0")>]
|
|
15
|
+
[<assembly: System.Reflection.AssemblyInformationalVersionAttribute("5.2.0+eb57861f9f3f657d2c972313ef3ea843448fd5e4")>]
|
|
16
|
+
[<assembly: System.Reflection.AssemblyProductAttribute("FsToolkit.ErrorHandling")>]
|
|
17
|
+
[<assembly: System.Reflection.AssemblyTitleAttribute("FsToolkit.ErrorHandling")>]
|
|
18
|
+
[<assembly: System.Reflection.AssemblyVersionAttribute("5.2.0.0")>]
|
|
19
|
+
[<assembly: System.Reflection.AssemblyMetadataAttribute("RepositoryUrl", "https://github.com/demystifyfp/FsToolkit.ErrorHandling.git")>]
|
|
20
|
+
do()
|