by runT1ME · 10y ago · 0 comments
for {
resa <- asyncCall(1)
resb <- asyncCall(2)
resc <- asyncCall(3)
} yield new Obj(resa, resb, resc)
which just gets rewritten to asyncCall(1).flatMap(resa => asyncCall(2).flaMap(resb =>
asyncCall(3).map(resc => new Obj(resa, resb, resc))))
This doesn't just work for futures, it works for any monad. This is super amazingly useful. Also, query syntax for LINQ in C#/F# can support this too.