Replies: 2 comments 5 replies
-
It's already possible today to use the type AsyncBuilder with
member this.MergeSources(m1: Async<'t1>, m2: Async<'t2>) : Async<'t1 * 't2> = async {
let! m1' = Async.StartChild m1
let! m2' = Async.StartChild m2
let! m1'' = m1'
let! m2'' = m2'
return m1'', m2''
}
let workA () = async {
printfn "[A] Starting"
for i in 0..10 do
printfn "[A] i = %d" i
do! Async.Sleep 100
printfn "[A] done"
return 42
}
let workB () = async {
printfn "[B] Starting"
for i in 0..10 do
printfn "[B] i = %d" i
do! Async.Sleep 75
printfn "[B] done"
return "supercalifragilisticexpialidocious"
}
let f () = async {
let! a = workA ()
and! b = workB ()
printfn "A result: %d" a
printfn "B result: %s" b
} |
Beta Was this translation helpful? Give feedback.
5 replies
-
Impl (in both cases) an be simplified to:
(which is what Async.Parallel kinda does) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
nowadays noise increases with the amount of works I start as child, since I have to add
let! x = aX
for all of themwould be better if I could just
although
![image](https://private-user-images.githubusercontent.com/35312807/256849638-bb1bcb2e-b491-4f85-a6d8-2554ee89f148.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjQ3ODI5NDAsIm5iZiI6MTcyNDc4MjY0MCwicGF0aCI6Ii8zNTMxMjgwNy8yNTY4NDk2MzgtYmIxYmNiMmUtYjQ5MS00Zjg1LWE2ZDgtMjU1NGVlODlmMTQ4LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA4MjclMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwODI3VDE4MTcyMFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTMzMjIyMGY1YjIxMjM3ZTNkYmIzOGU0NWE5MzRjNDRlYjUwOTc5MzVhZWRhZTQ3YTBmMWZhYWM4NjhmODU2M2ImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.hQdNdGAMfaryKyukcl0q3dcUoXQrYSLJPExX8-6frJ8)
and!
is already taken, maybe we can add another keyword(if I do I get this :
)
Beta Was this translation helpful? Give feedback.
All reactions