Created
January 7, 2020 12:03
-
-
Save isaacabraham/eb62b301d0cf120f558f30a869ba5a3d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Async = | |
let Bind continuation wf = async { | |
let! wf = wf | |
return! continuation wf | |
} | |
let Map continuation = Bind (continuation >> async.Return) | |
// e.g. | |
let workflow = async { return 10 } | |
workflow | |
|> Async.Map((*) 2) // 10 * 2 | |
|> Async.Bind(fun x -> async { return x + 5 }) // 20 + 5 | |
|> Async.RunSynchronously // 25 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment