@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,18 @@
1
+
2
+ import { class_type } from "../fable-library-js.5.17.2/Reflection.js";
3
+
4
+ export class ResultOptionCE_ResultOptionBuilder {
5
+ constructor() {
6
+ }
7
+ }
8
+
9
+ export function ResultOptionCE_ResultOptionBuilder_$reflection() {
10
+ return class_type("FsToolkit.ErrorHandling.ResultOptionCE.ResultOptionBuilder", undefined, ResultOptionCE_ResultOptionBuilder);
11
+ }
12
+
13
+ export function ResultOptionCE_ResultOptionBuilder_$ctor() {
14
+ return new ResultOptionCE_ResultOptionBuilder();
15
+ }
16
+
17
+ export const ResultOptionCE_resultOption = ResultOptionCE_ResultOptionBuilder_$ctor();
18
+
@@ -0,0 +1,57 @@
1
+ namespace FsToolkit.ErrorHandling.Operator.ResultOption
2
+
3
+ open FsToolkit.ErrorHandling
4
+
5
+ /// <summary>
6
+ /// Operators for working with the <c>Result</c> and <c>Option</c> types.
7
+ /// </summary>
8
+ [<AutoOpen>]
9
+ module ResultOption =
10
+
11
+ /// <summary>
12
+ /// Shorthand for <c>ResultOption.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 option, 'error>)
20
+ : Result<'okOutput option, 'error> =
21
+ ResultOption.map mapper input
22
+
23
+ /// <summary>
24
+ /// Shortand for <c>ResultOption.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) option, 'error>)
31
+ (input: Result<'okInput option, 'error>)
32
+ : Result<'okOutput option, 'error> =
33
+ ResultOption.apply applier input
34
+
35
+ /// <summary>
36
+ /// Shorthand for <c>ResultOption.apply</c>, where the value is wrapped in an <c>Option</c> for you
37
+ /// </summary>
38
+ /// <param name="applier">The <c>Result</c> value containing the function to apply.</param>
39
+ /// <param name="input">The <c>Result</c> value containing the value to apply the function to.</param>
40
+ /// <returns>The result of applying the function in the <c>Result</c> value to the value in the other <c>Result</c> value.</returns>
41
+ let inline (<*^>)
42
+ (applier: Result<('okInput -> 'okOutput) option, 'error>)
43
+ (input: Result<'okInput, 'error>)
44
+ : Result<'okOutput option, 'error> =
45
+ ResultOption.apply applier (Result.map Some input)
46
+
47
+ /// <summary>
48
+ /// Shorthand for <c>ResultOption.bind</c>
49
+ /// </summary>
50
+ /// <param name="input">The <c>Result</c> value to bind over.</param>
51
+ /// <param name="binder">The function to bind over the <c>Result</c> value.</param>
52
+ /// <returns>The result of binding the function over the <c>Result</c> value.</returns>
53
+ let inline (>>=)
54
+ (input: Result<'okInput option, 'error>)
55
+ ([<InlineIfLambda>] binder: 'okInput -> Result<'okOutput option, 'error>)
56
+ : Result<'okOutput option, 'error> =
57
+ ResultOption.bind binder input
@@ -0,0 +1,503 @@
1
+ // See here for previous design discussions:
2
+ // 1. https://github.com/demystifyfp/FsToolkit.ErrorHandling/pull/277
3
+ // 2. https://github.com/demystifyfp/FsToolkit.ErrorHandling/pull/310
4
+
5
+ [<RequireQualifiedAccess>]
6
+ module FsToolkit.ErrorHandling.Seq
7
+
8
+ open Microsoft.FSharp.Core.CompilerServices
9
+
10
+ /// <summary>
11
+ /// Applies a function to each element of a sequence and returns a single result
12
+ /// </summary>
13
+ /// <param name="state">The initial state</param>
14
+ /// <param name="f">The function to apply to each element</param>
15
+ /// <param name="xs">The input sequence</param>
16
+ /// <returns>If state and all elements in 'sequence' are Ok, a result with the elements in an array. Alternately, the first error encountered</returns>
17
+ let inline traverseResultM'
18
+ (state: Result<'okOutput seq, 'error>)
19
+ ([<InlineIfLambda>] f: 'okInput -> Result<'okOutput, 'error>)
20
+ (xs: SeqNull<'okInput>)
21
+ : Result<'okOutput[], 'error> =
22
+ if isNull xs then
23
+ nullArg (nameof xs)
24
+
25
+ match state with
26
+ | Error e -> Error e
27
+ | Ok initialSuccesses ->
28
+
29
+ let oks = ResizeArray(initialSuccesses)
30
+ let mutable err = Unchecked.defaultof<'error>
31
+ let mutable ok = true
32
+ use e = xs.GetEnumerator()
33
+
34
+ while ok
35
+ && e.MoveNext() do
36
+ match f e.Current with
37
+ | Ok r -> oks.Add r
38
+ | Error e ->
39
+ err <- e
40
+ ok <- false
41
+
42
+ if ok then Ok(oks.ToArray()) else Error err
43
+
44
+ /// <summary>
45
+ /// Applies a function to each element of a sequence and returns a single result
46
+ /// </summary>
47
+ /// <param name="f">The function to apply to each element</param>
48
+ /// <param name="xs">The input sequence</param>
49
+ /// <returns>A result with the ok elements in an array, or the first error occurring in the sequence</returns>
50
+ /// <remarks>This function is equivalent to <see cref="traverseResultM'"/> but applying an initial state of 'Seq.empty'</remarks>
51
+ let traverseResultM f xs = traverseResultM' (Ok Seq.empty) f xs
52
+
53
+ /// <summary>
54
+ /// Converts a sequence of results into a single result
55
+ /// </summary>
56
+ /// <param name="xs">The input sequence</param>
57
+ /// <returns>A result bearing all the results as an array, or the first error occurring in the sequence</returns>
58
+ /// <remarks>This function is equivalent to <see cref="traverseResultM"/> but auto-applying the 'id' function</remarks>
59
+ let sequenceResultM xs = traverseResultM id xs
60
+
61
+ /// <summary>
62
+ /// Applies a function to each element of a sequence and returns a single result
63
+ /// </summary>
64
+ /// <param name="state">The initial state</param>
65
+ /// <param name="f">The function to apply to each element</param>
66
+ /// <param name="xs">The input sequence</param>
67
+ /// <returns>If no Errors encountered, an Ok result bearing an array of the ok elements from the 'state' followed by those gathered from the sequence, or an Error bearing an array of all errors from the 'state' and/or those in the sequence</returns>
68
+ let inline traverseResultA'
69
+ (state: Result<'okOutput seq, 'error seq>)
70
+ ([<InlineIfLambda>] f: 'okInput -> Result<'okOutput, 'error>)
71
+ (xs: SeqNull<'okInput>)
72
+ =
73
+
74
+ if isNull xs then
75
+ nullArg (nameof xs)
76
+
77
+ match state with
78
+ | Error failuresToDate ->
79
+ let errs = ResizeArray failuresToDate
80
+
81
+ for x in xs do
82
+ match f x with
83
+ | Error e -> errs.Add e
84
+ | Ok _ -> () // as the initial state was failure, oks are irrelevant
85
+
86
+ Error(errs.ToArray())
87
+ | Ok initialSuccesses ->
88
+
89
+ let oks = ResizeArray initialSuccesses
90
+ let errs = ResizeArray()
91
+
92
+ for x in xs do
93
+ match f x with
94
+ | Ok r when errs.Count = 0 -> oks.Add r
95
+ | Ok _ -> () // no point saving results we won't use given the end result will be Error
96
+ | Error e -> errs.Add e
97
+
98
+ if errs.Count = 0 then
99
+ Ok(oks.ToArray())
100
+ else
101
+ Error(errs.ToArray())
102
+
103
+ /// <summary>
104
+ /// Applies a function to each element of a sequence and returns a single result
105
+ /// </summary>
106
+ /// <param name="f">The function to apply to each element</param>
107
+ /// <param name="xs">The input sequence</param>
108
+ /// <returns>A result with the ok elements in an array or an array of all errors from the sequence</returns>
109
+ /// <remarks>This function is equivalent to <see cref="traverseResultA'"/> but applying an initial state of Seq.empty'</remarks>
110
+ let traverseResultA f xs = traverseResultA' (Ok Seq.empty) f xs
111
+
112
+ /// <summary>
113
+ /// Converts a sequence of results into a single result
114
+ /// </summary>
115
+ /// <param name="xs">The input sequence</param>
116
+ /// <returns>A result with the elements in an array or an array of all errors from the sequence</returns>
117
+ /// <remarks>This function is equivalent to <see cref="traverseResultA"/> but auto-applying the 'id' function</remarks>
118
+ let sequenceResultA xs = traverseResultA id xs
119
+
120
+ /// <summary>
121
+ /// Applies a function to each element of a sequence and returns a single async result
122
+ /// </summary>
123
+ /// <param name="state">The initial state</param>
124
+ /// <param name="f">The function to apply to each element</param>
125
+ /// <param name="xs">The input sequence</param>
126
+ /// <returns>An async result with the ok elements in an array or the first error encountered in the state or the sequence</returns>
127
+ let inline traverseAsyncResultM'
128
+ (state: Async<Result<'okOutput seq, 'error>>)
129
+ ([<InlineIfLambda>] f: 'okInput -> Async<Result<'okOutput, 'error>>)
130
+ (xs: SeqNull<'okInput>)
131
+ : Async<Result<'okOutput[], 'error>> =
132
+ if isNull xs then
133
+ nullArg (nameof xs)
134
+
135
+ async {
136
+ match! state with
137
+ | Error e -> return Error e
138
+ | Ok initialSuccesses ->
139
+ let oks = ResizeArray initialSuccesses
140
+ let mutable err = Unchecked.defaultof<'error>
141
+ let mutable ok = true
142
+ use e = xs.GetEnumerator()
143
+
144
+ while ok
145
+ && e.MoveNext() do
146
+ match! f e.Current with
147
+ | Ok r -> oks.Add r
148
+ | Error e ->
149
+ err <- e
150
+ ok <- false
151
+
152
+ return if ok then Ok(oks.ToArray()) else Error err
153
+ }
154
+
155
+ /// <summary>
156
+ /// Applies a function to each element of a sequence and returns a single async result
157
+ /// </summary>
158
+ /// <param name="f">The function to apply to each element</param>
159
+ /// <param name="xs">The input sequence</param>
160
+ /// <returns>An async result with the ok elements in an array or the first error occurring in the sequence</returns>
161
+ /// <remarks>This function is equivalent to <see cref="traverseAsyncResultM'"/> but applying an initial state of 'Seq.empty'</remarks>
162
+ let traverseAsyncResultM f xs =
163
+ traverseAsyncResultM' (async { return Ok Seq.empty }) f xs
164
+
165
+ /// <summary>
166
+ /// Converts a sequence of async results into a single async result
167
+ /// </summary>
168
+ /// <param name="xs">The input sequence</param>
169
+ /// <returns>An async result with the ok elements in an array or the first error occurring in the sequence</returns>
170
+ /// <remarks>This function is equivalent to <see cref="traverseAsyncResultM"/> but auto-applying the 'id' function</remarks>
171
+ let sequenceAsyncResultM xs = traverseAsyncResultM id xs
172
+
173
+ #if !FABLE_COMPILER
174
+ /// <summary>
175
+ /// Applies a function to each element of a sequence and returns a single Task result
176
+ /// </summary>
177
+ /// <param name="state">The initial state</param>
178
+ /// <param name="f">The function to apply to each element</param>
179
+ /// <param name="xs">The input sequence</param>
180
+ /// <returns>A task result with the ok elements in an array or the first error encountered in the state or the sequence</returns>
181
+ let inline traverseTaskResultM'
182
+ (state: TaskResult<'okOutput seq, 'error>)
183
+ ([<InlineIfLambda>] f: 'okInput -> TaskResult<'okOutput, 'error>)
184
+ (xs: SeqNull<'okInput>)
185
+ : TaskResult<'okOutput[], 'error> =
186
+ if isNull xs then
187
+ nullArg (nameof xs)
188
+
189
+ task {
190
+ match! state with
191
+ | Error e -> return Error e
192
+ | Ok initialSuccesses ->
193
+ let oks = ResizeArray initialSuccesses
194
+ let mutable err = Unchecked.defaultof<'error>
195
+ let mutable ok = true
196
+ use e = xs.GetEnumerator()
197
+
198
+ while ok
199
+ && e.MoveNext() do
200
+ match! f e.Current with
201
+ | Ok r -> oks.Add r
202
+ | Error e ->
203
+ err <- e
204
+ ok <- false
205
+
206
+ return if ok then Ok(oks.ToArray()) else Error err
207
+ }
208
+
209
+ /// <summary>
210
+ /// Applies a function to each element of a sequence and returns a single Task result
211
+ /// </summary>
212
+ /// <param name="f">The function to apply to each element</param>
213
+ /// <param name="xs">The input sequence</param>
214
+ /// <returns>A task result with the ok elements in an array or the first error occurring in the sequence</returns>
215
+ /// <remarks>This function is equivalent to <see cref="traverseTaskResultM'"/> but applying an initial state of 'Seq.empty'</remarks>
216
+ let traverseTaskResultM f xs =
217
+ traverseTaskResultM' (TaskResult.ok Seq.empty) f xs
218
+
219
+ /// <summary>
220
+ /// Converts a sequence of Task results into a single Task result
221
+ /// </summary>
222
+ /// <param name="xs">The input sequence</param>
223
+ /// <returns>A task result with the ok elements in an array or the first error occurring in the sequence</returns>
224
+ /// <remarks>This function is equivalent to <see cref="traverseTaskResultM"/> but auto-applying the 'id' function</remarks>
225
+ let sequenceTaskResultM xs = traverseTaskResultM id xs
226
+
227
+ #endif
228
+
229
+ /// <summary>
230
+ /// Applies a function to each element of a sequence and returns a single async result
231
+ /// </summary>
232
+ /// <param name="state">The initial state</param>
233
+ /// <param name="f">The function to apply to each element</param>
234
+ /// <param name="xs">The input sequence</param>
235
+ /// <returns>An async result with the ok elements in an array or an array of all errors from the state and the original sequence</returns>
236
+ let inline traverseAsyncResultA'
237
+ (state: Async<Result<'okOutput seq, 'error seq>>)
238
+ ([<InlineIfLambda>] f: 'okInput -> Async<Result<'okOutput, 'error>>)
239
+ (xs: SeqNull<'okInput>)
240
+ : Async<Result<'okOutput[], 'error[]>> =
241
+ let xs = Nullness.nullArgCheck (nameof xs) xs
242
+
243
+ async {
244
+ match! state with
245
+ | Error failuresToDate ->
246
+ let errs = ResizeArray failuresToDate
247
+
248
+ for x in xs do
249
+ match! f x with
250
+ | Ok _ -> () // as the initial state was failure, oks are irrelevant
251
+ | Error e -> errs.Add e
252
+
253
+ return Error(errs.ToArray())
254
+ | Ok initialSuccesses ->
255
+
256
+ let oks = ResizeArray initialSuccesses
257
+ let errs = ResizeArray()
258
+
259
+ for x in xs do
260
+ match! f x with
261
+ | Ok r when errs.Count = 0 -> oks.Add r
262
+ | Ok _ -> () // no point saving results we won't use given the end result will be Error
263
+ | Error e -> errs.Add e
264
+
265
+ if errs.Count = 0 then
266
+ return Ok(oks.ToArray())
267
+ else
268
+ return Error(errs.ToArray())
269
+ }
270
+
271
+ /// <summary>
272
+ /// Applies a function to each element of a sequence and returns a single async result
273
+ /// </summary>
274
+ /// <param name="f">The function to apply to each element</param>
275
+ /// <param name="xs">The input sequence</param>
276
+ /// <returns>An async result with the ok elements in an array or an array of all errors occuring in the sequence</returns>
277
+ /// <remarks>This function is equivalent to <see cref="traverseAsyncResultA'"/> but applying an initial state of 'Seq.empty'</remarks>
278
+ let traverseAsyncResultA f xs =
279
+ traverseAsyncResultA' (async { return Ok Seq.empty }) f xs
280
+
281
+ /// <summary>
282
+ /// Converts a sequence of async results into a single async result
283
+ /// </summary>
284
+ /// <param name="xs">The input sequence</param>
285
+ /// <returns>An async result with all ok elements in an array or an error result with an array of all errors occuring in the sequence</returns>
286
+ /// <remarks>This function is equivalent to <see cref="traverseAsyncResultA"/> but auto-applying the 'id' function</remarks>
287
+ let sequenceAsyncResultA xs = traverseAsyncResultA id xs
288
+
289
+ #if !FABLE_COMPILER
290
+
291
+ /// <summary>
292
+ /// Applies a function to each element of a sequence and returns a single task result
293
+ /// </summary>
294
+ /// <param name="state">The initial state</param>
295
+ /// <param name="f">The function to apply to each element</param>
296
+ /// <param name="xs">The input sequence</param>
297
+ /// <returns>A task result with the ok elements in an array or an array of all errors from the state and the original sequence</returns>
298
+ let inline traverseTaskResultA'
299
+ (state: TaskResult<'okOutput seq, 'error seq>)
300
+ ([<InlineIfLambda>] f: 'okInput -> TaskResult<'okOutput, 'error>)
301
+ (xs: SeqNull<'okInput>)
302
+ : TaskResult<'okOutput[], 'error[]> =
303
+ let xs = Nullness.nullArgCheck (nameof xs) xs
304
+
305
+ task {
306
+ match! state with
307
+ | Error failuresToDate ->
308
+ let mutable errs = ArrayCollector()
309
+ errs.AddMany failuresToDate
310
+
311
+ for x in xs do
312
+ match! f x with
313
+ | Ok _ -> () // as the initial state was failure, oks are irrelevant
314
+ | Error e -> errs.Add e
315
+
316
+ return Error(errs.Close())
317
+ | Ok initialSuccesses ->
318
+
319
+ let mutable oks = ArrayCollector()
320
+ oks.AddMany initialSuccesses
321
+ let mutable ok = true
322
+ let mutable errs = ArrayCollector()
323
+
324
+ for x in xs do
325
+ match! f x with
326
+ | Ok r when ok -> oks.Add r
327
+ | Ok _ -> () // no point saving results we won't use given the end result will be Error
328
+ | Error e ->
329
+ errs.Add e
330
+ ok <- false
331
+
332
+ return if ok then Ok(oks.Close()) else Error(errs.Close())
333
+ }
334
+
335
+ /// <summary>
336
+ /// Applies a function to each element of a sequence and returns a single task result
337
+ /// </summary>
338
+ /// <param name="f">The function to apply to each element</param>
339
+ /// <param name="xs">The input sequence</param>
340
+ /// <returns>A task result with the ok elements in an array or an array of all errors occuring in the sequence</returns>
341
+ /// <remarks>This function is equivalent to <see cref="traverseTaskResultA'"/> but applying an initial state of 'Seq.empty'</remarks>
342
+ let traverseTaskResultA f xs =
343
+ traverseTaskResultA' (TaskResult.ok Seq.empty) f xs
344
+
345
+ /// <summary>
346
+ /// Converts a sequence of task results into a single task result
347
+ /// </summary>
348
+ /// <param name="xs">The input sequence</param>
349
+ /// <returns>A task result with all ok elements in an array or an error result with an array of all errors occuring in the sequence</returns>
350
+ /// <remarks>This function is equivalent to <see cref="traverseTaskResultA"/> but auto-applying the 'id' function</remarks>
351
+ let sequenceTaskResultA xs = traverseTaskResultA id xs
352
+
353
+ #endif
354
+
355
+ /// <summary>
356
+ /// Applies a function to each element of a sequence and returns a single option
357
+ /// </summary>
358
+ /// <param name="state">The initial state</param>
359
+ /// <param name="f">The function to apply to each element</param>
360
+ /// <param name="xs">The input sequence</param>
361
+ /// <returns>An option containing Some array of elements or None if any of the function applications return None</returns>
362
+ let inline traverseOptionM'
363
+ (state: seq<'okOutput> option)
364
+ ([<InlineIfLambda>] f: 'okInput -> 'okOutput option)
365
+ (xs: SeqNull<'okInput>)
366
+ : 'okOutput[] option =
367
+ if isNull xs then
368
+ nullArg (nameof xs)
369
+
370
+ match state with
371
+ | None -> None
372
+ | Some initialValues ->
373
+ let values = ResizeArray initialValues
374
+ let mutable ok = true
375
+ use enumerator = xs.GetEnumerator()
376
+
377
+ while ok
378
+ && enumerator.MoveNext() do
379
+ match f enumerator.Current with
380
+ | Some value -> values.Add value
381
+ | None -> ok <- false
382
+
383
+ if ok then Some(values.ToArray()) else None
384
+
385
+ /// <summary>
386
+ /// Applies a function to each element of a sequence and returns a single option
387
+ /// </summary>
388
+ /// <param name="f">The function to apply to each element</param>
389
+ /// <param name="xs">The input sequence</param>
390
+ /// <returns>An option containing Some array of elements or None if any of the function applications return None</returns>
391
+ /// <remarks>This function is equivalent to <see cref="traverseOptionM'"/> but applying an initial state of 'Seq.empty'</remarks>
392
+ let traverseOptionM f xs = traverseOptionM' (Some Seq.empty) f xs
393
+
394
+ /// <summary>
395
+ /// Converts a sequence of options into a single option
396
+ /// </summary>
397
+ /// <param name="xs">The input sequence</param>
398
+ /// <returns>An option containing Some array of elements or None if any of the function applications return None</returns>
399
+ /// <remarks>This function is equivalent to <see cref="traverseOptionM"/> but auto-applying the 'id' function</remarks>
400
+ let sequenceOptionM xs = traverseOptionM id xs
401
+
402
+ /// <summary>
403
+ /// Applies a function to each element of a sequence and returns a single async option
404
+ /// </summary>
405
+ /// <param name="state">The initial state</param>
406
+ /// <param name="f">The function to apply to each element</param>
407
+ /// <param name="xs">The input sequence</param>
408
+ /// <returns>An async option containing Some array of elements or None if any of the function applications return None</returns>
409
+ let inline traverseAsyncOptionM'
410
+ (state: Async<seq<'okOutput> option>)
411
+ ([<InlineIfLambda>] f: 'okInput -> Async<'okOutput option>)
412
+ (xs: SeqNull<'okInput>)
413
+ : Async<'okOutput[] option> =
414
+ if isNull xs then
415
+ nullArg (nameof xs)
416
+
417
+ async {
418
+ match! state with
419
+ | None -> return None
420
+ | Some initialValues ->
421
+ let values = ResizeArray initialValues
422
+ let mutable ok = true
423
+ use enumerator = xs.GetEnumerator()
424
+
425
+ while ok
426
+ && enumerator.MoveNext() do
427
+ match! f enumerator.Current with
428
+ | Some value -> values.Add value
429
+ | None -> ok <- false
430
+
431
+ return if ok then Some(values.ToArray()) else None
432
+ }
433
+
434
+ /// <summary>
435
+ /// Applies a function to each element of a sequence and returns a single async option
436
+ /// </summary>
437
+ /// <param name="f">The function to apply to each element</param>
438
+ /// <param name="xs">The input sequence</param>
439
+ /// <returns>An async option containing Some array of elements or None if any of the function applications return None</returns>
440
+ /// <remarks>This function is equivalent to <see cref="traverseAsyncOptionM'"/> but applying an initial state of 'Async { return Some Seq.empty }'</remarks>
441
+ let traverseAsyncOptionM f xs =
442
+ traverseAsyncOptionM' (async { return Some Seq.empty }) f xs
443
+
444
+ /// <summary>
445
+ /// Converts a sequence of async options into a single async option
446
+ /// </summary>
447
+ /// <param name="xs">The input sequence</param>
448
+ /// <returns>An async option containing Some array of elements or None if any of the function applications return None</returns>
449
+ /// <remarks>This function is equivalent to <see cref="traverseAsyncOptionM"/> but auto-applying the 'id' function</remarks>
450
+ let sequenceAsyncOptionM xs = traverseAsyncOptionM id xs
451
+
452
+ #if !FABLE_COMPILER
453
+
454
+ /// <summary>
455
+ /// Applies a function to each element of a sequence and returns a single voption
456
+ /// </summary>
457
+ /// <param name="state">The initial state</param>
458
+ /// <param name="f">The function to apply to each element</param>
459
+ /// <param name="xs">The input sequence</param>
460
+ /// <returns>A voption containing an Array of elements or None if any of the function applications return None</returns>
461
+ let inline traverseVOptionM'
462
+ (state: ValueOption<'okOutput seq>)
463
+ ([<InlineIfLambda>] f: 'okInput -> 'okOutput voption)
464
+ (xs: SeqNull<'okInput>)
465
+ : ValueOption<'okOutput[]> =
466
+ if isNull xs then
467
+ nullArg (nameof xs)
468
+
469
+ match state with
470
+ | ValueNone -> ValueNone
471
+ | ValueSome initialValues ->
472
+ let mutable values = ArrayCollector()
473
+ values.AddMany initialValues
474
+ let mutable ok = true
475
+ use enumerator = xs.GetEnumerator()
476
+
477
+ while ok
478
+ && enumerator.MoveNext() do
479
+ match f enumerator.Current with
480
+ | ValueSome value -> values.Add value
481
+ | ValueNone -> ok <- false
482
+
483
+ if ok then ValueSome(values.Close()) else ValueNone
484
+
485
+ /// <summary>
486
+ /// Applies a function to each element of a sequence and returns a single voption
487
+ /// </summary>
488
+ /// <param name="f">The function to apply to each element</param>
489
+ /// <param name="xs">The input sequence</param>
490
+ /// <returns>A voption containing Some array of elements or None if any of the function applications return None</returns>
491
+ /// <remarks>This function is equivalent to <see cref="traverseVOptionM'"/> but applying an initial state of 'ValueSome Seq.empty'</remarks>
492
+ let traverseVOptionM f xs =
493
+ traverseVOptionM' (ValueSome Seq.empty) f xs
494
+
495
+ /// <summary>
496
+ /// Converts a sequence of voptions into a single voption
497
+ /// </summary>
498
+ /// <param name="xs">The input sequence</param>
499
+ /// <returns>A voption containing Some array of elements or None if any of the function applications return None</returns>
500
+ /// <remarks>This function is equivalent to <see cref="traverseVOptionM"/> but auto-applying the 'id' function</remarks>
501
+ let sequenceVOptionM xs = traverseVOptionM id xs
502
+
503
+ #endif