foldResult
TaskResult.foldResult
('a -> 'b) -> ('c -> 'b) -> Task<Result<'a, 'c>> -> Task<'b>Examples
Example 1
type HttpResponse<'a, 'b> =
| Ok of 'a
| InternalError of 'b
// CreatePostRequest -> Task<Result<PostId, exn>>
let createPost (req : CreatePostRequest) = task {
// ...
}
// Task<HttpResponse>
let handler (httpReq : HttpRequest) =
// ...
// Task<Result<PostId, exn>>
let createPostTR = createPost httpReq
createPostTR
|> TaskResult.fold Ok InternalErrorLast updated