@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.
Files changed (144) hide show
  1. package/dist/fable_modules/Fable.Promise.3.2.1/AsyncIterable.fs +89 -0
  2. package/dist/fable_modules/Fable.Promise.3.2.1/AsyncIterable.fs.js +105 -0
  3. package/dist/fable_modules/Fable.Promise.3.2.1/Fable.Promise.fableproj +25 -0
  4. package/dist/fable_modules/Fable.Promise.3.2.1/Promise.fs +842 -0
  5. package/dist/fable_modules/Fable.Promise.3.2.1/Promise.fs.js +232 -0
  6. package/dist/fable_modules/Fable.Promise.3.2.1/PromiseImpl.fs +31 -0
  7. package/dist/fable_modules/Fable.Promise.3.2.1/PromiseImpl.fs.js +20 -0
  8. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Array.fs +235 -0
  9. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Array.fs.js +384 -0
  10. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AssemblyInfo.fs +19 -0
  11. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Async.fs +287 -0
  12. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Async.fs.js +128 -0
  13. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncOption.fs +127 -0
  14. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncOptionCE.fs +174 -0
  15. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncOptionCE.fs.js +37 -0
  16. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncOptionOp.fs +24 -0
  17. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncResult.fs +483 -0
  18. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncResultCE.fs +201 -0
  19. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncResultCE.fs.js +18 -0
  20. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncResultOp.fs +24 -0
  21. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncResultOption.fs +87 -0
  22. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncResultOption.fs.js +26 -0
  23. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncResultOptionCE.fs +236 -0
  24. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncResultOptionCE.fs.js +18 -0
  25. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncResultOptionOp.fs +24 -0
  26. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncValidation.fs +185 -0
  27. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncValidationCE.fs +186 -0
  28. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncValidationCE.fs.js +18 -0
  29. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncValidationOp.fs +35 -0
  30. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/FsToolkit.ErrorHandling.fableproj +69 -0
  31. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/List.fs +276 -0
  32. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/List.fs.js +364 -0
  33. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Nullness.fs +81 -0
  34. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Option.fs +462 -0
  35. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/OptionCE.fs +139 -0
  36. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/OptionCE.fs.js +48 -0
  37. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/OptionOp.fs +21 -0
  38. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ParallelAsyncResult.fs +88 -0
  39. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ParallelAsyncResult.fs.js +30 -0
  40. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ParallelAsyncResultCE.fs +200 -0
  41. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ParallelAsyncResultCE.fs.js +18 -0
  42. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ParallelAsyncValidation.fs +34 -0
  43. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ParallelAsyncValidationCE.fs +244 -0
  44. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ParallelAsyncValidationCE.fs.js +18 -0
  45. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Result.fs +731 -0
  46. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Result.fs.js +45 -0
  47. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ResultCE.fs +140 -0
  48. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ResultCE.fs.js +23 -0
  49. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ResultOp.fs +45 -0
  50. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ResultOption.fs +201 -0
  51. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ResultOption.fs.js +65 -0
  52. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ResultOptionCE.fs +135 -0
  53. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ResultOptionCE.fs.js +18 -0
  54. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ResultOptionOp.fs +57 -0
  55. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Seq.fs +503 -0
  56. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Seq.fs.js +295 -0
  57. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Validation.fs +167 -0
  58. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ValidationCE.fs +142 -0
  59. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ValidationCE.fs.js +18 -0
  60. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ValidationOp.fs +35 -0
  61. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ValueOption.fs +148 -0
  62. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ValueTaskValueOption.fs +102 -0
  63. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ValueTaskValueOptionCE.fs +587 -0
  64. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ValueTaskValueOptionOp.fs +10 -0
  65. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/obj/Debug/netstandard2.1/.NETStandard,Version=v2.1.AssemblyAttributes.fs +3 -0
  66. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/obj/Debug/netstandard2.1/FsToolkit.ErrorHandling.AssemblyInfo.fs +20 -0
  67. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/obj/Release/net9.0/.NETCoreApp,Version=v9.0.AssemblyAttributes.fs +3 -0
  68. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/obj/Release/net9.0/FsToolkit.ErrorHandling.AssemblyInfo.fs +20 -0
  69. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/obj/Release/netstandard2.0/.NETStandard,Version=v2.0.AssemblyAttributes.fs +3 -0
  70. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/obj/Release/netstandard2.0/FsToolkit.ErrorHandling.AssemblyInfo.fs +20 -0
  71. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/obj/Release/netstandard2.1/.NETStandard,Version=v2.1.AssemblyAttributes.fs +3 -0
  72. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/obj/Release/netstandard2.1/FsToolkit.ErrorHandling.AssemblyInfo.fs +20 -0
  73. package/dist/fable_modules/fable-library-js.5.17.2/Array.js +1348 -0
  74. package/dist/fable_modules/fable-library-js.5.17.2/Async.js +163 -0
  75. package/dist/fable_modules/fable-library-js.5.17.2/AsyncBuilder.js +204 -0
  76. package/dist/fable_modules/fable-library-js.5.17.2/BigInt.js +307 -0
  77. package/dist/fable_modules/fable-library-js.5.17.2/BitConverter.js +138 -0
  78. package/dist/fable_modules/fable-library-js.5.17.2/Boolean.js +22 -0
  79. package/dist/fable_modules/fable-library-js.5.17.2/CHANGELOG.md +348 -0
  80. package/dist/fable_modules/fable-library-js.5.17.2/Char.js +202 -0
  81. package/dist/fable_modules/fable-library-js.5.17.2/Choice.js +184 -0
  82. package/dist/fable_modules/fable-library-js.5.17.2/CollectionUtil.js +182 -0
  83. package/dist/fable_modules/fable-library-js.5.17.2/ConditionalWeakTable.js +21 -0
  84. package/dist/fable_modules/fable-library-js.5.17.2/Date.js +834 -0
  85. package/dist/fable_modules/fable-library-js.5.17.2/DateOffset.js +252 -0
  86. package/dist/fable_modules/fable-library-js.5.17.2/DateOnly.js +124 -0
  87. package/dist/fable_modules/fable-library-js.5.17.2/DateOnlyTemporal.js +146 -0
  88. package/dist/fable_modules/fable-library-js.5.17.2/DateTimeFormat.js +523 -0
  89. package/dist/fable_modules/fable-library-js.5.17.2/DateTimeOffsetTemporal.js +283 -0
  90. package/dist/fable_modules/fable-library-js.5.17.2/DateTimeTemporal.js +243 -0
  91. package/dist/fable_modules/fable-library-js.5.17.2/Decimal.js +238 -0
  92. package/dist/fable_modules/fable-library-js.5.17.2/Directory.js +11 -0
  93. package/dist/fable_modules/fable-library-js.5.17.2/Double.js +53 -0
  94. package/dist/fable_modules/fable-library-js.5.17.2/Encoding.js +185 -0
  95. package/dist/fable_modules/fable-library-js.5.17.2/Environment.js +3 -0
  96. package/dist/fable_modules/fable-library-js.5.17.2/Event.js +102 -0
  97. package/dist/fable_modules/fable-library-js.5.17.2/FSharp.Collections.js +45 -0
  98. package/dist/fable_modules/fable-library-js.5.17.2/FSharp.Core.CompilerServices.js +27 -0
  99. package/dist/fable_modules/fable-library-js.5.17.2/FSharp.Core.js +156 -0
  100. package/dist/fable_modules/fable-library-js.5.17.2/File.js +27 -0
  101. package/dist/fable_modules/fable-library-js.5.17.2/Global.js +29 -0
  102. package/dist/fable_modules/fable-library-js.5.17.2/Guid.js +163 -0
  103. package/dist/fable_modules/fable-library-js.5.17.2/Int32.js +135 -0
  104. package/dist/fable_modules/fable-library-js.5.17.2/List.js +1337 -0
  105. package/dist/fable_modules/fable-library-js.5.17.2/Long.js +38 -0
  106. package/dist/fable_modules/fable-library-js.5.17.2/MailboxProcessor.js +100 -0
  107. package/dist/fable_modules/fable-library-js.5.17.2/Map.js +1400 -0
  108. package/dist/fable_modules/fable-library-js.5.17.2/MapUtil.js +130 -0
  109. package/dist/fable_modules/fable-library-js.5.17.2/MutableMap.js +339 -0
  110. package/dist/fable_modules/fable-library-js.5.17.2/MutableSet.js +233 -0
  111. package/dist/fable_modules/fable-library-js.5.17.2/Native.js +14 -0
  112. package/dist/fable_modules/fable-library-js.5.17.2/Numeric.js +112 -0
  113. package/dist/fable_modules/fable-library-js.5.17.2/Observable.js +115 -0
  114. package/dist/fable_modules/fable-library-js.5.17.2/Option.js +87 -0
  115. package/dist/fable_modules/fable-library-js.5.17.2/Path.js +31 -0
  116. package/dist/fable_modules/fable-library-js.5.17.2/README.md +3 -0
  117. package/dist/fable_modules/fable-library-js.5.17.2/Random.js +172 -0
  118. package/dist/fable_modules/fable-library-js.5.17.2/Range.js +45 -0
  119. package/dist/fable_modules/fable-library-js.5.17.2/Reflection.js +489 -0
  120. package/dist/fable_modules/fable-library-js.5.17.2/RegExp.js +170 -0
  121. package/dist/fable_modules/fable-library-js.5.17.2/Result.js +165 -0
  122. package/dist/fable_modules/fable-library-js.5.17.2/Seq.js +1504 -0
  123. package/dist/fable_modules/fable-library-js.5.17.2/Seq2.js +111 -0
  124. package/dist/fable_modules/fable-library-js.5.17.2/Set.js +1829 -0
  125. package/dist/fable_modules/fable-library-js.5.17.2/String.js +731 -0
  126. package/dist/fable_modules/fable-library-js.5.17.2/System.Collections.Generic.js +333 -0
  127. package/dist/fable_modules/fable-library-js.5.17.2/System.Text.js +200 -0
  128. package/dist/fable_modules/fable-library-js.5.17.2/System.js +289 -0
  129. package/dist/fable_modules/fable-library-js.5.17.2/Task.js +27 -0
  130. package/dist/fable_modules/fable-library-js.5.17.2/TaskBuilder.js +72 -0
  131. package/dist/fable_modules/fable-library-js.5.17.2/TimeOnly.js +122 -0
  132. package/dist/fable_modules/fable-library-js.5.17.2/TimeOnlyTemporal.js +142 -0
  133. package/dist/fable_modules/fable-library-js.5.17.2/TimeSpan.js +180 -0
  134. package/dist/fable_modules/fable-library-js.5.17.2/TimeSpanTemporal.js +259 -0
  135. package/dist/fable_modules/fable-library-js.5.17.2/Timer.js +67 -0
  136. package/dist/fable_modules/fable-library-js.5.17.2/Types.js +198 -0
  137. package/dist/fable_modules/fable-library-js.5.17.2/Unicode.13.0.0.js +4 -0
  138. package/dist/fable_modules/fable-library-js.5.17.2/Uri.js +165 -0
  139. package/dist/fable_modules/fable-library-js.5.17.2/Util.js +807 -0
  140. package/dist/fable_modules/fable-library-js.5.17.2/big.d.ts +338 -0
  141. package/dist/fable_modules/fable-library-js.5.17.2/lib/big.js +829 -0
  142. package/dist/fable_modules/fable-library-js.5.17.2/package.json +24 -0
  143. package/dist/fable_modules/fable-library-js.5.17.2/quotation.js +682 -0
  144. package/package.json +1 -1
