File tree Expand file tree Collapse file tree 5 files changed +57
-0
lines changed
src/FsToolkit.ErrorHandling Expand file tree Collapse file tree 5 files changed +57
-0
lines changed Original file line number Diff line number Diff line change 131131 * [ apply] ( asyncResultOption/apply.md )
132132 * [ bind] ( asyncResultOption/bind.md )
133133 * [ Computation Expression] ( asyncResultOption/ce.md )
134+ * [ error] ( asyncResultOption/error.md )
134135 * [ ignore] ( asyncResultOption/ignore.md )
135136 * [ map] ( asyncResultOption/map.md )
136137 * [ map2] ( asyncResultOption/map2.md )
196197 * [ apply] ( taskResultOption/apply.md )
197198 * [ bind] ( taskResultOption/bind.md )
198199 * [ Computation Expression] ( taskResultOption/ce.md )
200+ * [ error] ( taskResultOption/error.md )
199201 * [ ignore] ( taskResultOption/ignore.md )
200202 * [ map] ( taskResultOption/map.md )
201203 * [ map2] ( taskResultOption/map2.md )
Original file line number Diff line number Diff line change 1+ ## AsyncResultOption.error
2+
3+ Namespace: ` FsToolkit.ErrorHandling `
4+
5+ Lift an ` 'error ` value into an ` Async<Result<'ok option, 'error>> `
6+
7+ ## Function Signature:
8+
9+ ``` fsharp
10+ 'error -> Async<Result<'ok option, 'error>>
11+ ```
12+
13+ ## Examples
14+
15+ ### Example 1
16+
17+
18+ ``` fsharp
19+ let result : Async<Result<int option, string>> =
20+ AsyncResultOption.error "Something bad happened"
21+ ```
22+
Original file line number Diff line number Diff line change 1+ ## TaskResultOption.error
2+
3+ Namespace: ` FsToolkit.ErrorHandling `
4+
5+ Lift an ` 'error ` value into an ` Task<Result<'ok option, 'error>> `
6+
7+ ## Function Signature:
8+
9+ ``` fsharp
10+ 'error -> Task<Result<'ok option, 'error>>
11+ ```
12+
13+ ## Examples
14+
15+ ### Example 1
16+
17+
18+ ``` fsharp
19+ let result : Task<Result<int option, string>> =
20+ TaskResultOption.error "Something bad happened"
21+ ```
22+
Original file line number Diff line number Diff line change @@ -24,6 +24,13 @@ module AsyncResultOption =
2424 )
2525 input
2626
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
2734
2835 let inline map2
2936 ( [<InlineIfLambda>] mapper : 'okInput1 -> 'okInput2 -> 'okOutput )
Original file line number Diff line number Diff line change @@ -23,6 +23,10 @@ module TaskResultOption =
2323
2424 let inline singleton value = TaskResult.ok ( Some value)
2525
26+ let inline ok x = singleton x
27+
28+ let inline error x : TaskResult < 'ok option , 'error > = TaskResult.error x
29+
2630 let inline apply fTRO xTRO = map2 ( fun f x -> f x) fTRO xTRO
2731
2832 /// Replaces the wrapped value with unit
You can’t perform that action at this time.
0 commit comments