Skip to content

Latest commit

 

History

History
42 lines (29 loc) · 936 Bytes

File metadata and controls

42 lines (29 loc) · 936 Bytes

List.sequenceJobResultM

Namespace: FsToolkit.ErrorHandling

Function Signature:

Job<Result<'a, 'b>> list -> Job<Result<'a list, 'b>>

This is the same as List.traverseJobResultM with id as the mapping function.

This is monadic, stopping on the first error. Compare with sequenceJobResultA, which collects all errors.

See also Scott Wlaschin's Understanding traverse and sequence.

Examples

Example 1

let jobs =
    [ JobResult.singleton 1
      JobResult.singleton 2
      JobResult.singleton 3 ]

jobs |> List.sequenceJobResultM
// job { return Ok [1; 2; 3] }

Example 2

let jobs =
    [ JobResult.singleton 1
      JobResult.error "oops"
      JobResult.singleton 3 ]

jobs |> List.sequenceJobResultM
// job { return Error "oops" }
// stops at first error