Skip to content

Instantly share code, notes, and snippets.

@adambard
Created August 10, 2017 05:28
Show Gist options
  • Save adambard/4eee89ba45a316e3ec8e82dccf18d8c1 to your computer and use it in GitHub Desktop.
Save adambard/4eee89ba45a316e3ec8e82dccf18d8c1 to your computer and use it in GitHub Desktop.
map, bind, and unit for F# Async
type Microsoft.FSharp.Control.Async with
static member unit (t:'T) : Async<'T> = async { return t }
static member bind (fn:'T -> Async<'U>) (t: Async<'T>) : Async<'U> =
async {
let! input = t
return! fn(input)
}
static member map (fn:'T -> 'U) (t:Async<'T>) : Async<'U> =
async {
let! input = t
return fn(input)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment