@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.
Files changed (182) hide show
  1. package/dist/Glutinum.Converter/FsharpAST.js +38 -4
  2. package/dist/Glutinum.Converter/Generate.js +15 -7
  3. package/dist/Glutinum.Converter/GlueAST.js +45 -36
  4. package/dist/Glutinum.Converter/Hosting.js +918 -0
  5. package/dist/Glutinum.Converter/Merge.js +218 -82
  6. package/dist/Glutinum.Converter/Packages.js +44 -8
  7. package/dist/Glutinum.Converter/Printer.js +77 -49
  8. package/dist/Glutinum.Converter/Read.js +8 -8
  9. package/dist/Glutinum.Converter/Reader/ClassDeclaration.js +7 -7
  10. package/dist/Glutinum.Converter/Reader/Declaration.js +26 -26
  11. package/dist/Glutinum.Converter/Reader/Documentation.js +37 -36
  12. package/dist/Glutinum.Converter/Reader/ExportAssignment.js +5 -5
  13. package/dist/Glutinum.Converter/Reader/ExportDeclaration.js +31 -19
  14. package/dist/Glutinum.Converter/Reader/FunctionDeclaration.js +6 -7
  15. package/dist/Glutinum.Converter/Reader/IndexedAccessType.js +36 -29
  16. package/dist/Glutinum.Converter/Reader/InterfaceDeclaration.js +3 -3
  17. package/dist/Glutinum.Converter/Reader/MappedTypeNode.js +82 -4
  18. package/dist/Glutinum.Converter/Reader/ModuleDeclaration.js +3 -3
  19. package/dist/Glutinum.Converter/Reader/Node.js +20 -20
  20. package/dist/Glutinum.Converter/Reader/Parameters.js +7 -7
  21. package/dist/Glutinum.Converter/Reader/TypeAliasDeclaration.js +5 -5
  22. package/dist/Glutinum.Converter/Reader/TypeNode.js +291 -232
  23. package/dist/Glutinum.Converter/Reader/TypeOperatorNode.js +8 -8
  24. package/dist/Glutinum.Converter/Reader/TypeQueryNode.js +108 -40
  25. package/dist/Glutinum.Converter/Reader/TypeScriptReader.js +2 -2
  26. package/dist/Glutinum.Converter/Reader/Types.js +6 -6
  27. package/dist/Glutinum.Converter/Reader/UnionTypeNode.js +7 -6
  28. package/dist/Glutinum.Converter/Reader/Utils.js +106 -56
  29. package/dist/Glutinum.Converter/Transform.js +2057 -700
  30. package/dist/Glutinum.Converter/TypeScript.Extensions.js +194 -202
  31. package/dist/Glutinum.Converter/Utils/Naming.js +7 -0
  32. package/dist/Glutinum.Converter/Utils/String.js +2 -2
  33. package/dist/Program.js +38 -26
  34. package/dist/fable_modules/Fable.Promise.3.2.1/AsyncIterable.fs +89 -0
  35. package/dist/fable_modules/Fable.Promise.3.2.1/AsyncIterable.fs.js +105 -0
  36. package/dist/fable_modules/Fable.Promise.3.2.1/Fable.Promise.fableproj +25 -0
  37. package/dist/fable_modules/Fable.Promise.3.2.1/Promise.fs +842 -0
  38. package/dist/fable_modules/Fable.Promise.3.2.1/Promise.fs.js +232 -0
  39. package/dist/fable_modules/Fable.Promise.3.2.1/PromiseImpl.fs +31 -0
  40. package/dist/fable_modules/Fable.Promise.3.2.1/PromiseImpl.fs.js +20 -0
  41. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Array.fs +235 -0
  42. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Array.fs.js +384 -0
  43. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AssemblyInfo.fs +19 -0
  44. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Async.fs +287 -0
  45. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Async.fs.js +128 -0
  46. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncOption.fs +127 -0
  47. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncOptionCE.fs +174 -0
  48. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncOptionCE.fs.js +37 -0
  49. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncOptionOp.fs +24 -0
  50. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncResult.fs +483 -0
  51. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncResultCE.fs +201 -0
  52. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncResultCE.fs.js +18 -0
  53. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncResultOp.fs +24 -0
  54. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncResultOption.fs +87 -0
  55. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncResultOption.fs.js +26 -0
  56. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncResultOptionCE.fs +236 -0
  57. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncResultOptionCE.fs.js +18 -0
  58. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncResultOptionOp.fs +24 -0
  59. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncValidation.fs +185 -0
  60. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncValidationCE.fs +186 -0
  61. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncValidationCE.fs.js +18 -0
  62. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncValidationOp.fs +35 -0
  63. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/FsToolkit.ErrorHandling.fableproj +69 -0
  64. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/List.fs +276 -0
  65. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/List.fs.js +364 -0
  66. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Nullness.fs +81 -0
  67. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Option.fs +462 -0
  68. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/OptionCE.fs +139 -0
  69. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/OptionCE.fs.js +48 -0
  70. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/OptionOp.fs +21 -0
  71. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ParallelAsyncResult.fs +88 -0
  72. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ParallelAsyncResult.fs.js +30 -0
  73. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ParallelAsyncResultCE.fs +200 -0
  74. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ParallelAsyncResultCE.fs.js +18 -0
  75. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ParallelAsyncValidation.fs +34 -0
  76. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ParallelAsyncValidationCE.fs +244 -0
  77. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ParallelAsyncValidationCE.fs.js +18 -0
  78. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Result.fs +731 -0
  79. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Result.fs.js +45 -0
  80. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ResultCE.fs +140 -0
  81. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ResultCE.fs.js +23 -0
  82. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ResultOp.fs +45 -0
  83. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ResultOption.fs +201 -0
  84. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ResultOption.fs.js +65 -0
  85. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ResultOptionCE.fs +135 -0
  86. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ResultOptionCE.fs.js +18 -0
  87. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ResultOptionOp.fs +57 -0
  88. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Seq.fs +503 -0
  89. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Seq.fs.js +295 -0
  90. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Validation.fs +167 -0
  91. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ValidationCE.fs +142 -0
  92. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ValidationCE.fs.js +18 -0
  93. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ValidationOp.fs +35 -0
  94. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ValueOption.fs +148 -0
  95. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ValueTaskValueOption.fs +102 -0
  96. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ValueTaskValueOptionCE.fs +587 -0
  97. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ValueTaskValueOptionOp.fs +10 -0
  98. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/obj/Debug/netstandard2.1/.NETStandard,Version=v2.1.AssemblyAttributes.fs +3 -0
  99. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/obj/Debug/netstandard2.1/FsToolkit.ErrorHandling.AssemblyInfo.fs +20 -0
  100. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/obj/Release/net9.0/.NETCoreApp,Version=v9.0.AssemblyAttributes.fs +3 -0
  101. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/obj/Release/net9.0/FsToolkit.ErrorHandling.AssemblyInfo.fs +20 -0
  102. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/obj/Release/netstandard2.0/.NETStandard,Version=v2.0.AssemblyAttributes.fs +3 -0
  103. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/obj/Release/netstandard2.0/FsToolkit.ErrorHandling.AssemblyInfo.fs +20 -0
  104. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/obj/Release/netstandard2.1/.NETStandard,Version=v2.1.AssemblyAttributes.fs +3 -0
  105. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/obj/Release/netstandard2.1/FsToolkit.ErrorHandling.AssemblyInfo.fs +20 -0
  106. package/dist/fable_modules/fable-library-js.5.17.2/Array.js +1348 -0
  107. package/dist/fable_modules/fable-library-js.5.17.2/Async.js +163 -0
  108. package/dist/fable_modules/fable-library-js.5.17.2/AsyncBuilder.js +204 -0
  109. package/dist/fable_modules/fable-library-js.5.17.2/BigInt.js +307 -0
  110. package/dist/fable_modules/fable-library-js.5.17.2/BitConverter.js +138 -0
  111. package/dist/fable_modules/fable-library-js.5.17.2/Boolean.js +22 -0
  112. package/dist/fable_modules/fable-library-js.5.17.2/CHANGELOG.md +348 -0
  113. package/dist/fable_modules/fable-library-js.5.17.2/Char.js +202 -0
  114. package/dist/fable_modules/fable-library-js.5.17.2/Choice.js +184 -0
  115. package/dist/fable_modules/fable-library-js.5.17.2/CollectionUtil.js +182 -0
  116. package/dist/fable_modules/fable-library-js.5.17.2/ConditionalWeakTable.js +21 -0
  117. package/dist/fable_modules/fable-library-js.5.17.2/Date.js +834 -0
  118. package/dist/fable_modules/fable-library-js.5.17.2/DateOffset.js +252 -0
  119. package/dist/fable_modules/fable-library-js.5.17.2/DateOnly.js +124 -0
  120. package/dist/fable_modules/fable-library-js.5.17.2/DateOnlyTemporal.js +146 -0
  121. package/dist/fable_modules/fable-library-js.5.17.2/DateTimeFormat.js +523 -0
  122. package/dist/fable_modules/fable-library-js.5.17.2/DateTimeOffsetTemporal.js +283 -0
  123. package/dist/fable_modules/fable-library-js.5.17.2/DateTimeTemporal.js +243 -0
  124. package/dist/fable_modules/fable-library-js.5.17.2/Decimal.js +238 -0
  125. package/dist/fable_modules/fable-library-js.5.17.2/Directory.js +11 -0
  126. package/dist/fable_modules/fable-library-js.5.17.2/Double.js +53 -0
  127. package/dist/fable_modules/fable-library-js.5.17.2/Encoding.js +185 -0
  128. package/dist/fable_modules/fable-library-js.5.17.2/Environment.js +3 -0
  129. package/dist/fable_modules/fable-library-js.5.17.2/Event.js +102 -0
  130. package/dist/fable_modules/fable-library-js.5.17.2/FSharp.Collections.js +45 -0
  131. package/dist/fable_modules/fable-library-js.5.17.2/FSharp.Core.CompilerServices.js +27 -0
  132. package/dist/fable_modules/fable-library-js.5.17.2/FSharp.Core.js +156 -0
  133. package/dist/fable_modules/fable-library-js.5.17.2/File.js +27 -0
  134. package/dist/fable_modules/fable-library-js.5.17.2/Global.js +29 -0
  135. package/dist/fable_modules/fable-library-js.5.17.2/Guid.js +163 -0
  136. package/dist/fable_modules/fable-library-js.5.17.2/Int32.js +135 -0
  137. package/dist/fable_modules/fable-library-js.5.17.2/List.js +1337 -0
  138. package/dist/fable_modules/fable-library-js.5.17.2/Long.js +38 -0
  139. package/dist/fable_modules/fable-library-js.5.17.2/MailboxProcessor.js +100 -0
  140. package/dist/fable_modules/fable-library-js.5.17.2/Map.js +1400 -0
  141. package/dist/fable_modules/fable-library-js.5.17.2/MapUtil.js +130 -0
  142. package/dist/fable_modules/fable-library-js.5.17.2/MutableMap.js +339 -0
  143. package/dist/fable_modules/fable-library-js.5.17.2/MutableSet.js +233 -0
  144. package/dist/fable_modules/fable-library-js.5.17.2/Native.js +14 -0
  145. package/dist/fable_modules/fable-library-js.5.17.2/Numeric.js +112 -0
  146. package/dist/fable_modules/fable-library-js.5.17.2/Observable.js +115 -0
  147. package/dist/fable_modules/fable-library-js.5.17.2/Option.js +87 -0
  148. package/dist/fable_modules/fable-library-js.5.17.2/Path.js +31 -0
  149. package/dist/fable_modules/fable-library-js.5.17.2/README.md +3 -0
  150. package/dist/fable_modules/fable-library-js.5.17.2/Random.js +172 -0
  151. package/dist/fable_modules/fable-library-js.5.17.2/Range.js +45 -0
  152. package/dist/fable_modules/fable-library-js.5.17.2/Reflection.js +489 -0
  153. package/dist/fable_modules/fable-library-js.5.17.2/RegExp.js +170 -0
  154. package/dist/fable_modules/fable-library-js.5.17.2/Result.js +165 -0
  155. package/dist/fable_modules/fable-library-js.5.17.2/Seq.js +1504 -0
  156. package/dist/fable_modules/fable-library-js.5.17.2/Seq2.js +111 -0
  157. package/dist/fable_modules/fable-library-js.5.17.2/Set.js +1829 -0
  158. package/dist/fable_modules/fable-library-js.5.17.2/String.js +731 -0
  159. package/dist/fable_modules/fable-library-js.5.17.2/System.Collections.Generic.js +333 -0
  160. package/dist/fable_modules/fable-library-js.5.17.2/System.Text.js +200 -0
  161. package/dist/fable_modules/fable-library-js.5.17.2/System.js +289 -0
  162. package/dist/fable_modules/fable-library-js.5.17.2/Task.js +27 -0
  163. package/dist/fable_modules/fable-library-js.5.17.2/TaskBuilder.js +72 -0
  164. package/dist/fable_modules/fable-library-js.5.17.2/TimeOnly.js +122 -0
  165. package/dist/fable_modules/fable-library-js.5.17.2/TimeOnlyTemporal.js +142 -0
  166. package/dist/fable_modules/fable-library-js.5.17.2/TimeSpan.js +180 -0
  167. package/dist/fable_modules/fable-library-js.5.17.2/TimeSpanTemporal.js +259 -0
  168. package/dist/fable_modules/fable-library-js.5.17.2/Timer.js +67 -0
  169. package/dist/fable_modules/fable-library-js.5.17.2/Types.js +198 -0
  170. package/dist/fable_modules/fable-library-js.5.17.2/Unicode.13.0.0.js +4 -0
  171. package/dist/fable_modules/fable-library-js.5.17.2/Uri.js +165 -0
  172. package/dist/fable_modules/fable-library-js.5.17.2/Util.js +807 -0
  173. package/dist/fable_modules/fable-library-js.5.17.2/big.d.ts +338 -0
  174. package/dist/fable_modules/fable-library-js.5.17.2/lib/big.js +829 -0
  175. package/dist/fable_modules/fable-library-js.5.17.2/package.json +24 -0
  176. package/dist/fable_modules/fable-library-js.5.17.2/quotation.js +682 -0
  177. package/package.json +2 -2
  178. package/dist/Glutinum.Converter/TypeScript.js +0 -12
  179. package/src/Glutinum.Converter/js/bootstrap.js +0 -123
  180. package/src/Glutinum.Converter/js/host.js +0 -144
  181. package/src/Glutinum.Converter/js/npm.js +0 -137
  182. package/src/Glutinum.Converter/js/resolve.js +0 -402
