Operators

Last updated 3 months ago

AsyncResult Infix Operators

FsToolkit.ErrorHandling provides the standard infix operators for the map (<!>), apply (<*>) & bind (>>=) functions of Async<Result<'a, 'b>> type.

Namespace: FsToolkit.ErrorHandling.Operator.AsyncResult

Examples:

Example 1

The AsyncResult Computation Expression example can be written using operators as below

open FsToolkit.ErrorHandling.Operator.AsyncResult
‚Äč
// CreatePostRequest -> Async<Result<Unit,Exception>>
let createPostAndNotifyFollowers (req : CreatePostRequest) =
notifyNewPostRequest
<!> (getFollowersIds req.UserId)
<*> (createPost req)
>>= notifyFollowers