ce

JobOption Computation Expression

Namespace: FsToolkit.ErrorHandling

Examples:

Example 1

Given a personId and an age, find a person and update their age.

tryParseInt : string -> Option<int>
tryFindPersonById : int -> Job<Option<Person>>
updatePerson : Person -> Job<unit>
// Job<Option<unit>>
let addResult = jobOption {
  let! personId = tryParseInt "3001"
  let! age = tryParseInt "35"
  let! person = tryFindPersonById personId "US-OH"
  let person = { person with Age = age }
  do! updatePerson person
}

Last updated