Last updated 3 months ago

Namespace: FsToolkit.ErrorHandling

Function Signature:

('a -> 'b) -> Async<Result<'a, 'c>>
-> Async<Result<'b, 'c>>


Example 1

As a continuation of Result.map3 (Example 2), let's assume that we want to store the created post in the database (using a fake function createPost)

// A fake function to represent the DB call
// CreatePostRequest -> Async<Result<PostId, Exception>>
let createPost (req : CreatePostRequest) = async {
// ...

To return the id of the post, using the we can achieve the following

// Async<Result<Guid>, Exception>
createPost createPostRequest
|> (fun (PostId postId) -> postId)