@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,18 @@
1
+
2
+ import { class_type } from "../fable-library-js.5.17.2/Reflection.js";
3
+
4
+ export class AsyncResultCE_AsyncResultBuilder {
5
+ constructor() {
6
+ }
7
+ }
8
+
9
+ export function AsyncResultCE_AsyncResultBuilder_$reflection() {
10
+ return class_type("FsToolkit.ErrorHandling.AsyncResultCE.AsyncResultBuilder", undefined, AsyncResultCE_AsyncResultBuilder);
11
+ }
12
+
13
+ export function AsyncResultCE_AsyncResultBuilder_$ctor() {
14
+ return new AsyncResultCE_AsyncResultBuilder();
15
+ }
16
+
17
+ export const AsyncResultCE_asyncResult = AsyncResultCE_AsyncResultBuilder_$ctor();
18
+
@@ -0,0 +1,24 @@
1
+ namespace FsToolkit.ErrorHandling.Operator.AsyncResult
2
+
3
+ open FsToolkit.ErrorHandling
4
+
5
+ [<AutoOpen>]
6
+ module AsyncResult =
7
+
8
+ let inline (<!>)
9
+ (([<InlineIfLambda>] mapper: 'okInput -> 'okOutput))
10
+ (input: Async<Result<'okInput, 'error>>)
11
+ : Async<Result<'okOutput, 'error>> =
12
+ AsyncResult.map mapper input
13
+
14
+ let inline (<*>)
15
+ (applier: Async<Result<'okInput -> 'okOutput, 'error>>)
16
+ (input: Async<Result<'okInput, 'error>>)
17
+ : Async<Result<'okOutput, 'error>> =
18
+ AsyncResult.apply applier input
19
+
20
+ let inline (>>=)
21
+ (input: Async<Result<'input, 'error>>)
22
+ ([<InlineIfLambda>] binder: 'input -> Async<Result<'okOutput, 'error>>)
23
+ : Async<Result<'okOutput, 'error>> =
24
+ AsyncResult.bind binder input
@@ -0,0 +1,87 @@
1
+ namespace FsToolkit.ErrorHandling
2
+
3
+
4
+ type AsyncResultOption<'ok, 'error> = Async<Result<'ok option, 'error>>
5
+
6
+ [<RequireQualifiedAccess>]
7
+ module AsyncResultOption =
8
+
9
+ let inline map
10
+ ([<InlineIfLambda>] mapper: 'okInput -> 'okOutput)
11
+ (input: Async<Result<'okInput option, 'error>>)
12
+ : Async<Result<'okOutput option, 'error>> =
13
+ AsyncResult.map (Option.map mapper) input
14
+
15
+ let inline bind
16
+ ([<InlineIfLambda>] binder: 'okInput -> Async<Result<'okOutput option, 'error>>)
17
+ (input: Async<Result<'okInput option, 'error>>)
18
+ : Async<Result<'okOutput option, 'error>> =
19
+ AsyncResult.bind
20
+ (fun opt ->
21
+ match opt with
22
+ | Some x -> binder x
23
+ | None -> AsyncResult.ok None
24
+ )
25
+ input
26
+
27
+ let inline ok x =
28
+ Ok(Some x)
29
+ |> Async.singleton
30
+
31
+ let inline error x : Async<Result<'ok option, 'error>> =
32
+ Error x
33
+ |> Async.singleton
34
+
35
+ let inline map2
36
+ ([<InlineIfLambda>] mapper: 'okInput1 -> 'okInput2 -> 'okOutput)
37
+ (input1: Async<Result<'okInput1 option, 'error>>)
38
+ (input2: Async<Result<'okInput2 option, 'error>>)
39
+ : Async<Result<'okOutput option, 'error>> =
40
+ AsyncResult.map2 (Option.map2 mapper) input1 input2
41
+
42
+ let inline map3
43
+ ([<InlineIfLambda>] mapper: 'okInput1 -> 'okInput2 -> 'okInput3 -> 'okOutput)
44
+ (input1: Async<Result<'okInput1 option, 'error>>)
45
+ (input2: Async<Result<'okInput2 option, 'error>>)
46
+ (input3: Async<Result<'okInput3 option, 'error>>)
47
+ : Async<Result<'okOutput option, 'error>> =
48
+ AsyncResult.map3 (Option.map3 mapper) input1 input2 input3
49
+
50
+ let inline singleton (value: 'ok) : Async<Result<'ok option, 'error>> =
51
+ AsyncResult.ok (Some value)
52
+
53
+ let apply
54
+ (applier: Async<Result<('okInput -> 'okOutput) option, 'error>>)
55
+ (input: Async<Result<'okInput option, 'error>>)
56
+ : Async<Result<'okOutput option, 'error>> =
57
+ map2 (fun f x -> f x) applier input
58
+
59
+ #if !FABLE_COMPILER_PYTHON
60
+ // https://github.com/fable-compiler/Fable/issues/4125
61
+ /// Replaces the wrapped value with unit
62
+ let ignore<'ok, 'error>
63
+ (value: Async<Result<'ok option, 'error>>)
64
+ : Async<Result<unit option, 'error>> =
65
+ value
66
+ |> map ignore<'ok>
67
+ #endif
68
+
69
+
70
+ let inline ofResult (r: Result<'ok, 'error>) =
71
+ r
72
+ |> Result.map Some
73
+ |> Async.singleton
74
+
75
+
76
+ let inline ofAsyncResult (r: Async<Result<'ok, 'error>>) =
77
+ r
78
+ |> AsyncResult.map Some
79
+
80
+ let inline ofOption (r: 'ok option) =
81
+ r
82
+ |> Ok
83
+ |> Async.singleton
84
+
85
+ let inline ofAsyncOption (r: Async<'ok option>) =
86
+ r
87
+ |> Async.map Ok
@@ -0,0 +1,26 @@
1
+
2
+ import { singleton } from "../fable-library-js.5.17.2/AsyncBuilder.js";
3
+ import { FSharpResult$2 } from "../fable-library-js.5.17.2/Result.js";
4
+ import { some, value as value_4 } from "../fable-library-js.5.17.2/Option.js";
5
+
6
+ export function AsyncResultOption_apply(applier, input) {
7
+ return singleton.Bind(applier, (x_3) => singleton.Bind(input, (y_2) => {
8
+ let copyOfStruct, copyOfStruct_1, input1_1, input2_1, x_1, y;
9
+ const value = (copyOfStruct = x_3, (copyOfStruct.tag === 1) ? (new FSharpResult$2(/* Error */ 1, [copyOfStruct.fields[0]])) : ((copyOfStruct_1 = y_2, (copyOfStruct_1.tag === 1) ? (new FSharpResult$2(/* Error */ 1, [copyOfStruct_1.fields[0]])) : (new FSharpResult$2(/* Ok */ 0, [(input1_1 = copyOfStruct.fields[0], (input2_1 = copyOfStruct_1.fields[0], (input1_1 != null) ? ((input2_1 != null) ? ((x_1 = input1_1, (y = value_4(input2_1), some(x_1(y))))) : undefined) : undefined))])))));
10
+ return singleton.Return(value);
11
+ }));
12
+ }
13
+
14
+ /**
15
+ * Replaces the wrapped value with unit
16
+ */
17
+ export function AsyncResultOption_ignore(value) {
18
+ return singleton.Bind(value, (x$0027) => {
19
+ let input_2;
20
+ let value_2;
21
+ const input_4 = x$0027;
22
+ value_2 = ((input_4.tag === 1) ? (new FSharpResult$2(/* Error */ 1, [input_4.fields[0]])) : (new FSharpResult$2(/* Ok */ 0, [(input_2 = input_4.fields[0], (input_2 == null) ? undefined : some(void value_4(input_2)))])));
23
+ return singleton.Return(value_2);
24
+ });
25
+ }
26
+
@@ -0,0 +1,236 @@
1
+ namespace FsToolkit.ErrorHandling
2
+
3
+ open System
4
+ open System.Threading.Tasks
5
+
6
+ [<AutoOpen>]
7
+ module AsyncResultOptionCE =
8
+
9
+ type AsyncResultOptionBuilder() =
10
+ member inline _.Return(value: 'ok) : AsyncResultOption<'ok, 'error> =
11
+ AsyncResultOption.singleton value
12
+
13
+ member inline _.ReturnFrom
14
+ (value: Async<Result<'ok option, 'error>>)
15
+ : Async<Result<'ok option, 'error>> =
16
+ value
17
+
18
+ member inline _.Bind
19
+ (
20
+ input: AsyncResultOption<'okInput, 'error>,
21
+ [<InlineIfLambda>] binder: 'okInput -> AsyncResultOption<'okOutput, 'error>
22
+ ) : AsyncResultOption<'okOutput, 'error> =
23
+ AsyncResultOption.bind binder input
24
+
25
+ member inline _.Combine(aro1, aro2) =
26
+ aro1
27
+ |> AsyncResultOption.bind (fun _ -> aro2)
28
+
29
+ member inline _.Delay([<InlineIfLambda>] f: unit -> Async<'a>) : Async<'a> = async.Delay f
30
+
31
+ member inline _.Zero() = Async.singleton (Ok(Some()))
32
+
33
+ member inline _.TryWith
34
+ (
35
+ computation: AsyncResultOption<'ok, 'error>,
36
+ [<InlineIfLambda>] handler: Exception -> AsyncResultOption<'ok, 'error>
37
+ ) : AsyncResultOption<'ok, 'error> =
38
+ async.TryWith(computation, handler)
39
+
40
+ member inline _.TryFinally
41
+ (
42
+ computation: AsyncResultOption<'ok, 'error>,
43
+ [<InlineIfLambda>] compensation: unit -> unit
44
+ ) : AsyncResultOption<'ok, 'error> =
45
+ async.TryFinally(computation, compensation)
46
+ #if !FABLE_COMPILER
47
+ member inline _.TryFinallyAsync
48
+ (
49
+ computation: AsyncResultOption<'ok, 'error>,
50
+ [<InlineIfLambda>] compensation: unit -> ValueTask
51
+ ) : AsyncResultOption<'ok, 'error> =
52
+ let compensation =
53
+ async {
54
+ let vTask = compensation ()
55
+
56
+ if vTask.IsCompletedSuccessfully then
57
+ return ()
58
+ else
59
+ return!
60
+ vTask.AsTask()
61
+ |> Async.AwaitTask
62
+ }
63
+
64
+ Async.TryFinallyAsync(computation, compensation)
65
+
66
+ member inline this.Using
67
+ (
68
+ resource: 'ok :> IAsyncDisposableNull,
69
+ [<InlineIfLambda>] binder: 'ok -> AsyncResultOption<'okOut, 'error>
70
+ ) : AsyncResultOption<'okOut, 'error> =
71
+ this.TryFinallyAsync(
72
+ binder resource,
73
+ (fun () ->
74
+ if not (isNull (box resource)) then
75
+ resource.DisposeAsync()
76
+ else
77
+ ValueTask()
78
+ )
79
+ )
80
+ #endif
81
+
82
+ member inline this.While
83
+ ([<InlineIfLambda>] guard: unit -> bool, computation: AsyncResultOption<unit, 'error>)
84
+ : AsyncResultOption<unit, 'error> =
85
+ if guard () then
86
+ let mutable whileAsync = Unchecked.defaultof<_>
87
+
88
+ whileAsync <-
89
+ this.Bind(computation, (fun () -> if guard () then whileAsync else this.Zero()))
90
+
91
+ whileAsync
92
+ else
93
+ this.Zero()
94
+
95
+ /// <summary>
96
+ /// Method lets us transform data types into our internal representation. This is the identity method to recognize the self type.
97
+ ///
98
+ /// See https://stackoverflow.com/questions/35286541/why-would-you-use-builder-source-in-a-custom-computation-expression-builder
99
+ /// </summary>
100
+ member inline _.Source
101
+ (result: AsyncResultOption<'ok, 'error>)
102
+ : AsyncResultOption<'ok, 'error> =
103
+ result
104
+
105
+ let asyncResultOption = new AsyncResultOptionBuilder()
106
+
107
+
108
+ [<AutoOpen>]
109
+ module AsyncResultOptionCEExtensions =
110
+
111
+ type AsyncResultOptionBuilder with
112
+
113
+ /// <summary>
114
+ /// Needed to allow `for..in` and `for..do` functionality
115
+ /// </summary>
116
+ member inline _.Source(s: #seq<'value>) : #seq<'value> = s
117
+
118
+ /// <summary>
119
+ /// Method lets us transform data types into our internal representation.
120
+ /// </summary>
121
+ member inline _.Source(result: Result<'ok, 'error>) : AsyncResultOption<'ok, 'error> =
122
+ AsyncResultOption.ofResult result
123
+
124
+ /// <summary>
125
+ /// Method lets us transform data types into our internal representation.
126
+ /// </summary>
127
+ member inline this.Source(result: Choice<'ok, 'error>) : AsyncResultOption<'ok, 'error> =
128
+ this.Source(Result.ofChoice result)
129
+
130
+ /// <summary>
131
+ /// Method lets us transform data types into our internal representation.
132
+ /// </summary>
133
+ member inline this.Source(optional: 'ok option) : AsyncResultOption<'ok, 'error> =
134
+ AsyncResultOption.ofOption optional
135
+
136
+ /// <summary>
137
+ /// Method lets us transform data types into our internal representation.
138
+ /// </summary>
139
+ member inline this.Source(async: Async<'ok>) : AsyncResultOption<'ok, 'error> =
140
+ Async.map (Some >> Ok) async
141
+
142
+
143
+ member inline _.Using
144
+ (
145
+ resource: 'ok :> IDisposableNull,
146
+ [<InlineIfLambda>] binder: 'ok -> AsyncResultOption<'okOutput, 'error>
147
+ ) : AsyncResultOption<'okOutput, 'error> =
148
+ async.Using(resource, binder)
149
+
150
+
151
+ member inline this.For
152
+ (sequence: #seq<'ok>, [<InlineIfLambda>] binder: 'ok -> AsyncResultOption<unit, 'error>)
153
+ : AsyncResultOption<unit, 'error> =
154
+ this.Using(
155
+ sequence.GetEnumerator(),
156
+ fun enum ->
157
+ this.While(
158
+ (fun () -> enum.MoveNext()),
159
+ this.Delay(fun () -> binder enum.Current)
160
+ )
161
+ )
162
+
163
+
164
+ #if !FABLE_COMPILER
165
+ /// <summary>
166
+ /// Method lets us transform data types into our internal representation.
167
+ /// </summary>
168
+ member inline this.Source(async: Task<'ok>) : AsyncResultOption<'ok, 'error> =
169
+ async
170
+ |> Async.AwaitTask
171
+ |> Async.map (Some >> Ok)
172
+
173
+ /// <summary>
174
+ /// Method lets us transform data types into our internal representation.
175
+ /// </summary>
176
+ member inline this.Source(async: Task) : AsyncResultOption<unit, 'error> =
177
+ async
178
+ |> Async.AwaitTask
179
+ |> Async.map (Some >> Ok)
180
+ #endif
181
+ [<AutoOpen>]
182
+ module AsyncResultOptionCEExtensionsHighPriority =
183
+
184
+ type AsyncResultOptionBuilder with
185
+
186
+ /// <summary>
187
+ /// Method lets us transform data types into our internal representation.
188
+ /// </summary>
189
+ member inline _.Source
190
+ (result: Async<Result<'ok, 'error>>)
191
+ : AsyncResultOption<'ok, 'error> =
192
+ AsyncResultOption.ofAsyncResult result
193
+
194
+ /// <summary>
195
+ /// Method lets us transform data types into our internal representation.
196
+ /// </summary>
197
+ member inline _.Source(result: Async<'ok option>) : AsyncResultOption<'ok, 'error> =
198
+ AsyncResultOption.ofAsyncOption result
199
+
200
+
201
+ #if !FABLE_COMPILER
202
+ /// <summary>
203
+ /// Method lets us transform data types into our internal representation.
204
+ /// </summary>
205
+ member inline _.Source(result: Task<Result<'ok, 'error>>) : AsyncResultOption<'ok, 'error> =
206
+ result
207
+ |> Async.AwaitTask
208
+ |> AsyncResultOption.ofAsyncResult
209
+
210
+ /// <summary>
211
+ /// Method lets us transform data types into our internal representation.
212
+ /// </summary>
213
+ member inline _.Source(result: Task<'ok option>) : AsyncResultOption<'ok, 'error> =
214
+ result
215
+ |> Async.AwaitTask
216
+ |> AsyncResultOption.ofAsyncOption
217
+ #endif
218
+
219
+ #if !FABLE_COMPILER
220
+ [<AutoOpen>]
221
+ module AsyncResultOptionCEExtensionsHighPriority2 =
222
+
223
+ type AsyncResultOptionBuilder with
224
+
225
+
226
+ /// <summary>
227
+ /// Method lets us transform data types into our internal representation. This is the identity method to recognize the self type.
228
+ ///
229
+ /// See https://stackoverflow.com/questions/35286541/why-would-you-use-builder-source-in-a-custom-computation-expression-builder
230
+ /// </summary>
231
+ member inline _.Source
232
+ (result: Task<Result<'ok option, 'error>>)
233
+ : AsyncResultOption<'ok, 'error> =
234
+ result
235
+ |> Async.AwaitTask
236
+ #endif
@@ -0,0 +1,18 @@
1
+
2
+ import { class_type } from "../fable-library-js.5.17.2/Reflection.js";
3
+
4
+ export class AsyncResultOptionCE_AsyncResultOptionBuilder {
5
+ constructor() {
6
+ }
7
+ }
8
+
9
+ export function AsyncResultOptionCE_AsyncResultOptionBuilder_$reflection() {
10
+ return class_type("FsToolkit.ErrorHandling.AsyncResultOptionCE.AsyncResultOptionBuilder", undefined, AsyncResultOptionCE_AsyncResultOptionBuilder);
11
+ }
12
+
13
+ export function AsyncResultOptionCE_AsyncResultOptionBuilder_$ctor() {
14
+ return new AsyncResultOptionCE_AsyncResultOptionBuilder();
15
+ }
16
+
17
+ export const AsyncResultOptionCE_asyncResultOption = AsyncResultOptionCE_AsyncResultOptionBuilder_$ctor();
18
+
@@ -0,0 +1,24 @@
1
+ namespace FsToolkit.ErrorHandling.Operator.AsyncResultOption
2
+
3
+ open FsToolkit.ErrorHandling
4
+
5
+ [<AutoOpen>]
6
+ module AsyncResultOption =
7
+
8
+ let inline (<!>)
9
+ ([<InlineIfLambda>] mapper: 'okInput -> 'okOutput)
10
+ (input: Async<Result<'okInput option, 'error>>)
11
+ : Async<Result<'okOutput option, 'error>> =
12
+ AsyncResultOption.map mapper input
13
+
14
+ let inline (<*>)
15
+ (applier: Async<Result<('okInput -> 'okOutput) option, 'error>>)
16
+ (input: Async<Result<'okInput option, 'error>>)
17
+ : Async<Result<'okOutput option, 'error>> =
18
+ AsyncResultOption.apply applier input
19
+
20
+ let inline (>>=)
21
+ (input: Async<Result<'okInput option, 'error>>)
22
+ ([<InlineIfLambda>] binder: 'okInput -> Async<Result<'okOutput option, 'error>>)
23
+ : Async<Result<'okOutput option, 'error>> =
24
+ AsyncResultOption.bind binder input
@@ -0,0 +1,185 @@
1
+ namespace FsToolkit.ErrorHandling
2
+
3
+ /// AsyncValidation<'a, 'err> is defined as Async<Result<'a, 'err list>> meaning you can use many of the functions found in the Result and Async module.
4
+ type AsyncValidation<'ok, 'error> = Async<Result<'ok, 'error list>>
5
+
6
+ [<RequireQualifiedAccess>]
7
+ module AsyncValidation =
8
+
9
+ let inline ok (value: 'ok) : AsyncValidation<'ok, 'error> =
10
+ Ok value
11
+ |> async.Return
12
+
13
+ let inline error (error: 'error) : AsyncValidation<'ok, 'error> =
14
+ Error [ error ]
15
+ |> async.Return
16
+
17
+ let inline ofResult (result: Result<'ok, 'error>) : AsyncValidation<'ok, 'error> =
18
+ Result.mapError List.singleton result
19
+ |> async.Return
20
+
21
+ let inline ofChoice (choice: Choice<'ok, 'error>) : AsyncValidation<'ok, 'error> =
22
+ match choice with
23
+ | Choice1Of2 x -> ok x
24
+ | Choice2Of2 e -> error e
25
+
26
+ let inline apply
27
+ (applier: AsyncValidation<'okInput -> 'okOutput, 'error>)
28
+ (input: AsyncValidation<'okInput, 'error>)
29
+ : AsyncValidation<'okOutput, 'error> =
30
+ async {
31
+ let! applier = applier
32
+ let! input = input
33
+
34
+ return
35
+ match applier, input with
36
+ | Ok f, Ok x -> Ok(f x)
37
+ | Error errs, Ok _
38
+ | Ok _, Error errs -> Error errs
39
+ | Error errs1, Error errs2 ->
40
+ Error(
41
+ errs1
42
+ @ errs2
43
+ )
44
+ }
45
+
46
+ let inline orElse
47
+ (ifError: AsyncValidation<'ok, 'errorOutput>)
48
+ (result: AsyncValidation<'ok, 'errorInput>)
49
+ : AsyncValidation<'ok, 'errorOutput> =
50
+ async {
51
+ let! result = result
52
+
53
+ return!
54
+ result
55
+ |> Result.either ok (fun _ -> ifError)
56
+ }
57
+
58
+ let inline orElseWith
59
+ ([<InlineIfLambda>] ifErrorFunc: 'errorInput list -> AsyncValidation<'ok, 'errorOutput>)
60
+ (result: AsyncValidation<'ok, 'errorInput>)
61
+ : AsyncValidation<'ok, 'errorOutput> =
62
+ async {
63
+ let! result = result
64
+
65
+ return!
66
+ match result with
67
+ | Ok x -> ok x
68
+ | Error err -> ifErrorFunc err
69
+ }
70
+
71
+ let inline map
72
+ ([<InlineIfLambda>] mapper: 'okInput -> 'okOutput)
73
+ (input: AsyncValidation<'okInput, 'error>)
74
+ : AsyncValidation<'okOutput, 'error> =
75
+ async {
76
+ let! input = input
77
+ return Result.map mapper input
78
+ }
79
+
80
+ let inline map2
81
+ ([<InlineIfLambda>] mapper: 'okInput1 -> 'okInput2 -> 'okOutput)
82
+ (input1: AsyncValidation<'okInput1, 'error>)
83
+ (input2: AsyncValidation<'okInput2, 'error>)
84
+ : AsyncValidation<'okOutput, 'error> =
85
+ async {
86
+ let! input1 = input1
87
+ let! input2 = input2
88
+
89
+ return
90
+ match input1, input2 with
91
+ | Ok x, Ok y -> Ok(mapper x y)
92
+ | Ok _, Error errs -> Error errs
93
+ | Error errs, Ok _ -> Error errs
94
+ | Error errs1, Error errs2 ->
95
+ Error(
96
+ errs1
97
+ @ errs2
98
+ )
99
+ }
100
+
101
+ let inline map3
102
+ ([<InlineIfLambda>] mapper: 'okInput1 -> 'okInput2 -> 'okInput3 -> 'okOutput)
103
+ (input1: AsyncValidation<'okInput1, 'error>)
104
+ (input2: AsyncValidation<'okInput2, 'error>)
105
+ (input3: AsyncValidation<'okInput3, 'error>)
106
+ : AsyncValidation<'okOutput, 'error> =
107
+ async {
108
+ let! input1 = input1
109
+ let! input2 = input2
110
+ let! input3 = input3
111
+
112
+ return
113
+ match input1, input2, input3 with
114
+ | Ok x, Ok y, Ok z -> Ok(mapper x y z)
115
+ | Error errs, Ok _, Ok _ -> Error errs
116
+ | Ok _, Error errs, Ok _ -> Error errs
117
+ | Ok _, Ok _, Error errs -> Error errs
118
+ | Error errs1, Error errs2, Ok _ ->
119
+ Error(
120
+ errs1
121
+ @ errs2
122
+ )
123
+ | Ok _, Error errs1, Error errs2 ->
124
+ Error(
125
+ errs1
126
+ @ errs2
127
+ )
128
+ | Error errs1, Ok _, Error errs2 ->
129
+ Error(
130
+ errs1
131
+ @ errs2
132
+ )
133
+ | Error errs1, Error errs2, Error errs3 ->
134
+ Error(
135
+ errs1
136
+ @ errs2
137
+ @ errs3
138
+ )
139
+ }
140
+
141
+ let inline mapError
142
+ ([<InlineIfLambda>] errorMapper: 'errorInput -> 'errorOutput)
143
+ (input: AsyncValidation<'ok, 'errorInput>)
144
+ : AsyncValidation<'ok, 'errorOutput> =
145
+ async {
146
+ let! input = input
147
+ return Result.mapError (List.map errorMapper) input
148
+ }
149
+
150
+ let inline mapErrors
151
+ ([<InlineIfLambda>] errorMapper: 'errorInput list -> 'errorOutput list)
152
+ (input: AsyncValidation<'ok, 'errorInput>)
153
+ : AsyncValidation<'ok, 'errorOutput> =
154
+ async {
155
+ let! input = input
156
+ return Result.mapError errorMapper input
157
+ }
158
+
159
+ let inline bind
160
+ ([<InlineIfLambda>] binder: 'okInput -> AsyncValidation<'okOutput, 'error>)
161
+ (input: AsyncValidation<'okInput, 'error>)
162
+ : AsyncValidation<'okOutput, 'error> =
163
+ async {
164
+ let! input = input
165
+
166
+ match input with
167
+ | Ok x -> return! binder x
168
+ | Error e -> return Error e
169
+ }
170
+
171
+ let inline zip
172
+ (left: AsyncValidation<'left, 'error>)
173
+ (right: AsyncValidation<'right, 'error>)
174
+ : AsyncValidation<'left * 'right, 'error> =
175
+ async {
176
+ let! left = left
177
+ let! right = right
178
+
179
+ return
180
+ match left, right with
181
+ | Ok x1res, Ok x2res -> Ok(x1res, x2res)
182
+ | Error e, Ok _ -> Error e
183
+ | Ok _, Error e -> Error e
184
+ | Error e1, Error e2 -> Error(e1 @ e2)
185
+ }