map2
TaskResult.map2
Namespace: FsToolkit.ErrorHandling
Function Signature:
('a -> 'b -> 'c) -> Task<Result<'a, 'd>> -> Task<Result<'b, 'd>>
-> Task<Result<'c, 'd>>Examples
Note: Many use-cases requiring map operations can also be solved using the taskResult computation expression.
Example 1
Given the functions
getFollowerIds : UserId -> Task<Result<UserId list, exn>>
createPost : CreatePostRequest -> Task<Result<PostId, exn>>And the type
type NotifyNewPostRequest =
{ UserIds : UserId list
NewPostId : PostId }
static member Create userIds newPostsId =
{UserIds = userIds; NewPostId = newPostsId}We can create a NotifyNewPostRequest using TaskResult.map2 as below:
Last updated