Computation Expression
CancellableTaskValidation Computation Expression
Namespace: FsToolkit.ErrorHandling
The CancellableTaskValidation
type is defined as:
type CancellableTaskValidation<'a,'err> = CancellableTask<Result<'a, 'err list>>
This CE can take advantage of the and! operator to join multiple error results into a list.
Examples
See here for other validation-like examples
// Result<string, string> -> CancellableTask<Result<string, string>>
let downloadCancellableTask stuff = cancellableTask {
return stuff
}
// CancellableTaskValidation<string, string>
let result = cancellableTaskValidation {
let! x = downloadCancellableTask (Ok "I")
and! y = downloadCancellableTask (Ok "am")
and! z = downloadCancellableTask (Ok "cancellableTask!")
return sprintf "%s %s %s" x y z
}
// cancellableTask { return Ok "I am cancellableTask!" }
// CancellableTaskValidation<string, string>
let result = cancellableTaskValidation {
let! x = downloadCancellableTask (Error "Am")
and! y = downloadCancellableTask (Error "I")
and! z = downloadCancellableTask (Error "cancellableTask?")
return sprintf "%s %s %s" x y z
}
// cancellableTask { return Error [ "Am"; "I"; "cancellableTask?" ] }
Last updated