Operators
CancellableTaskValidation Infix Operators
Namespace: FsToolkit.ErrorHandling.Operator.CancellableTaskValidation
FsToolkit.ErrorHandling provides the standard infix operators for map
(<!>
), apply
(<*>
), and bind
(>>=
) to work with Result<'a, 'b list>
.
There are also variants of the map
and apply
operators (<!^>
and <*^>
) that accept Result<'a, 'b>
(non-list) as the right-hand argument.
Examples
Example 1
Assume that we have following types and functions:
We can make use of the standard operators in the CancellableTaskValidation Operators module to perform the cancellableTaskValidation of the incoming request and capture all the errors as shown below:
By using the CancellableTaskValidation
operators instead of the Result
operators, we collect all the errors:
Example 2
In the above example, all the TryCreate
functions return a string list as the error type (CancellableTask<Result<'a, string list>>
). If these functions instead returned CancellableTask<Result<'a, string>>
(only a single error), we can use <*^>
and <!^>
to get the same result:
Last updated