Skip to content

Instantly share code, notes, and snippets.

@palladin
Last active September 25, 2021 17:52
Show Gist options
  • Save palladin/5872220a4e60cb6e6028 to your computer and use it in GitHub Desktop.
Save palladin/5872220a4e60cb6e6028 to your computer and use it in GitHub Desktop.
Programming with distributed functional futures
open MBrace.Core
f : Cloud<Int>
g,h : int -> Cloud<Int>
j,k : int -> int -> Cloud<int>
let spawn c = Cloud.StartAsTask c
let get t = Cloud.AwaitTask t
let (>>=) c f = cloud.Bind(c, f)
let main = cloud {
let! a = spawn f
let! b = spawn (get a >>= g)
let! c = spawn (get a >>= h)
let! d = spawn (get b >>= (fun x -> get c >>= (fun y -> j x y)))
let! e = spawn (get b >>= (fun x -> get d >>= (fun y -> k x y)))
return! get e
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment