map
AsyncResultOption.map
Namespace: FsToolkit.ErrorHandling
Function Signature:
('a -> 'b) -> Async<Result<'a option, 'c>>
-> Async<Result<'b option, 'c>>
Examples
Note: Many use-cases requiring map
operations can also be solved using the asyncResultOption
computation expression.
Example 1
Given the function
getUserById : UserId -> Async<Result<User option, exn>>
Then using the AsyncResultOption.map
we can get the name of the user like this:
// Async<Result<PersonName option>, exn>
getUserById sampleUserId
|> AsyncResultOption.map (fun user -> user.Name)
Last updated