@@ -0,0 +1,45 @@
1
+
2
+ import { FSharpResult$2 } from "../fable-library-js.5.17.2/Result.js";
3
+
4
+ /**
5
+ * Takes two results and returns a tuple of the pair
6
+ *
7
+ * Documentation is found here: <href>https://demystifyfp.gitbook.io/fstoolkit-errorhandling/fstoolkit.errorhandling/result/zip</href>
8
+ */
9
+ export function zip(left, right) {
10
+ const copyOfStruct = left;
11
+ if (copyOfStruct.tag === 1) {
12
+ return new FSharpResult$2(/* Error */ 1, [copyOfStruct.fields[0]]);
13
+ }
14
+ else {
15
+ const copyOfStruct_1 = right;
16
+ if (copyOfStruct_1.tag === 1) {
17
+ return new FSharpResult$2(/* Error */ 1, [copyOfStruct_1.fields[0]]);
18
+ }
19
+ else {
20
+ return new FSharpResult$2(/* Ok */ 0, [[copyOfStruct.fields[0], copyOfStruct_1.fields[0]]]);
21
+ }
22
+ }
23
+ }
24
+
25
+ /**
26
+ * Takes two results and returns a tuple of the error pair
27
+ *
28
+ * Documentation is found here: <href>https://demystifyfp.gitbook.io/fstoolkit-errorhandling/fstoolkit.errorhandling/result/ziperror</href>
29
+ */
30
+ export function zipError(left, right) {
31
+ const copyOfStruct = left;
32
+ if (copyOfStruct.tag === 0) {
33
+ return new FSharpResult$2(/* Ok */ 0, [copyOfStruct.fields[0]]);
34
+ }
35
+ else {
36
+ const copyOfStruct_1 = right;
37
+ if (copyOfStruct_1.tag === 0) {
38
+ return new FSharpResult$2(/* Ok */ 0, [copyOfStruct_1.fields[0]]);
39
+ }
40
+ else {
41
+ return new FSharpResult$2(/* Error */ 1, [[copyOfStruct.fields[0], copyOfStruct_1.fields[0]]]);
42
+ }
43
+ }
44
+ }
45
+
@@ -0,0 +1,140 @@
1
+ namespace FsToolkit.ErrorHandling
2
+
3
+ open System
4
+
5
+ [<AutoOpen>]
6
+ module ResultCE =
7
+
8
+ type ResultBuilder() =
9
+ member inline _.Return(value: 'ok) : Result<'ok, 'error> = Ok value
10
+
11
+ member inline _.ReturnFrom(result: Result<'ok, 'error>) : Result<'ok, 'error> = result
12
+
13
+ member this.Zero() : Result<unit, 'error> = this.Return()
14
+
15
+ member inline _.Bind
16
+ (
17
+ input: Result<'okInput, 'error>,
18
+ [<InlineIfLambda>] binder: 'okInput -> Result<'okOutput, 'error>
19
+ ) : Result<'okOutput, 'error> =
20
+ Result.bind binder input
21
+
22
+ member inline _.Delay
23
+ ([<InlineIfLambda>] generator: unit -> Result<'ok, 'error>)
24
+ : unit -> Result<'ok, 'error> =
25
+ generator
26
+
27
+ member inline _.Run
28
+ ([<InlineIfLambda>] generator: unit -> Result<'ok, 'error>)
29
+ : Result<'ok, 'error> =
30
+ generator ()
31
+
32
+ member inline this.Combine
33
+ (result: Result<unit, 'error>, [<InlineIfLambda>] binder: unit -> Result<'ok, 'error>)
34
+ : Result<'ok, 'error> =
35
+ this.Bind(result, binder)
36
+
37
+ member inline this.TryWith
38
+ (
39
+ [<InlineIfLambda>] generator: unit -> Result<'T, 'TError>,
40
+ [<InlineIfLambda>] handler: exn -> Result<'T, 'TError>
41
+ ) : Result<'T, 'TError> =
42
+ try
43
+ this.Run generator
44
+ with e ->
45
+ handler e
46
+
47
+ member inline this.TryFinally
48
+ (
49
+ [<InlineIfLambda>] generator: unit -> Result<'ok, 'error>,
50
+ [<InlineIfLambda>] compensation: unit -> unit
51
+ ) : Result<'ok, 'error> =
52
+ try
53
+ this.Run generator
54
+ finally
55
+ compensation ()
56
+
57
+ member inline this.Using
58
+ (resource: 'disposable :> IDisposableNull, binder: 'disposable -> Result<'ok, 'error>)
59
+ : Result<'ok, 'error> =
60
+ this.TryFinally(
61
+ (fun () -> binder resource),
62
+ (fun () ->
63
+ if not (obj.ReferenceEquals(resource, null)) then
64
+ resource.Dispose()
65
+ )
66
+ )
67
+
68
+ member inline this.While
69
+ (
70
+ [<InlineIfLambda>] guard: unit -> bool,
71
+ [<InlineIfLambda>] generator: unit -> Result<unit, 'error>
72
+ ) : Result<unit, 'error> =
73
+
74
+ let mutable doContinue = true
75
+ let mutable result = Ok()
76
+
77
+ while doContinue
78
+ && guard () do
79
+ match generator () with
80
+ | Ok() -> ()
81
+ | Error e ->
82
+ doContinue <- false
83
+ result <- Error e
84
+
85
+ result
86
+
87
+ member inline this.For
88
+ (sequence: #seq<'T>, [<InlineIfLambda>] binder: 'T -> Result<unit, 'TError>)
89
+ : Result<unit, 'TError> =
90
+ this.Using(
91
+ sequence.GetEnumerator(),
92
+ fun enum ->
93
+ this.While(
94
+ (fun () -> enum.MoveNext()),
95
+ this.Delay(fun () -> binder enum.Current)
96
+ )
97
+ )
98
+
99
+ member inline _.BindReturn
100
+ (x: Result<'okInput, 'error>, [<InlineIfLambda>] f: 'okInput -> 'okOutput)
101
+ : Result<'okOutput, 'error> =
102
+ Result.map f x
103
+
104
+ /// <summary>
105
+ /// Method lets us transform data types into our internal representation. This is the identity method to recognize the self type.
106
+ ///
107
+ /// See https://stackoverflow.com/questions/35286541/why-would-you-use-builder-source-in-a-custom-computation-expression-builder
108
+ /// </summary>
109
+ /// <param name="result"></param>
110
+ /// <returns></returns>
111
+ member inline _.Source(result: Result<'ok, 'error>) : Result<'ok, 'error> = result
112
+
113
+ /// <summary>
114
+ /// The <c>Result</c> computation expression.
115
+ /// </summary>
116
+ let result = ResultBuilder()
117
+
118
+ [<AutoOpen>]
119
+ module ResultCEExtensions =
120
+
121
+ type ResultBuilder with
122
+
123
+ /// <summary>
124
+ /// Needed to allow `for..in` and `for..do` functionality
125
+ /// </summary>
126
+ member inline _.Source(s: #seq<_>) : #seq<_> = s
127
+
128
+
129
+ // Having Choice<_> members as extensions gives them lower priority in
130
+ // overload resolution and allows skipping more type annotations.
131
+ [<AutoOpen>]
132
+ module ResultCEChoiceExtensions =
133
+ type ResultBuilder with
134
+
135
+ /// <summary>
136
+ /// Method lets us transform data types into our internal representation.
137
+ /// </summary>
138
+ /// <returns></returns>
139
+ member inline _.Source(choice: Choice<'ok, 'error>) : Result<'ok, 'error> =
140
+ Result.ofChoice choice
@@ -0,0 +1,23 @@
1
+
2
+ import { class_type } from "../fable-library-js.5.17.2/Reflection.js";
3
+ import { FSharpResult$2 } from "../fable-library-js.5.17.2/Result.js";
4
+
5
+ export class ResultCE_ResultBuilder {
6
+ constructor() {
7
+ }
8
+ }
9
+
10
+ export function ResultCE_ResultBuilder_$reflection() {
11
+ return class_type("FsToolkit.ErrorHandling.ResultCE.ResultBuilder", undefined, ResultCE_ResultBuilder);
12
+ }
13
+
14
+ export function ResultCE_ResultBuilder_$ctor() {
15
+ return new ResultCE_ResultBuilder();
16
+ }
17
+
18
+ export function ResultCE_ResultBuilder__Zero(this$) {
19
+ return new FSharpResult$2(/* Ok */ 0, [undefined]);
20
+ }
21
+
22
+ export const ResultCE_result = ResultCE_ResultBuilder_$ctor();
23
+
@@ -0,0 +1,45 @@
1
+ namespace FsToolkit.ErrorHandling.Operator.Result
2
+
3
+ open FsToolkit.ErrorHandling
4
+
5
+ /// <summary>
6
+ /// Operators for working with the <c>Result</c> type.
7
+ /// </summary>
8
+ [<AutoOpen>]
9
+ module Result =
10
+
11
+ /// <summary>
12
+ /// Shorthand for <c>Result.map</c>
13
+ /// </summary>
14
+ /// <param name="mapper">The function to map over the <c>Result</c> value.</param>
15
+ /// <param name="input">The <c>Result</c> value to map over.</param>
16
+ /// <returns>The result of mapping the function over the <c>Result</c> value.</returns>
17
+ let inline (<!>)
18
+ (([<InlineIfLambda>] mapper: 'okInput -> 'okOutput))
19
+ (input: Result<'okInput, 'error>)
20
+ : Result<'okOutput, 'error> =
21
+ Result.map mapper input
22
+
23
+ /// <summary>
24
+ /// Shorthand for <c>Result.apply</c>
25
+ /// </summary>
26
+ /// <param name="applier">The <c>Result</c> value containing the function to apply.</param>
27
+ /// <param name="input">The <c>Result</c> value containing the value to apply the function to.</param>
28
+ /// <returns>The result of applying the function in the <c>Result</c> value to the value in the other <c>Result</c> value.</returns>
29
+ let inline (<*>)
30
+ (applier: Result<'okInput -> 'okOutput, 'error>)
31
+ (input: Result<'okInput, 'error>)
32
+ : Result<'okOutput, 'error> =
33
+ Result.apply applier input
34
+
35
+ /// <summary>
36
+ /// Shorthand for <c>Result.bind</c>
37
+ /// </summary>
38
+ /// <param name="input">The <c>Result</c> value to bind over.</param>
39
+ /// <param name="binder">The function to bind over the <c>Result</c> value.</param>
40
+ /// <returns>The result of binding the function over the <c>Result</c> value.</returns>
41
+ let inline (>>=)
42
+ (input: Result<'input, 'error>)
43
+ ([<InlineIfLambda>] binder: 'input -> Result<'okOutput, 'error>)
44
+ : Result<'okOutput, 'error> =
45
+ Result.bind binder input
@@ -0,0 +1,201 @@
1
+ namespace FsToolkit.ErrorHandling
2
+
3
+ /// <summary>
4
+ /// Helper functions for working with <c>Result</c> values that contain <c>Option</c> values.
5
+ /// </summary>
6
+ [<RequireQualifiedAccess>]
7
+ module ResultOption =
8
+
9
+ /// <summary>
10
+ /// Converts a value to a value into a <c>Result</c> which contains the value wrapped in an <c>Option</c>.
11
+ /// </summary>
12
+ /// <param name="x">The value to convert.</param>
13
+ /// <returns>The value wrapped in an <c>Option</c> and then wrapped in a <c>Result</c>.</returns>
14
+ let inline singleton x = Ok(Some x)
15
+
16
+ /// <summary>
17
+ /// Applies a transformation function to a <c>Result</c> value that contains an <c>Option</c> value.
18
+ ///
19
+ /// Documentation is found here: <href>https://demystifyfp.gitbook.io/fstoolkit-errorhandling/fstoolkit.errorhandling/option/map</href>
20
+ /// </summary>
21
+ /// <param name="mapper">The transformation function to apply.</param>
22
+ /// <param name="input">The <c>Result</c> value to apply the transformation function to.</param>
23
+ /// <returns>The result of applying the transformation function to the <c>Result</c> value.</returns>
24
+ let inline map
25
+ ([<InlineIfLambda>] mapper: 'okInput -> 'okOutput)
26
+ (input: Result<'okInput option, 'error>)
27
+ : Result<'okOutput option, 'error> =
28
+ Result.map (Option.map mapper) input
29
+
30
+ /// <summary>
31
+ /// Maps the error value of a <c>Result</c> value that contains an <c>Option</c> value using the provided function.
32
+ ///
33
+ /// Documentation is found here: <href>https://demystifyfp.gitbook.io/fstoolkit-errorhandling/fstoolkit.errorhandling/option/maperror</href>
34
+ /// </summary>
35
+ /// <param name="mapper">The function to map over the error value.</param>
36
+ /// <param name="input">The <c>Result</c> value to map the error value of.</param>
37
+ /// <returns>The result of mapping the error value of the <c>Result</c> value.</returns>
38
+ let inline mapError
39
+ ([<InlineIfLambda>] mapper: 'errorInput -> 'errorOutput)
40
+ (input: Result<'ok option, 'errorInput>)
41
+ : Result<'ok option, 'errorOutput> =
42
+ Result.mapError mapper input
43
+
44
+ /// <summary>
45
+ /// Takes a transformation function and applies to to the value in a <c>Result</c> value that contains an <c>Option</c> value, if is is <c>Ok</c> and <c>Some</c>.
46
+ ///
47
+ /// Documentation is found here: <href>https://demystifyfp.gitbook.io/fstoolkit-errorhandling/fstoolkit.errorhandling/option/bind</href>
48
+ /// </summary>
49
+ /// <param name="binder">The transformation function to apply.</param>
50
+ /// <param name="input">The <c>Result</c> value to apply the transformation function to.</param>
51
+ /// <returns>The result of applying the transformation function to the <c>Result</c> value.</returns>
52
+ let inline bind
53
+ ([<InlineIfLambda>] binder: 'okInput -> Result<'okOutput option, 'error>)
54
+ (input: Result<'okInput option, 'error>)
55
+ : Result<'okOutput option, 'error> =
56
+ Result.bind
57
+ (function
58
+ | Some x -> binder x
59
+ | None -> Ok None)
60
+ input
61
+
62
+ /// <summary>
63
+ /// Applies a transformation function to a <c>Result</c> value that contains an <c>Option</c> value and returns the result wrapped in an <c>Option</c> within a <c>Result</c>.
64
+ ///
65
+ /// Documentation is found here: <href>https://demystifyfp.gitbook.io/fstoolkit-errorhandling/fstoolkit.errorhandling/option/apply</href>
66
+ /// </summary>
67
+ /// <param name="applier">The <c>Result</c> containing a potential function to apply</param>
68
+ /// <param name="input">The <c>Result</c> containing a potential value to apply the function to</param>
69
+ /// <returns>The result of applying the function to the value, wrapped in an <c>Option</c> and then wrapped in a <c>Result</c>.</returns>
70
+ let inline apply
71
+ (applier: Result<('okInput -> 'okOutput) option, 'error>)
72
+ (input: Result<'okInput option, 'error>)
73
+ : Result<'okOutput option, 'error> =
74
+ match (applier, input) with
75
+ | Ok f, Ok x ->
76
+ match f, x with
77
+ | Some f', Some x' -> Ok(Some(f' x'))
78
+ | _ -> Ok None
79
+ | Error e, _
80
+ | _, Error e -> Error e
81
+
82
+
83
+ /// <summary>
84
+ /// Combines two <c>Result</c> values that contain <c>Option</c> values into a single <c>Result</c> value that contains the result wrapped in an <c>Option</c>.
85
+ ///
86
+ /// Documentation is found here: <href>https://demystifyfp.gitbook.io/fstoolkit-errorhandling/fstoolkit.errorhandling/option/map2</href>
87
+ /// </summary>
88
+ /// <param name="mapper">The function to combine the two values with.</param>
89
+ /// <param name="input1">The first <c>Result</c> value to combine.</param>
90
+ /// <param name="input2">The second <c>Result</c> value to combine.</param>
91
+ /// <returns>The result of combining the two <c>Result</c> values, wrapped in an <c>Option</c> and then wrapped in a <c>Result</c>.</returns>
92
+ let inline map2
93
+ ([<InlineIfLambda>] mapper: 'okInput1 -> 'okInput2 -> 'okOutput)
94
+ (input1: Result<'okInput1 option, 'error>)
95
+ (input2: Result<'okInput2 option, 'error>)
96
+ : Result<'okOutput option, 'error> =
97
+ match (input1, input2) with
98
+ | Ok x, Ok y ->
99
+ match x, y with
100
+ | Some x', Some y' -> Ok(Some(mapper x' y'))
101
+ | _ -> Ok None
102
+ | Error e, _
103
+ | _, Error e -> Error e
104
+
105
+ /// <summary>
106
+ /// Combines three <c>Result</c> values that contain <c>Option</c> values into a single <c>Result</c> value that contains the result wrapped in an <c>Option</c>.
107
+ ///
108
+ /// Documentation is found here: <href>https://demystifyfp.gitbook.io/fstoolkit-errorhandling/fstoolkit.errorhandling/option/map3</href>
109
+ /// </summary>
110
+ /// <param name="mapper">The function to combine the three values with.</param>
111
+ /// <param name="input1">The first <c>Result</c> value to combine.</param>
112
+ /// <param name="input2">The second <c>Result</c> value to combine.</param>
113
+ /// <param name="input3">The third <c>Result</c> value to combine.</param>
114
+ /// <returns>The result of combining the three <c>Result</c> values, wrapped in an <c>Option</c> and then wrapped in a <c>Result</c>.</returns>
115
+ let inline map3
116
+ ([<InlineIfLambda>] mapper: 'okInput1 -> 'okInput2 -> 'okInput3 -> 'okOutput)
117
+ (input1: Result<'okInput1 option, 'error>)
118
+ (input2: Result<'okInput2 option, 'error>)
119
+ (input3: Result<'okInput3 option, 'error>)
120
+ : Result<'okOutput option, 'error> =
121
+ match (input1, input2, input3) with
122
+ | Ok x, Ok y, Ok z ->
123
+ match x, y, z with
124
+ | Some x', Some y', Some z' -> Ok(Some(mapper x' y' z'))
125
+ | _ -> Ok None
126
+ | Error e, _, _
127
+ | _, Error e, _
128
+ | _, _, Error e -> Error e
129
+
130
+ /// <summary>
131
+ /// Combines two <c>Result</c> values that contain <c>Option</c> values into a single <c>Result</c> value that contains the tuple of the two values wrapped in an <c>Option</c>, if they are both <c>Some</c>.
132
+ ///
133
+ /// Documentation is found here: <href>https://demystifyfp.gitbook.io/fstoolkit-errorhandling/fstoolkit.errorhandling/option/zip</href>
134
+ /// </summary>
135
+ /// <param name="input1">The first <c>Result</c> value to combine.</param>
136
+ /// <param name="input2">The second <c>Result</c> value to combine.</param>
137
+ /// <returns>A tuple of the two values wrapped in an <c>Option</c> and then wrapped in a <c>Result</c>.</returns>
138
+ let zip
139
+ (left: Result<'leftOk option, 'error>)
140
+ (right: Result<'rightOk option, 'error>)
141
+ : Result<('leftOk * 'rightOk) option, 'error> =
142
+ match left, right with
143
+ | Ok x1res, Ok x2res ->
144
+ match x1res, x2res with
145
+ | Some x1, Some x2 -> Ok(Some(x1, x2))
146
+ | _ -> Ok None
147
+ | Error e, _ -> Error e
148
+ | _, Error e -> Error e
149
+
150
+ /// <summary>
151
+ /// Takes two results and returns a tuple of the error pair
152
+ ///
153
+ /// Documentation is found here: <href>https://demystifyfp.gitbook.io/fstoolkit-errorhandling/fstoolkit.errorhandling/option/ziperror</href>
154
+ /// </summary>
155
+ /// <param name="left">The first <c>Result</c> value to combine.</param>
156
+ /// <param name="right">The second <c>Result</c> value to combine.</param>
157
+ /// <returns>A tuple of the error pair of the input results.</returns>
158
+ let zipError
159
+ (left: Result<'ok option, 'leftError>)
160
+ (right: Result<'ok option, 'rightError>)
161
+ : Result<'ok option, 'leftError * 'rightError> =
162
+ match left, right with
163
+ | Error x1res, Error x2res -> Error(x1res, x2res)
164
+ | Ok e, _ -> Ok e
165
+ | _, Ok e -> Ok e
166
+
167
+ /// <summary>
168
+ /// Replaces the wrapped value with unit
169
+ /// </summary>
170
+ /// <param name="resultOpt">The <c>Result</c> value to ignore the value of.</param>
171
+ /// <returns>The <c>Result</c> value with the value replaced with an <c>Option</c> unit.</returns>
172
+ let inline ignore<'ok, 'error> (resultOpt: Result<'ok option, 'error>) =
173
+ resultOpt
174
+ |> map ignore<'ok>
175
+
176
+ /// <summary>
177
+ /// Converts a <c>Result</c> into a <c>Result</c> that contains the value wrapped in an <c>Option</c>.
178
+ /// </summary>
179
+ /// <param name="result">The <c>Result</c> to convert.</param>
180
+ /// <returns>The <c>Result</c> with the value wrapped in an <c>Option</c>.</returns>
181
+ let inline ofResult (result: Result<'ok, 'error>) : Result<'ok option, 'error> =
182
+ match result with
183
+ | Ok x -> Ok(Some x)
184
+ | Error e -> Error e
185
+
186
+ /// <summary>
187
+ /// Converts an <c>Option</c> into a <c>Result</c> that contains the <c>Option</c>
188
+ /// </summary>
189
+ /// <param name="option">The <c>Option</c> to convert.</param>
190
+ /// <returns>The <c>Result</c> with the <c>Option</c>.</returns>
191
+ let inline ofOption (option: 'T option) : Result<'T option, 'error> = Ok option
192
+
193
+ /// <summary>
194
+ /// Converts a <c>Choice</c> into a <c>Result</c> that contains the value wrapped in an <c>Option</c>.
195
+ /// </summary>
196
+ /// <param name="choice">The <c>Choice</c> to convert.</param>
197
+ /// <returns>The <c>Result</c> with the value wrapped in an <c>Option</c>.</returns>
198
+ let inline ofChoice (choice: Choice<'ok, 'error>) : Result<'ok option, 'error> =
199
+ match choice with
200
+ | Choice1Of2 x -> Ok(Some x)
201
+ | Choice2Of2 e -> Error e
@@ -0,0 +1,65 @@
1
+
2
+ import { FSharpResult$2 } from "../fable-library-js.5.17.2/Result.js";
3
+ import { value } from "../fable-library-js.5.17.2/Option.js";
4
+
5
+ /**
6
+ * Combines two <c>Result</c> values that contain <c>Option</c> values into a single <c>Result</c> value that contains the tuple of the two values wrapped in an <c>Option</c>, if they are both <c>Some</c>.
7
+ *
8
+ * Documentation is found here: <href>https://demystifyfp.gitbook.io/fstoolkit-errorhandling/fstoolkit.errorhandling/option/zip</href>
9
+ */
10
+ export function zip(left, right) {
11
+ const copyOfStruct = left;
12
+ if (copyOfStruct.tag === 1) {
13
+ return new FSharpResult$2(/* Error */ 1, [copyOfStruct.fields[0]]);
14
+ }
15
+ else {
16
+ const copyOfStruct_1 = right;
17
+ if (copyOfStruct_1.tag === 1) {
18
+ return new FSharpResult$2(/* Error */ 1, [copyOfStruct_1.fields[0]]);
19
+ }
20
+ else {
21
+ let matchResult, x1, x2;
22
+ if (copyOfStruct.fields[0] != null) {
23
+ if (copyOfStruct_1.fields[0] != null) {
24
+ matchResult = 0;
25
+ x1 = value(copyOfStruct.fields[0]);
26
+ x2 = value(copyOfStruct_1.fields[0]);
27
+ }
28
+ else {
29
+ matchResult = 1;
30
+ }
31
+ }
32
+ else {
33
+ matchResult = 1;
34
+ }
35
+ switch (matchResult) {
36
+ case 0:
37
+ return new FSharpResult$2(/* Ok */ 0, [[x1, x2]]);
38
+ default:
39
+ return new FSharpResult$2(/* Ok */ 0, [undefined]);
40
+ }
41
+ }
42
+ }
43
+ }
44
+
45
+ /**
46
+ * Takes two results and returns a tuple of the error pair
47
+ *
48
+ * Documentation is found here: <href>https://demystifyfp.gitbook.io/fstoolkit-errorhandling/fstoolkit.errorhandling/option/ziperror</href>
49
+ */
50
+ export function zipError(left, right) {
51
+ const copyOfStruct = left;
52
+ if (copyOfStruct.tag === 0) {
53
+ return new FSharpResult$2(/* Ok */ 0, [copyOfStruct.fields[0]]);
54
+ }
55
+ else {
56
+ const copyOfStruct_1 = right;
57
+ if (copyOfStruct_1.tag === 0) {
58
+ return new FSharpResult$2(/* Ok */ 0, [copyOfStruct_1.fields[0]]);
59
+ }
60
+ else {
61
+ return new FSharpResult$2(/* Error */ 1, [[copyOfStruct.fields[0], copyOfStruct_1.fields[0]]]);
62
+ }
63
+ }
64
+ }
65
+
@@ -0,0 +1,135 @@
1
+ namespace FsToolkit.ErrorHandling
2
+
3
+ open System
4
+
5
+ [<AutoOpen>]
6
+ module ResultOptionCE =
7
+
8
+ type ResultOptionBuilder() =
9
+ member inline _.Return value = ResultOption.singleton value
10
+
11
+ member inline _.ReturnFrom value : Result<'ok option, 'error> = value
12
+
13
+ member inline _.Zero() =
14
+ Some()
15
+ |> Ok
16
+
17
+ member inline _.Bind
18
+ (
19
+ resultOpt: Result<'okInput option, 'error>,
20
+ [<InlineIfLambda>] binder: 'okInput -> Result<'okOutput option, 'error>
21
+ ) : Result<'okOutput option, 'error> =
22
+ ResultOption.bind binder resultOpt
23
+
24
+ member inline _.Combine
25
+ (
26
+ resultOpt: Result<unit option, 'error>,
27
+ [<InlineIfLambda>] binder: unit -> Result<'ok option, 'error>
28
+ ) : Result<'ok option, 'error> =
29
+ ResultOption.bind binder resultOpt
30
+
31
+ member inline _.Delay([<InlineIfLambda>] delayer: unit -> Result<'ok option, 'error>) =
32
+ delayer
33
+
34
+ member inline _.Run
35
+ ([<InlineIfLambda>] generator: unit -> Result<'ok option, 'error>)
36
+ : Result<'ok option, 'error> =
37
+ generator ()
38
+
39
+ member inline this.TryWith
40
+ (
41
+ [<InlineIfLambda>] generator: unit -> Result<'T option, 'TError>,
42
+ [<InlineIfLambda>] handler: exn -> Result<'T option, 'TError>
43
+ ) : Result<'T option, 'TError> =
44
+ try
45
+ this.Run generator
46
+ with e ->
47
+ handler e
48
+
49
+ member inline this.TryFinally
50
+ (
51
+ [<InlineIfLambda>] generator: unit -> Result<'ok option, 'error>,
52
+ [<InlineIfLambda>] compensation: unit -> unit
53
+ ) : Result<'ok option, 'error> =
54
+ try
55
+ this.Run generator
56
+ finally
57
+ compensation ()
58
+
59
+ member inline this.Using
60
+ (
61
+ resource: 'disposable :> IDisposableNull,
62
+ binder: 'disposable -> Result<'ok option, 'error>
63
+ ) : Result<'ok option, 'error> =
64
+ this.TryFinally(
65
+ (fun () -> binder resource),
66
+ (fun () ->
67
+ if not (obj.ReferenceEquals(resource, null)) then
68
+ resource.Dispose()
69
+ )
70
+ )
71
+
72
+ member inline this.While
73
+ (
74
+ [<InlineIfLambda>] guard: unit -> bool,
75
+ [<InlineIfLambda>] generator: unit -> Result<unit option, 'error>
76
+ ) : Result<unit option, 'error> =
77
+
78
+ let mutable doContinue = true
79
+ let mutable result = Ok(Some())
80
+
81
+ while doContinue
82
+ && guard () do
83
+ match generator () with
84
+ | Ok option ->
85
+ match option with
86
+ | Some _ -> ()
87
+ | None ->
88
+ doContinue <- false
89
+ result <- Ok None
90
+ | Error e ->
91
+ doContinue <- false
92
+ result <- Error e
93
+
94
+ result
95
+
96
+ member inline this.For
97
+ (sequence: #seq<'T>, [<InlineIfLambda>] binder: 'T -> Result<unit option, 'TError>)
98
+ : Result<unit option, 'TError> =
99
+ this.Using(
100
+ sequence.GetEnumerator(),
101
+ fun enum ->
102
+ this.While(
103
+ (fun () -> enum.MoveNext()),
104
+ this.Delay(fun () -> binder enum.Current)
105
+ )
106
+ )
107
+
108
+ member inline _.BindReturn
109
+ (resultOpt: Result<'T option, 'TError>, [<InlineIfLambda>] binder: 'T -> 'U)
110
+ : Result<'U option, 'TError> =
111
+ ResultOption.map binder resultOpt
112
+
113
+ member inline _.Source(result: Result<'ok option, 'error>) : Result<'ok option, 'error> =
114
+ result
115
+
116
+ let resultOption = ResultOptionBuilder()
117
+
118
+ [<AutoOpen>]
119
+ module ResultOptionCEExtensions =
120
+
121
+ type ResultOptionBuilder with
122
+
123
+ /// <summary>
124
+ /// Needed to allow `for..in` and `for..do` functionality
125
+ /// </summary>
126
+ member inline _.Source(s: #seq<'value>) : #seq<'value> = s
127
+
128
+ member inline _.Source(result: Result<'ok, 'error>) : Result<'ok option, 'error> =
129
+ ResultOption.ofResult result
130
+
131
+ member inline _.Source(option: 'T option) : Result<'T option, 'error> =
132
+ ResultOption.ofOption option
133
+
134
+ member inline _.Source(choice: Choice<'T, 'Error>) : Result<'T option, 'Error> =
135
+ ResultOption.ofChoice choice