Skip to content

Latest commit

 

History

History
26 lines (20 loc) · 602 Bytes

File metadata and controls

26 lines (20 loc) · 602 Bytes

CancellableTaskOption Computation Expression

Namespace: FsToolkit.ErrorHandling

Examples:

Example 1

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

tryParseInt : string -> int option
tryFindPersonById : int -> CancellableTask<Person option>
updatePerson : Person -> CancellableTask<unit>
// CancellableTask<unit option>
let addResult = cancellableTaskOption {
  let! personId = tryParseInt "3001"
  let! age = tryParseInt "35"
  let! person = tryFindPersonById personId
  let person = { person with Age = age }
  do! updatePerson person
}