@@ -8,10 +8,14 @@ open System.Threading
88
99// ----------------------------------------------------------------------------
1010
11- [<AutoOpen>]
12- module AsyncExtensions =
13- type Microsoft.FSharp.Control.Async with
11+ module AsyncOps =
12+
13+ let unit : Async < unit > = async.Return()
14+
1415
16+ [<AutoOpen>]
17+ module AsyncExtensions =
18+ type Microsoft.FSharp.Control.Async with
1519 /// Creates an asynchronous workflow that runs the asynchronous workflow
1620 /// given as an argument at most once. When the returned workflow is
1721 /// started for the second time, it reuses the result of the
@@ -34,4 +38,16 @@ module AsyncExtensions =
3438 let ct = new System.Threading.CancellationTokenSource()
3539 Async.Start( op, ct.Token)
3640 { new IDisposable with
37- member x.Dispose () = ct.Cancel() }
41+ member x.Dispose () = ct.Cancel() }
42+
43+ /// An async computation which does nothing.
44+ static member inline unit = AsyncOps.unit
45+
46+ /// Creates an async computation which maps a function f over the
47+ /// value produced by the specified asynchronous computation.
48+ static member inline map f a = async.Bind( a, f >> async.Return)
49+
50+ /// Creates an async computation which binds the result of the specified
51+ /// async computation to the specified function. The computation produced
52+ /// by the specified function is returned.
53+ static member inline bind f a = async.Bind( a, f)
0 commit comments