I propose we add support and! for task based CE
The use case is the following - we need to load several pieces of data that are not interdependent to combine them and use further on in program. Rather than doing those calls sequentially one after another it is beneficial to perform those calls concurrently and continue when all the pieces are loaded - performance optimization.
Actually, this is even covered in documentation although not implemented https://learn.microsoft.com/en-us/dotnet/fsharp/language-reference/computation-expressions#and
So basically it would be possible to simplify this code
task {
let tOne= getData1()
let tTwo= getData2()
let! results = Task.WhenAll([| tOne; tTwo|])
let one = tOne.Result
let two = tOne.Result
...
}
into this code
task {
let! one = getData1()
and! two = getData2()
...
}
More examples
The existing way of approaching this problem in F# is
- the first snippet from above
- starting all tasks first and them awaiting them one by one
task {
let tOne = getData1()
let tTwo = getData2()
let! one = tOne
let! two = tTwo
...
}
Pros and Cons
The advantages of making this adjustment to F# are clear and concise way to concurrently await multiple tasks
The disadvantages of making this adjustment to F# are i don't see disadvantages
Extra information
Estimated cost (XS, S, M, L, XL, XXL): S
Related suggestions: (put links to related suggestions here)
Affidavit (please submit!)
Please tick these items by placing a cross in the box:
Please tick all that apply:
For Readers
If you would like to see this issue implemented, please click the 👍 emoji on this issue. These counts are used to generally order the suggestions by engagement.
I propose we add support
and!for task based CEThe use case is the following - we need to load several pieces of data that are not interdependent to combine them and use further on in program. Rather than doing those calls sequentially one after another it is beneficial to perform those calls concurrently and continue when all the pieces are loaded - performance optimization.
Actually, this is even covered in documentation although not implemented https://learn.microsoft.com/en-us/dotnet/fsharp/language-reference/computation-expressions#and
So basically it would be possible to simplify this code
into this code
More examples
The existing way of approaching this problem in F# is
Pros and Cons
The advantages of making this adjustment to F# are clear and concise way to concurrently await multiple tasks
The disadvantages of making this adjustment to F# are i don't see disadvantages
Extra information
Estimated cost (XS, S, M, L, XL, XXL): S
Related suggestions: (put links to related suggestions here)
Affidavit (please submit!)
Please tick these items by placing a cross in the box:
Please tick all that apply:
For Readers
If you would like to see this issue implemented, please click the 👍 emoji on this issue. These counts are used to generally order the suggestions by engagement.