@glutinum/cli 0.10.0 → 0.12.0

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 (132) hide show
  1. package/README.md +48 -0
  2. package/dist/Glutinum.Converter/FsharpAST.js +76 -21
  3. package/dist/Glutinum.Converter/FsharpAST.js.map +1 -1
  4. package/dist/Glutinum.Converter/Generate.js +5 -7
  5. package/dist/Glutinum.Converter/Generate.js.map +1 -1
  6. package/dist/Glutinum.Converter/GlueAST.js +90 -14
  7. package/dist/Glutinum.Converter/GlueAST.js.map +1 -1
  8. package/dist/Glutinum.Converter/Log.js +5 -5
  9. package/dist/Glutinum.Converter/Log.js.map +1 -1
  10. package/dist/Glutinum.Converter/Merge.js +7 -7
  11. package/dist/Glutinum.Converter/Merge.js.map +1 -1
  12. package/dist/Glutinum.Converter/Printer.js +203 -106
  13. package/dist/Glutinum.Converter/Printer.js.map +1 -1
  14. package/dist/Glutinum.Converter/Read.js.map +1 -1
  15. package/dist/Glutinum.Converter/Reader/ClassDeclaration.js.map +1 -1
  16. package/dist/Glutinum.Converter/Reader/Declaration.js +20 -19
  17. package/dist/Glutinum.Converter/Reader/Declaration.js.map +1 -1
  18. package/dist/Glutinum.Converter/Reader/Documentation.js.map +1 -1
  19. package/dist/Glutinum.Converter/Reader/EnumDeclaration.js +4 -3
  20. package/dist/Glutinum.Converter/Reader/EnumDeclaration.js.map +1 -1
  21. package/dist/Glutinum.Converter/Reader/ExportAssignment.js.map +1 -1
  22. package/dist/Glutinum.Converter/Reader/FunctionDeclaration.js +2 -2
  23. package/dist/Glutinum.Converter/Reader/FunctionDeclaration.js.map +1 -1
  24. package/dist/Glutinum.Converter/Reader/IndexedAccessType.js +5 -6
  25. package/dist/Glutinum.Converter/Reader/IndexedAccessType.js.map +1 -1
  26. package/dist/Glutinum.Converter/Reader/InterfaceDeclaration.js.map +1 -1
  27. package/dist/Glutinum.Converter/Reader/MappedTypeNode.js +42 -0
  28. package/dist/Glutinum.Converter/Reader/MappedTypeNode.js.map +1 -0
  29. package/dist/Glutinum.Converter/Reader/ModuleDeclaration.js.map +1 -1
  30. package/dist/Glutinum.Converter/Reader/NamedTupleMember.js.map +1 -1
  31. package/dist/Glutinum.Converter/Reader/Node.js +8 -5
  32. package/dist/Glutinum.Converter/Reader/Node.js.map +1 -1
  33. package/dist/Glutinum.Converter/Reader/Parameters.js +7 -4
  34. package/dist/Glutinum.Converter/Reader/Parameters.js.map +1 -1
  35. package/dist/Glutinum.Converter/Reader/Report.js +35 -0
  36. package/dist/Glutinum.Converter/Reader/Report.js.map +1 -0
  37. package/dist/Glutinum.Converter/Reader/TypeAliasDeclaration.js +5 -0
  38. package/dist/Glutinum.Converter/Reader/TypeAliasDeclaration.js.map +1 -1
  39. package/dist/Glutinum.Converter/Reader/TypeNode.js +250 -69
  40. package/dist/Glutinum.Converter/Reader/TypeNode.js.map +1 -1
  41. package/dist/Glutinum.Converter/Reader/TypeOperatorNode.js +31 -26
  42. package/dist/Glutinum.Converter/Reader/TypeOperatorNode.js.map +1 -1
  43. package/dist/Glutinum.Converter/Reader/TypeParameters.js.map +1 -1
  44. package/dist/Glutinum.Converter/Reader/TypeQueryNode.js +127 -0
  45. package/dist/Glutinum.Converter/Reader/TypeQueryNode.js.map +1 -0
  46. package/dist/Glutinum.Converter/Reader/TypeScriptReader.js +7 -2
  47. package/dist/Glutinum.Converter/Reader/TypeScriptReader.js.map +1 -1
  48. package/dist/Glutinum.Converter/Reader/UnionTypeNode.js +6 -9
  49. package/dist/Glutinum.Converter/Reader/UnionTypeNode.js.map +1 -1
  50. package/dist/Glutinum.Converter/Reader/Utils.js +35 -13
  51. package/dist/Glutinum.Converter/Reader/Utils.js.map +1 -1
  52. package/dist/Glutinum.Converter/Reader/VariableStatement.js +2 -2
  53. package/dist/Glutinum.Converter/Reader/VariableStatement.js.map +1 -1
  54. package/dist/Glutinum.Converter/Transform.js +614 -211
  55. package/dist/Glutinum.Converter/Transform.js.map +1 -1
  56. package/dist/Glutinum.Converter/TypeScript.Extensions.js +745 -0
  57. package/dist/Glutinum.Converter/TypeScript.Extensions.js.map +1 -0
  58. package/dist/Glutinum.Converter/Utils/Naming.js +6 -2
  59. package/dist/Glutinum.Converter/Utils/Naming.js.map +1 -1
  60. package/dist/Program.js +2 -2
  61. package/dist/Program.js.map +1 -1
  62. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/AssemblyInfo.fs +19 -0
  63. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/Async.fs +207 -0
  64. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/Async.fs.js +127 -0
  65. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/Async.fs.js.map +1 -0
  66. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/AsyncOption.fs +81 -0
  67. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/AsyncOptionCE.fs +183 -0
  68. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/AsyncOptionCE.fs.js +37 -0
  69. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/AsyncOptionCE.fs.js.map +1 -0
  70. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/AsyncOptionOp.fs +24 -0
  71. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/AsyncResult.fs +439 -0
  72. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/AsyncResultCE.fs +217 -0
  73. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/AsyncResultCE.fs.js +18 -0
  74. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/AsyncResultCE.fs.js.map +1 -0
  75. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/AsyncResultOp.fs +24 -0
  76. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/AsyncResultOption.fs +75 -0
  77. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/AsyncResultOption.fs.js +26 -0
  78. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/AsyncResultOption.fs.js.map +1 -0
  79. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/AsyncResultOptionCE.fs +238 -0
  80. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/AsyncResultOptionCE.fs.js +18 -0
  81. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/AsyncResultOptionCE.fs.js.map +1 -0
  82. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/AsyncResultOptionOp.fs +24 -0
  83. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/AsyncValidation.fs +190 -0
  84. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/AsyncValidationCE.fs +194 -0
  85. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/AsyncValidationCE.fs.js +18 -0
  86. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/AsyncValidationCE.fs.js.map +1 -0
  87. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/AsyncValidationOp.fs +35 -0
  88. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/FsToolkit.ErrorHandling.fableproj +51 -0
  89. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/List.fs +218 -0
  90. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/List.fs.js +358 -0
  91. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/List.fs.js.map +1 -0
  92. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/Option.fs +331 -0
  93. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/OptionCE.fs +186 -0
  94. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/OptionCE.fs.js +18 -0
  95. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/OptionCE.fs.js.map +1 -0
  96. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/OptionOp.fs +21 -0
  97. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/Result.fs +644 -0
  98. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/Result.fs.js +45 -0
  99. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/Result.fs.js.map +1 -0
  100. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/ResultCE.fs +155 -0
  101. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/ResultCE.fs.js +23 -0
  102. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/ResultCE.fs.js.map +1 -0
  103. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/ResultOp.fs +45 -0
  104. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/ResultOption.fs +201 -0
  105. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/ResultOption.fs.js +65 -0
  106. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/ResultOption.fs.js.map +1 -0
  107. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/ResultOptionCE.fs +146 -0
  108. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/ResultOptionCE.fs.js +18 -0
  109. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/ResultOptionCE.fs.js.map +1 -0
  110. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/ResultOptionOp.fs +57 -0
  111. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/Seq.fs +19 -0
  112. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/Seq.fs.js +31 -0
  113. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/Seq.fs.js.map +1 -0
  114. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/Shims.fs +22 -0
  115. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/Shims.fs.js +18 -0
  116. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/Shims.fs.js.map +1 -0
  117. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/Validation.fs +172 -0
  118. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/ValidationCE.fs +148 -0
  119. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/ValidationCE.fs.js +18 -0
  120. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/ValidationCE.fs.js.map +1 -0
  121. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/ValidationOp.fs +35 -0
  122. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/ValueOption.fs +151 -0
  123. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/ValueOptionCE.fs +165 -0
  124. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/obj/Debug/netstandard2.1/.NETStandard,Version=v2.1.AssemblyAttributes.fs +3 -0
  125. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/obj/Debug/netstandard2.1/FsToolkit.ErrorHandling.AssemblyInfo.fs +20 -0
  126. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/obj/Release/netstandard2.0/.NETStandard,Version=v2.0.AssemblyAttributes.fs +3 -0
  127. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/obj/Release/netstandard2.0/FsToolkit.ErrorHandling.AssemblyInfo.fs +20 -0
  128. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/obj/Release/netstandard2.1/.NETStandard,Version=v2.1.AssemblyAttributes.fs +3 -0
  129. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/obj/Release/netstandard2.1/FsToolkit.ErrorHandling.AssemblyInfo.fs +20 -0
  130. package/dist/fable_modules/project_cracked.json +1 -1
  131. package/package.json +3 -2
  132. package/src/Glutinum.Converter/js/bootstrap.js +16 -0
