bind
Namespace: FsToolkit.ErrorHandling
Function Signature
('input -> Task<'output voption>) -> Task<'input voption> -> Task<'output voption>Examples
Take the following function for example
type Account =
{ EmailAddress : string
Name : string }
// string -> Task<Account voption>
let lookupAccountByEmail email = task {
let john = { EmailAddress = "john@test.com"; Name = "John Johnson" }
let jeff = { EmailAddress = "jeff@test.com"; Name = "Jeff Jefferson" }
let jack = { EmailAddress = "jack@test.com"; Name = "Jack Jackson" }
// Just a map lookup, but imagine we look up an account in our database
let accounts = Map.ofList [
("john@test.com", john)
("jeff@test.com", jeff)
("jack@test.com", jack)
]
return
accounts
|> Map.tryFind email
|> Option.toValueOption
}Example 1
Example 2
Example 3
Last updated