Skip to content

Instantly share code, notes, and snippets.

@isaacabraham
Created January 7, 2020 12:03
Show Gist options
  • Save isaacabraham/eb62b301d0cf120f558f30a869ba5a3d to your computer and use it in GitHub Desktop.
Save isaacabraham/eb62b301d0cf120f558f30a869ba5a3d to your computer and use it in GitHub Desktop.
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