@@ -0,0 +1,190 @@
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
+ let inline ok (value: 'ok) : AsyncValidation<'ok, 'error> =
9
+ Ok value
10
+ |> async.Return
11
+
12
+ let inline error (error: 'error) : AsyncValidation<'ok, 'error> =
13
+ Error [ error ]
14
+ |> async.Return
15
+
16
+ let inline ofResult (result: Result<'ok, 'error>) : AsyncValidation<'ok, 'error> =
17
+ Result.mapError List.singleton result
18
+ |> async.Return
19
+
20
+ let inline ofChoice (choice: Choice<'ok, 'error>) : AsyncValidation<'ok, 'error> =
21
+ match choice with
22
+ | Choice1Of2 x -> ok x
23
+ | Choice2Of2 e -> error e
24
+
25
+ let inline apply
26
+ (applier: AsyncValidation<'okInput -> 'okOutput, 'error>)
27
+ (input: AsyncValidation<'okInput, 'error>)
28
+ : AsyncValidation<'okOutput, 'error> =
29
+ async {
30
+ let! applier = applier
31
+ let! input = input
32
+
33
+ return
34
+ match applier, input with
35
+ | Ok f, Ok x -> Ok(f x)
36
+ | Error errs, Ok _
37
+ | Ok _, Error errs -> Error errs
38
+ | Error errs1, Error errs2 ->
39
+ Error(
40
+ errs1
41
+ @ errs2
42
+ )
43
+ }
44
+
45
+ let inline retn (value: 'ok) : AsyncValidation<'ok, 'error> = ok value
46
+
47
+ let inline returnError (error: 'error) : AsyncValidation<'ok, 'error> =
48
+ Error [ error ]
49
+ |> async.Return
50
+
51
+ let inline orElse
52
+ (ifError: AsyncValidation<'ok, 'errorOutput>)
53
+ (result: AsyncValidation<'ok, 'errorInput>)
54
+ : AsyncValidation<'ok, 'errorOutput> =
55
+ async {
56
+ let! result = result
57
+
58
+ return!
59
+ result
60
+ |> Result.either ok (fun _ -> ifError)
61
+ }
62
+
63
+ let inline orElseWith
64
+ ([<InlineIfLambda>] ifErrorFunc: 'errorInput list -> AsyncValidation<'ok, 'errorOutput>)
65
+ (result: AsyncValidation<'ok, 'errorInput>)
66
+ : AsyncValidation<'ok, 'errorOutput> =
67
+ async {
68
+ let! result = result
69
+
70
+ return!
71
+ match result with
72
+ | Ok x -> ok x
73
+ | Error err -> ifErrorFunc err
74
+ }
75
+
76
+ let inline map
77
+ ([<InlineIfLambda>] mapper: 'okInput -> 'okOutput)
78
+ (input: AsyncValidation<'okInput, 'error>)
79
+ : AsyncValidation<'okOutput, 'error> =
80
+ async {
81
+ let! input = input
82
+ return Result.map mapper input
83
+ }
84
+
85
+ let inline map2
86
+ ([<InlineIfLambda>] mapper: 'okInput1 -> 'okInput2 -> 'okOutput)
87
+ (input1: AsyncValidation<'okInput1, 'error>)
88
+ (input2: AsyncValidation<'okInput2, 'error>)
89
+ : AsyncValidation<'okOutput, 'error> =
90
+ async {
91
+ let! input1 = input1
92
+ let! input2 = input2
93
+
94
+ return
95
+ match input1, input2 with
96
+ | Ok x, Ok y -> Ok(mapper x y)
97
+ | Ok _, Error errs -> Error errs
98
+ | Error errs, Ok _ -> Error errs
99
+ | Error errs1, Error errs2 ->
100
+ Error(
101
+ errs1
102
+ @ errs2
103
+ )
104
+ }
105
+
106
+ let inline map3
107
+ ([<InlineIfLambda>] mapper: 'okInput1 -> 'okInput2 -> 'okInput3 -> 'okOutput)
108
+ (input1: AsyncValidation<'okInput1, 'error>)
109
+ (input2: AsyncValidation<'okInput2, 'error>)
110
+ (input3: AsyncValidation<'okInput3, 'error>)
111
+ : AsyncValidation<'okOutput, 'error> =
112
+ async {
113
+ let! input1 = input1
114
+ let! input2 = input2
115
+ let! input3 = input3
116
+
117
+ return
118
+ match input1, input2, input3 with
119
+ | Ok x, Ok y, Ok z -> Ok(mapper x y z)
120
+ | Error errs, Ok _, Ok _ -> Error errs
121
+ | Ok _, Error errs, Ok _ -> Error errs
122
+ | Ok _, Ok _, Error errs -> Error errs
123
+ | Error errs1, Error errs2, Ok _ ->
124
+ Error(
125
+ errs1
126
+ @ errs2
127
+ )
128
+ | Ok _, Error errs1, Error errs2 ->
129
+ Error(
130
+ errs1
131
+ @ errs2
132
+ )
133
+ | Error errs1, Ok _, Error errs2 ->
134
+ Error(
135
+ errs1
136
+ @ errs2
137
+ )
138
+ | Error errs1, Error errs2, Error errs3 ->
139
+ Error(
140
+ errs1
141
+ @ errs2
142
+ @ errs3
143
+ )
144
+ }
145
+
146
+ let inline mapError
147
+ ([<InlineIfLambda>] errorMapper: 'errorInput -> 'errorOutput)
148
+ (input: AsyncValidation<'ok, 'errorInput>)
149
+ : AsyncValidation<'ok, 'errorOutput> =
150
+ async {
151
+ let! input = input
152
+ return Result.mapError (List.map errorMapper) input
153
+ }
154
+
155
+ let inline mapErrors
156
+ ([<InlineIfLambda>] errorMapper: 'errorInput list -> 'errorOutput list)
157
+ (input: AsyncValidation<'ok, 'errorInput>)
158
+ : AsyncValidation<'ok, 'errorOutput> =
159
+ async {
160
+ let! input = input
161
+ return Result.mapError errorMapper input
162
+ }
163
+
164
+ let inline bind
165
+ ([<InlineIfLambda>] binder: 'okInput -> AsyncValidation<'okOutput, 'error>)
166
+ (input: AsyncValidation<'okInput, 'error>)
167
+ : AsyncValidation<'okOutput, 'error> =
168
+ async {
169
+ let! input = input
170
+
171
+ match input with
172
+ | Ok x -> return! binder x
173
+ | Error e -> return Error e
174
+ }
175
+
176
+ let inline zip
177
+ (left: AsyncValidation<'left, 'error>)
178
+ (right: AsyncValidation<'right, 'error>)
179
+ : AsyncValidation<'left * 'right, 'error> =
180
+ async {
181
+ let! left = left
182
+ let! right = right
183
+
184
+ return
185
+ match left, right with
186
+ | Ok x1res, Ok x2res -> Ok(x1res, x2res)
187
+ | Error e, Ok _ -> Error e
188
+ | Ok _, Error e -> Error e
189
+ | Error e1, Error e2 -> Error(e1 @ e2)
190
+ }
@@ -0,0 +1,194 @@
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
+ (
32
+ validation1: AsyncValidation<unit, 'error>,
33
+ validation2: AsyncValidation<'ok, 'error>
34
+ ) : AsyncValidation<'ok, 'error> =
35
+ this.Bind(validation1, (fun () -> validation2))
36
+
37
+ member inline _.TryWith
38
+ (
39
+ computation: AsyncValidation<'ok, 'error>,
40
+ [<InlineIfLambda>] handler: exn -> AsyncValidation<'ok, 'error>
41
+ ) : AsyncValidation<'ok, 'error> =
42
+ async.TryWith(computation, handler)
43
+
44
+ member inline _.TryFinally
45
+ (
46
+ computation: AsyncValidation<'ok, 'error>,
47
+ [<InlineIfLambda>] compensation: unit -> unit
48
+ ) : AsyncValidation<'ok, 'error> =
49
+ async.TryFinally(computation, compensation)
50
+
51
+ member inline _.Using
52
+ (
53
+ resource: 'disposable :> IDisposable,
54
+ [<InlineIfLambda>] binder: 'disposable -> AsyncValidation<'okOutput, 'error>
55
+ ) : AsyncValidation<'okOutput, 'error> =
56
+ async.Using(resource, binder)
57
+
58
+ member inline this.While
59
+ (
60
+ [<InlineIfLambda>] guard: unit -> bool,
61
+ computation: AsyncValidation<unit, 'error>
62
+ ) : AsyncValidation<unit, 'error> =
63
+ if guard () then
64
+ let mutable whileAsync = Unchecked.defaultof<_>
65
+
66
+ whileAsync <-
67
+ this.Bind(computation, (fun () -> if guard () then whileAsync else this.Zero()))
68
+
69
+ whileAsync
70
+ else
71
+ this.Zero()
72
+
73
+
74
+ member inline this.For
75
+ (
76
+ sequence: #seq<'ok>,
77
+ [<InlineIfLambda>] binder: 'ok -> AsyncValidation<unit, 'error>
78
+ ) : AsyncValidation<unit, 'error> =
79
+ this.Using(
80
+ sequence.GetEnumerator(),
81
+ fun enum -> this.While(enum.MoveNext, this.Delay(fun () -> binder enum.Current))
82
+ )
83
+
84
+ member inline _.BindReturn
85
+ (
86
+ input: AsyncValidation<'okInput, 'error>,
87
+ [<InlineIfLambda>] mapper: 'okInput -> 'okOutput
88
+ ) : AsyncValidation<'okOutput, 'error> =
89
+ AsyncValidation.map mapper input
90
+
91
+ member inline _.MergeSources
92
+ (
93
+ left: AsyncValidation<'left, 'error>,
94
+ right: AsyncValidation<'right, 'error>
95
+ ) : AsyncValidation<'left * 'right, 'error> =
96
+ AsyncValidation.zip left right
97
+
98
+ let asyncValidation = AsyncValidationBuilder()
99
+
100
+ [<AutoOpen>]
101
+ module LowPriority =
102
+
103
+ type AsyncValidationBuilder with
104
+
105
+ /// <summary>
106
+ /// Method lets us transform data types into our internal representation.
107
+ /// </summary>
108
+ /// <returns></returns>
109
+ member inline _.Source(a: Async<'ok>) : AsyncValidation<'ok, 'error> =
110
+ async {
111
+ let! result = a
112
+ return! AsyncValidation.ok result
113
+ }
114
+
115
+ /// <summary>
116
+ /// Method lets us transform data types into our internal representation.
117
+ /// </summary>
118
+ member inline _.Source(s: Result<'ok, 'error>) : AsyncValidation<'ok, 'error> =
119
+ AsyncValidation.ofResult s
120
+
121
+ /// <summary>
122
+ /// Method lets us transform data types into our internal representation.
123
+ /// </summary>
124
+ /// <returns></returns>
125
+ member inline _.Source(choice: Choice<'ok, 'error>) : AsyncValidation<'ok, 'error> =
126
+ AsyncValidation.ofChoice choice
127
+
128
+ /// <summary>
129
+ /// Needed to allow `for..in` and `for..do` functionality
130
+ /// </summary>
131
+ member inline _.Source(s: #seq<_>) : #seq<_> = s
132
+
133
+ [<AutoOpen>]
134
+ module MediumPriority =
135
+
136
+ open System.Threading.Tasks
137
+
138
+ type AsyncValidationBuilder with
139
+
140
+ /// <summary>
141
+ /// Method lets us transform data types into our internal representation.
142
+ /// </summary>
143
+ member inline _.Source(s: Async<Result<'ok, 'error>>) : AsyncValidation<'ok, 'error> =
144
+ AsyncResult.mapError List.singleton s
145
+
146
+ #if !FABLE_COMPILER
147
+
148
+ /// <summary>
149
+ /// Method lets us transform data types into our internal representation.
150
+ /// </summary>
151
+ member inline _.Source(s: Task<Result<'ok, 'error>>) : AsyncValidation<'ok, 'error> =
152
+ Async.AwaitTask s
153
+ |> AsyncResult.mapError List.singleton
154
+
155
+ #endif
156
+
157
+ [<AutoOpen>]
158
+ module HighPriority =
159
+
160
+ open System.Threading.Tasks
161
+
162
+ // Having members as extensions gives them lower priority in
163
+ // overload resolution and allows skipping more type annotations.
164
+ type AsyncValidationBuilder with
165
+
166
+ /// <summary>
167
+ /// Method lets us transform data types into our internal representation.
168
+ /// </summary>
169
+ member inline _.Source(s: Validation<'ok, 'error>) : AsyncValidation<'ok, 'error> =
170
+ Async.retn s
171
+
172
+ #if !FABLE_COMPILER
173
+
174
+ /// <summary>
175
+ /// Method lets us transform data types into our internal representation.
176
+ /// </summary>
177
+ member inline _.Source
178
+ (result: Task<Validation<'ok, 'error>>)
179
+ : AsyncValidation<'ok, 'error> =
180
+ Async.AwaitTask result
181
+
182
+ #endif
183
+
184
+ /// <summary>
185
+ /// Method lets us transform data types into our internal representation. This is the identity method to recognize the self type.
186
+ ///
187
+ /// See https://stackoverflow.com/questions/35286541/why-would-you-use-builder-source-in-a-custom-computation-expression-builder
188
+ /// </summary>
189
+ /// <param name="result"></param>
190
+ /// <returns></returns>
191
+ member inline _.Source
192
+ (result: AsyncValidation<'ok, 'error>)
193
+ : AsyncValidation<'ok, 'error> =
194
+ result
@@ -0,0 +1,18 @@
1
+ import { class_type } from "../fable-library-js.4.14.0/Reflection.js";
2
+
3
+ export class AsyncValidationBuilder {
4
+ constructor() {
5
+ }
6
+ }
7
+
8
+ export function AsyncValidationBuilder_$reflection() {
9
+ return class_type("FsToolkit.ErrorHandling.AsyncValidationCE.AsyncValidationBuilder", void 0, AsyncValidationBuilder);
10
+ }
11
+
12
+ export function AsyncValidationBuilder_$ctor() {
13
+ return new AsyncValidationBuilder();
14
+ }
15
+
16
+ export const asyncValidation = AsyncValidationBuilder_$ctor();
17
+
18
+ //# sourceMappingURL=AsyncValidationCE.fs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["./AsyncValidationCE.fs"],"names":["\u0060\u0060.ctor\u0060\u0060"],"mappings":";;;;;;;;;;;;;;;\u002BBAiG0B,AAAAA","file":null,"sourcesContent":null,"sourceRoot":null}
@@ -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,51 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <Project Sdk="Microsoft.NET.Sdk">
3
+ <PropertyGroup>
4
+ <OutputType>Library</OutputType>
5
+ <TargetFrameworks>netstandard2.1;netstandard2.0</TargetFrameworks>
6
+ <LangVersion>preview</LangVersion>
7
+ <DebugType>portable</DebugType>
8
+
9
+ <PackageTags>$(PackageTags), fable-library, fable-dotnet, fable-javascript, fable-python</PackageTags>
10
+ </PropertyGroup>
11
+ <ItemGroup>
12
+ <Compile Include="Shims.fs" />
13
+ <Compile Include="Result.fs" />
14
+ <Compile Include="ResultCE.fs" />
15
+ <Compile Include="ResultOp.fs" />
16
+ <Compile Include="Option.fs" />
17
+ <Compile Include="OptionCE.fs" />
18
+ <Compile Include="OptionOp.fs" />
19
+ <Compile Include="ResultOption.fs" />
20
+ <Compile Include="ResultOptionCE.fs" />
21
+ <Compile Include="ResultOptionOp.fs" />
22
+ <Compile Include="Async.fs" />
23
+ <Compile Include="AsyncResult.fs" />
24
+ <Compile Include="AsyncResultCE.fs" />
25
+ <Compile Include="AsyncResultOp.fs" />
26
+ <Compile Include="Validation.fs" />
27
+ <Compile Include="ValidationOp.fs" />
28
+ <Compile Include="ValidationCE.fs" />
29
+ <Compile Include="AsyncValidation.fs" />
30
+ <Compile Include="AsyncValidationOp.fs" />
31
+ <Compile Include="AsyncValidationCE.fs" />
32
+ <Compile Include="ValueOption.fs" />
33
+ <Compile Include="ValueOptionCE.fs" />
34
+ <Compile Include="AsyncOption.fs" />
35
+ <Compile Include="AsyncOptionCE.fs" />
36
+ <Compile Include="AsyncOptionOp.fs" />
37
+ <Compile Include="AsyncResultOption.fs" />
38
+ <Compile Include="AsyncResultOptionCE.fs" />
39
+ <Compile Include="AsyncResultOptionOp.fs" />
40
+ <Compile Include="List.fs" />
41
+ <Compile Include="Seq.fs" />
42
+ <None Include="Script.fsx" />
43
+ <None Include="paket.references" />
44
+ <Watch Include="@(None)" />
45
+ </ItemGroup>
46
+ <!-- Add source files to "fable" folder in Nuget package -->
47
+ <ItemGroup>
48
+ <Content Include="*.fsproj; **\*.fs" PackagePath="fable\" />
49
+ </ItemGroup>
50
+ <Import Project="..\..\.paket\Paket.Restore.targets" />
51
+ </Project>