sequenceResultM
Function Signature
Result<'a, 'b> list -> Result<'a list, 'b>Examples
Example 1
// string -> Result<int, string>
let tryParseInt str =
match Int32.TryParse str with
| true, x -> Ok x
| false, _ ->
Error (sprintf "unable to parse '%s' to integer" str)
["1"; "2"; "3"]
|> List.map tryParseInt
|> List.sequenceResultM
// Ok [1; 2; 3]
["1"; "foo"; "3"; "bar"]
|> List.map tryParseInt
|> List.sequenceResultM
// Error "unable to parse 'foo' to integer"Example 2
Last updated