traverseJobResultM
List.traverseJobResultM
('a -> Job<Result<'b, 'c>>) -> 'a list -> Job<Result<'b list, 'c>>Examples
Example 1
// string -> Job<Result<int, string>>
let tryParseIntJob str =
job {
match System.Int32.TryParse str with
| true, x -> return Ok x
| false, _ -> return Error (sprintf "unable to parse '%s' to integer" str)
}
["1"; "2"; "3"]
|> List.traverseJobResultM tryParseIntJob
// job { return Ok [1; 2; 3] }
["1"; "foo"; "3"; "bar"]
|> List.traverseJobResultM tryParseIntJob
// job { return Error "unable to parse 'foo' to integer" }
// stops at first errorExample 2
Last updated