apply
Namespace: FsToolkit.ErrorHandling
Function Signature:
CancellableTask<('a -> 'b) option> -> CancellableTask<'a option> -> CancellableTask<'b option>
Examples
Take the following function for example
// string -> int
let characterCount (s: string) = s.Length
Example 1
let result =
CancellableTaskOption.some "foo" // CancellableTask<string option>
|> CancellableTaskOption.apply (CancellableTaskOption.some characterCount) // CancellableTask<int option>
// cancellableTask { Some 3 }
Example 2
let result =
CancellableTask.singleton None // CancellableTask<string option>
|> CancellableTaskOption.apply (CancellableTaskOption.some characterCount) // CancellableTask<int option>
// cancellableTask { None }
Example 3
let result : CancellableTask<int option> =
CancellableTaskOption.some "foo" // CancellableTask<string option>
|> CancellableTaskOption.apply (CancellableTask.singleton None) // CancellableTask<int option>
// cancellableTask { None }
Last updated