@@ -0,0 +1,186 @@
1
+ namespace FsToolkit.ErrorHandling
2
+
3
+ open System
4
+
5
+ [<AutoOpen>]
6
+ module AsyncValidationCE =
7
+
8
+ type AsyncValidationBuilder() =
9
+ member inline _.Return(value: 'ok) : AsyncValidation<'ok, 'error> = AsyncValidation.ok value
10
+
11
+ member inline _.ReturnFrom
12
+ (result: AsyncValidation<'ok, 'error>)
13
+ : AsyncValidation<'ok, 'error> =
14
+ result
15
+
16
+ member inline _.Bind
17
+ (
18
+ result: AsyncValidation<'okInput, 'error>,
19
+ [<InlineIfLambda>] binder: 'okInput -> AsyncValidation<'okOutput, 'error>
20
+ ) : AsyncValidation<'okOutput, 'error> =
21
+ AsyncValidation.bind binder result
22
+
23
+ member inline this.Zero() : AsyncValidation<unit, 'error> = this.Return()
24
+
25
+ member inline _.Delay
26
+ ([<InlineIfLambda>] generator: unit -> AsyncValidation<'ok, 'error>)
27
+ : AsyncValidation<'ok, 'error> =
28
+ async.Delay generator
29
+
30
+ member inline this.Combine
31
+ (validation1: AsyncValidation<unit, 'error>, validation2: AsyncValidation<'ok, 'error>)
32
+ : AsyncValidation<'ok, 'error> =
33
+ this.Bind(validation1, (fun () -> validation2))
34
+
35
+ member inline _.TryWith
36
+ (
37
+ computation: AsyncValidation<'ok, 'error>,
38
+ [<InlineIfLambda>] handler: exn -> AsyncValidation<'ok, 'error>
39
+ ) : AsyncValidation<'ok, 'error> =
40
+ async.TryWith(computation, handler)
41
+
42
+ member inline _.TryFinally
43
+ (
44
+ computation: AsyncValidation<'ok, 'error>,
45
+ [<InlineIfLambda>] compensation: unit -> unit
46
+ ) : AsyncValidation<'ok, 'error> =
47
+ async.TryFinally(computation, compensation)
48
+
49
+ member inline _.Using
50
+ (
51
+ resource: 'disposable :> IDisposableNull,
52
+ [<InlineIfLambda>] binder: 'disposable -> AsyncValidation<'okOutput, 'error>
53
+ ) : AsyncValidation<'okOutput, 'error> =
54
+ async.Using(resource, binder)
55
+
56
+ member inline this.While
57
+ ([<InlineIfLambda>] guard: unit -> bool, computation: AsyncValidation<unit, 'error>)
58
+ : AsyncValidation<unit, 'error> =
59
+ if guard () then
60
+ let mutable whileAsync = Unchecked.defaultof<_>
61
+
62
+ whileAsync <-
63
+ this.Bind(computation, (fun () -> if guard () then whileAsync else this.Zero()))
64
+
65
+ whileAsync
66
+ else
67
+ this.Zero()
68
+
69
+
70
+ member inline this.For
71
+ (sequence: #seq<'ok>, [<InlineIfLambda>] binder: 'ok -> AsyncValidation<unit, 'error>)
72
+ : AsyncValidation<unit, 'error> =
73
+ this.Using(
74
+ sequence.GetEnumerator(),
75
+ fun enum -> this.While(enum.MoveNext, this.Delay(fun () -> binder enum.Current))
76
+ )
77
+
78
+ member inline _.BindReturn
79
+ (
80
+ input: AsyncValidation<'okInput, 'error>,
81
+ [<InlineIfLambda>] mapper: 'okInput -> 'okOutput
82
+ ) : AsyncValidation<'okOutput, 'error> =
83
+ AsyncValidation.map mapper input
84
+
85
+ member inline _.MergeSources
86
+ (left: AsyncValidation<'left, 'error>, right: AsyncValidation<'right, 'error>)
87
+ : AsyncValidation<'left * 'right, 'error> =
88
+ AsyncValidation.zip left right
89
+
90
+ let asyncValidation = AsyncValidationBuilder()
91
+
92
+ [<AutoOpen>]
93
+ module LowPriority =
94
+
95
+ type AsyncValidationBuilder with
96
+
97
+ /// <summary>
98
+ /// Method lets us transform data types into our internal representation.
99
+ /// </summary>
100
+ /// <returns></returns>
101
+ member inline _.Source(a: Async<'ok>) : AsyncValidation<'ok, 'error> =
102
+ async {
103
+ let! result = a
104
+ return! AsyncValidation.ok result
105
+ }
106
+
107
+ /// <summary>
108
+ /// Method lets us transform data types into our internal representation.
109
+ /// </summary>
110
+ member inline _.Source(s: Result<'ok, 'error>) : AsyncValidation<'ok, 'error> =
111
+ AsyncValidation.ofResult s
112
+
113
+ /// <summary>
114
+ /// Method lets us transform data types into our internal representation.
115
+ /// </summary>
116
+ /// <returns></returns>
117
+ member inline _.Source(choice: Choice<'ok, 'error>) : AsyncValidation<'ok, 'error> =
118
+ AsyncValidation.ofChoice choice
119
+
120
+ /// <summary>
121
+ /// Needed to allow `for..in` and `for..do` functionality
122
+ /// </summary>
123
+ member inline _.Source(s: #seq<_>) : #seq<_> = s
124
+
125
+ [<AutoOpen>]
126
+ module MediumPriority =
127
+
128
+ open System.Threading.Tasks
129
+
130
+ type AsyncValidationBuilder with
131
+
132
+ /// <summary>
133
+ /// Method lets us transform data types into our internal representation.
134
+ /// </summary>
135
+ member inline _.Source(s: Async<Result<'ok, 'error>>) : AsyncValidation<'ok, 'error> =
136
+ AsyncResult.mapError List.singleton s
137
+
138
+ #if !FABLE_COMPILER
139
+
140
+ /// <summary>
141
+ /// Method lets us transform data types into our internal representation.
142
+ /// </summary>
143
+ member inline _.Source(s: Task<Result<'ok, 'error>>) : AsyncValidation<'ok, 'error> =
144
+ Async.AwaitTask s
145
+ |> AsyncResult.mapError List.singleton
146
+
147
+ #endif
148
+
149
+ [<AutoOpen>]
150
+ module HighPriority =
151
+
152
+ open System.Threading.Tasks
153
+
154
+ // Having members as extensions gives them lower priority in
155
+ // overload resolution and allows skipping more type annotations.
156
+ type AsyncValidationBuilder with
157
+
158
+ /// <summary>
159
+ /// Method lets us transform data types into our internal representation.
160
+ /// </summary>
161
+ member inline _.Source(s: Validation<'ok, 'error>) : AsyncValidation<'ok, 'error> =
162
+ Async.singleton s
163
+
164
+ #if !FABLE_COMPILER
165
+
166
+ /// <summary>
167
+ /// Method lets us transform data types into our internal representation.
168
+ /// </summary>
169
+ member inline _.Source
170
+ (result: Task<Validation<'ok, 'error>>)
171
+ : AsyncValidation<'ok, 'error> =
172
+ Async.AwaitTask result
173
+
174
+ #endif
175
+
176
+ /// <summary>
177
+ /// Method lets us transform data types into our internal representation. This is the identity method to recognize the self type.
178
+ ///
179
+ /// See https://stackoverflow.com/questions/35286541/why-would-you-use-builder-source-in-a-custom-computation-expression-builder
180
+ /// </summary>
181
+ /// <param name="result"></param>
182
+ /// <returns></returns>
183
+ member inline _.Source
184
+ (result: AsyncValidation<'ok, 'error>)
185
+ : AsyncValidation<'ok, 'error> =
186
+ result
@@ -0,0 +1,18 @@
1
+
2
+ import { class_type } from "../fable-library-js.5.17.2/Reflection.js";
3
+
4
+ export class AsyncValidationBuilder {
5
+ constructor() {
6
+ }
7
+ }
8
+
9
+ export function AsyncValidationBuilder_$reflection() {
10
+ return class_type("FsToolkit.ErrorHandling.AsyncValidationCE.AsyncValidationBuilder", undefined, AsyncValidationBuilder);
11
+ }
12
+
13
+ export function AsyncValidationBuilder_$ctor() {
14
+ return new AsyncValidationBuilder();
15
+ }
16
+
17
+ export const asyncValidation = AsyncValidationBuilder_$ctor();
18
+
@@ -0,0 +1,35 @@
1
+ namespace FsToolkit.ErrorHandling.Operator.AsyncValidation
2
+
3
+ open FsToolkit.ErrorHandling
4
+
5
+ [<AutoOpen>]
6
+ module AsyncValidation =
7
+ let inline (<!>)
8
+ ([<InlineIfLambda>] mapper: 'okInput -> 'okOutput)
9
+ (input: AsyncValidation<'okInput, 'error>)
10
+ : AsyncValidation<'okOutput, 'error> =
11
+ AsyncValidation.map mapper input
12
+
13
+ let inline (<!^>)
14
+ ([<InlineIfLambda>] mapper: 'okInput -> 'okOutput)
15
+ (input: Result<'okInput, 'error>)
16
+ : AsyncValidation<'okOutput, 'error> =
17
+ AsyncValidation.map mapper (AsyncValidation.ofResult input)
18
+
19
+ let inline (<*>)
20
+ (applier: AsyncValidation<('okInput -> 'okOutput), 'error>)
21
+ (input: AsyncValidation<'okInput, 'error>)
22
+ : AsyncValidation<'okOutput, 'error> =
23
+ AsyncValidation.apply applier input
24
+
25
+ let inline (<*^>)
26
+ (applier: AsyncValidation<('okInput -> 'okOutput), 'error>)
27
+ (input: Result<'okInput, 'error>)
28
+ : AsyncValidation<'okOutput, 'error> =
29
+ AsyncValidation.apply applier (AsyncValidation.ofResult input)
30
+
31
+ let inline (>>=)
32
+ (input: AsyncValidation<'okInput, 'error>)
33
+ ([<InlineIfLambda>] binder: 'okInput -> AsyncValidation<'okOutput, 'error>)
34
+ : AsyncValidation<'okOutput, 'error> =
35
+ AsyncValidation.bind binder input
@@ -0,0 +1,69 @@
1
+ <Project Sdk="Microsoft.NET.Sdk">
2
+ <PropertyGroup>
3
+ <OutputType>Library</OutputType>
4
+ <TargetFrameworks>netstandard2.1;netstandard2.0;net9.0</TargetFrameworks>
5
+ <DebugType>portable</DebugType>
6
+ <NoWarn>$(NoWarn);FS1204;FS3511;FS3513;FS0057</NoWarn>
7
+ <PackageTags>$(PackageTags), fable-library, fable-dotnet, fable-javascript, fable-python</PackageTags>
8
+ </PropertyGroup>
9
+ <ItemGroup>
10
+ <Compile Include="Nullness.fs" />
11
+ <Compile Include="Result.fs" />
12
+ <Compile Include="ResultCE.fs" />
13
+ <Compile Include="ResultOp.fs" />
14
+ <Compile Include="Option.fs" />
15
+ <Compile Include="ValueOption.fs" />
16
+ <Compile Include="OptionCE.fs" />
17
+ <Compile Include="OptionOp.fs" />
18
+ <Compile Include="ResultOption.fs" />
19
+ <Compile Include="ResultOptionCE.fs" />
20
+ <Compile Include="ResultOptionOp.fs" />
21
+ <Compile Include="Async.fs" />
22
+ <Compile Include="Task.fs" Condition="'$(FABLE_COMPILER)' != 'true'" />
23
+ <Compile Include="TaskOp.fs" Condition="'$(FABLE_COMPILER)' != 'true'" />
24
+ <Compile Include="AsyncResult.fs" />
25
+ <Compile Include="AsyncResultCE.fs" />
26
+ <Compile Include="AsyncResultOp.fs" />
27
+ <Compile Include="TaskResult.fs" Condition="'$(FABLE_COMPILER)' != 'true'" />
28
+ <Compile Include="TaskResultCE.fs" Condition="'$(FABLE_COMPILER)' != 'true'" />
29
+ <Compile Include="TaskResultOp.fs" Condition="'$(FABLE_COMPILER)' != 'true'" />
30
+ <Compile Include="Validation.fs" />
31
+ <Compile Include="ValidationOp.fs" />
32
+ <Compile Include="ValidationCE.fs" />
33
+ <Compile Include="AsyncValidation.fs" />
34
+ <Compile Include="AsyncValidationOp.fs" />
35
+ <Compile Include="AsyncValidationCE.fs" />
36
+ <Compile Include="TaskValidation.fs" Condition="'$(FABLE_COMPILER)' != 'true'" />
37
+ <Compile Include="TaskValidationOp.fs" Condition="'$(FABLE_COMPILER)' != 'true'" />
38
+ <Compile Include="TaskValidationCE.fs" Condition="'$(FABLE_COMPILER)' != 'true'" />
39
+ <Compile Include="AsyncOption.fs" />
40
+ <Compile Include="AsyncOptionCE.fs" />
41
+ <Compile Include="AsyncOptionOp.fs" />
42
+ <Compile Include="TaskOption.fs" Condition="'$(FABLE_COMPILER)' != 'true'" />
43
+ <Compile Include="TaskValueOption.fs" Condition="'$(FABLE_COMPILER)' != 'true'" />
44
+ <Compile Include="ValueTaskValueOption.fs" Condition="'$(FABLE_COMPILER)' != 'true'" />
45
+ <Compile Include="TaskOptionCE.fs" Condition="'$(FABLE_COMPILER)' != 'true'" />
46
+ <Compile Include="TaskValueOptionCE.fs" Condition="'$(FABLE_COMPILER)' != 'true'" />
47
+ <Compile Include="ValueTaskValueOptionCE.fs" Condition="'$(FABLE_COMPILER)' != 'true'" />
48
+ <Compile Include="TaskOptionOp.fs" Condition="'$(FABLE_COMPILER)' != 'true'" />
49
+ <Compile Include="TaskValueOptionOp.fs" Condition="'$(FABLE_COMPILER)' != 'true'" />
50
+ <Compile Include="ValueTaskValueOptionOp.fs" Condition="'$(FABLE_COMPILER)' != 'true'" />
51
+ <Compile Include="AsyncResultOption.fs" />
52
+ <Compile Include="AsyncResultOptionCE.fs" />
53
+ <Compile Include="AsyncResultOptionOp.fs" />
54
+ <Compile Include="TaskResultOption.fs" Condition="'$(FABLE_COMPILER)' != 'true'" />
55
+ <Compile Include="TaskResultOptionCE.fs" Condition="'$(FABLE_COMPILER)' != 'true'" />
56
+ <Compile Include="TaskResultOptionOp.fs" Condition="'$(FABLE_COMPILER)' != 'true'" />
57
+ <Compile Include="ParallelAsyncResult.fs" />
58
+ <Compile Include="ParallelAsyncResultCE.fs" />
59
+ <Compile Include="ParallelAsyncValidation.fs" />
60
+ <Compile Include="ParallelAsyncValidationCE.fs" />
61
+ <Compile Include="List.fs" />
62
+ <Compile Include="Array.fs" />
63
+ <Compile Include="Seq.fs" />
64
+ <None Include="Script.fsx" />
65
+ </ItemGroup>
66
+ <ItemGroup>
67
+ <Content Include="*.fsproj; **\*.fs" Exclude="Task.fs; **\Task*.fs" PackagePath="fable\" />
68
+ </ItemGroup>
69
+ </Project>
@@ -0,0 +1,276 @@
1
+ namespace FsToolkit.ErrorHandling
2
+
3
+ [<RequireQualifiedAccess>]
4
+ module List =
5
+
6
+ let rec private traverseResultM' (state: Result<_, _>) (f: _ -> Result<_, _>) xs =
7
+ match xs with
8
+ | [] ->
9
+ state
10
+ |> Result.map List.rev
11
+ | x :: xs ->
12
+ let r =
13
+ result {
14
+ let! y = f x
15
+ let! ys = state
16
+ return y :: ys
17
+ }
18
+
19
+ match r with
20
+ | Ok _ -> traverseResultM' r f xs
21
+ | Error _ -> r
22
+
23
+ let rec private traverseAsyncResultM'
24
+ (state: Async<Result<_, _>>)
25
+ (f: _ -> Async<Result<_, _>>)
26
+ xs
27
+ =
28
+ match xs with
29
+ | [] ->
30
+ state
31
+ |> AsyncResult.map List.rev
32
+ | x :: xs ->
33
+ async {
34
+ let! r =
35
+ asyncResult {
36
+ let! ys = state
37
+ let! y = f x
38
+ return y :: ys
39
+ }
40
+
41
+ match r with
42
+ | Ok _ -> return! traverseAsyncResultM' (Async.singleton r) f xs
43
+ | Error _ -> return r
44
+ }
45
+
46
+ let traverseResultM f xs = traverseResultM' (Ok []) f xs
47
+
48
+ let sequenceResultM xs = traverseResultM id xs
49
+
50
+ let traverseAsyncResultM f xs =
51
+ traverseAsyncResultM' (AsyncResult.ok []) f xs
52
+
53
+ let sequenceAsyncResultM xs = traverseAsyncResultM id xs
54
+
55
+ let rec private traverseResultA' state f xs =
56
+ match xs with
57
+ | [] ->
58
+ state
59
+ |> Result.eitherMap List.rev List.rev
60
+ | x :: xs ->
61
+
62
+ match state, f x with
63
+ | Ok ys, Ok y -> traverseResultA' (Ok(y :: ys)) f xs
64
+ | Error errs, Error e -> traverseResultA' (Error(e :: errs)) f xs
65
+ | Ok _, Error e -> traverseResultA' (Error [ e ]) f xs
66
+ | Error e, Ok _ -> traverseResultA' (Error e) f xs
67
+
68
+ let rec private traverseAsyncResultA' state f xs =
69
+ match xs with
70
+ | [] ->
71
+ state
72
+ |> AsyncResult.eitherMap List.rev List.rev
73
+
74
+ | x :: xs ->
75
+ async {
76
+ let! s = state
77
+ let! fR = f x
78
+
79
+ match s, fR with
80
+ | Ok ys, Ok y -> return! traverseAsyncResultA' (AsyncResult.ok (y :: ys)) f xs
81
+ | Error errs, Error e ->
82
+ return! traverseAsyncResultA' (AsyncResult.error (e :: errs)) f xs
83
+ | Ok _, Error e -> return! traverseAsyncResultA' (AsyncResult.error [ e ]) f xs
84
+ | Error e, Ok _ -> return! traverseAsyncResultA' (AsyncResult.error e) f xs
85
+ }
86
+
87
+ let traverseResultA f xs = traverseResultA' (Ok []) f xs
88
+
89
+ let sequenceResultA xs = traverseResultA id xs
90
+
91
+ let rec private traverseValidationA' state f xs =
92
+ match xs with
93
+ | [] ->
94
+ state
95
+ |> Result.eitherMap List.rev List.rev
96
+ | x :: xs ->
97
+ let fR = f x
98
+
99
+ match state, fR with
100
+ | Ok ys, Ok y -> traverseValidationA' (Ok(y :: ys)) f xs
101
+ | Error errs1, Error errs2 ->
102
+ traverseValidationA'
103
+ (Error(
104
+ errs2
105
+ @ errs1
106
+ ))
107
+ f
108
+ xs
109
+ | Ok _, Error errs
110
+ | Error errs, Ok _ -> traverseValidationA' (Error errs) f xs
111
+
112
+ let traverseValidationA f xs = traverseValidationA' (Ok []) f xs
113
+
114
+ let sequenceValidationA xs = traverseValidationA id xs
115
+
116
+ let traverseAsyncResultA f xs =
117
+ traverseAsyncResultA' (AsyncResult.ok []) f xs
118
+
119
+ let sequenceAsyncResultA xs = traverseAsyncResultA id xs
120
+
121
+ let rec private traverseOptionM' (state: _ option) (f: _ -> _ option) xs =
122
+ match xs with
123
+ | [] ->
124
+ state
125
+ |> Option.map List.rev
126
+ | x :: xs ->
127
+ let r =
128
+ option {
129
+ let! y = f x
130
+ let! ys = state
131
+ return y :: ys
132
+ }
133
+
134
+ match r with
135
+ | Some _ -> traverseOptionM' r f xs
136
+ | None -> r
137
+
138
+ let rec private traverseAsyncOptionM' (state: Async<_ option>) (f: _ -> Async<_ option>) xs =
139
+ match xs with
140
+ | [] ->
141
+ state
142
+ |> AsyncOption.map List.rev
143
+ | x :: xs ->
144
+ async {
145
+ let! o =
146
+ asyncOption {
147
+ let! y = f x
148
+ let! ys = state
149
+ return y :: ys
150
+ }
151
+
152
+ match o with
153
+ | Some _ -> return! traverseAsyncOptionM' (Async.singleton o) f xs
154
+ | None -> return o
155
+ }
156
+
157
+ /// <summary>
158
+ /// Applies the given function <paramref name="f"/> to each element in the input list <paramref name="xs"/>,
159
+ /// and returns an option containing a list of the results. If any of the function applications return None,
160
+ /// the entire result will be None.
161
+ /// </summary>
162
+ /// <param name="f">The function to apply to each element in the input list.</param>
163
+ /// <param name="xs">The input list.</param>
164
+ /// <returns>An option containing a list of the results of applying the function to each element in the input list,
165
+ /// or None if any of the function applications return None.</returns>
166
+ let traverseOptionM f xs = traverseOptionM' (Some []) f xs
167
+
168
+ /// <summary>
169
+ /// Applies the monadic function <paramref name="id"/> to each element in the input list <paramref name="xs"/>,
170
+ /// and returns the result as an option. If any element in the list is None, the entire result will be None.
171
+ /// </summary>
172
+ /// <param name="xs">The input list.</param>
173
+ /// <returns>An option containing the result of applying <paramref name="id"/> to each element in <paramref name="xs"/>.</returns>
174
+ let sequenceOptionM xs = traverseOptionM id xs
175
+
176
+ let traverseAsyncOptionM f xs =
177
+ traverseAsyncOptionM' (AsyncOption.some []) f xs
178
+
179
+ let sequenceAsyncOptionM xs = traverseAsyncOptionM id xs
180
+
181
+ #if !FABLE_COMPILER
182
+ let rec private traverseVOptionM' (state: voption<_>) (f: _ -> voption<_>) xs =
183
+ match xs with
184
+ | [] ->
185
+ state
186
+ |> ValueOption.map List.rev
187
+ | x :: xs ->
188
+ let r =
189
+ voption {
190
+ let! y = f x
191
+ let! ys = state
192
+ return y :: ys
193
+ }
194
+
195
+ match r with
196
+ | ValueSome _ -> traverseVOptionM' r f xs
197
+ | ValueNone -> r
198
+
199
+ /// <summary>
200
+ /// Applies the given function <paramref name="f"/> to each element in the input list <paramref name="xs"/>,
201
+ /// and returns an option containing a list of the results. If any of the function applications return ValueNone,
202
+ /// the entire result will be ValueNone.
203
+ /// </summary>
204
+ /// <param name="f">The function to apply to each element in the input list.</param>
205
+ /// <param name="xs">The input list</param>
206
+ /// <returns>An Option monad containing the collected results.</returns>
207
+ let traverseVOptionM f xs = traverseVOptionM' (ValueSome []) f xs
208
+
209
+ /// <summary>
210
+ /// Applies the <paramref name="id"/> function to each element in the input list <paramref name="xs"/>,
211
+ /// and returns the result as a value option. If any element in the list is ValueNone, the entire result will be ValueNone.
212
+ /// </summary>
213
+ /// <param name="xs">The input list.</param>
214
+ /// <returns>A <see cref="Option{T}"/> representing the sequence of results.</returns>
215
+ let sequenceVOptionM xs = traverseVOptionM id xs
216
+
217
+
218
+ open System.Threading.Tasks
219
+
220
+ let private traverseTaskResultM' (f: 'c -> Task<Result<'a, 'b>>) (xs: 'c list) =
221
+ let mutable state = Ok []
222
+ let mutable index = 0
223
+
224
+ let xs =
225
+ xs
226
+ |> List.toArray
227
+
228
+ task {
229
+ while state
230
+ |> Result.isOk
231
+ && index < xs.Length do
232
+ let! r =
233
+ xs
234
+ |> Array.item index
235
+ |> f
236
+
237
+ index <- index + 1
238
+
239
+ match (r, state) with
240
+ | Ok y, Ok ys -> state <- Ok(y :: ys)
241
+ | Error e, _ -> state <- Error e
242
+ | _, _ -> ()
243
+
244
+ return
245
+ state
246
+ |> Result.map List.rev
247
+ }
248
+
249
+ let traverseTaskResultM f xs = traverseTaskResultM' f xs
250
+
251
+ let sequenceTaskResultM xs = traverseTaskResultM id xs
252
+
253
+ let private traverseTaskResultA' (f: 'c -> Task<Result<'a, 'b>>) (xs: 'c list) =
254
+ let mutable state = Ok []
255
+
256
+ task {
257
+ for x in xs do
258
+ let! r = f x
259
+
260
+ match (r, state) with
261
+ | Ok y, Ok ys -> state <- Ok(y :: ys)
262
+ | Error e, Error errs -> state <- Error(e :: errs)
263
+ | Ok _, Error e -> state <- Error e
264
+ | Error e, Ok _ -> state <- Error [ e ]
265
+
266
+ return
267
+ state
268
+ |> Result.eitherMap List.rev List.rev
269
+ }
270
+
271
+ let traverseTaskResultA f xs = traverseTaskResultA' f xs
272
+
273
+ let sequenceTaskResultA xs = traverseTaskResultA id xs
274
+
275
+
276
+ #endif