You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I wondered what your thoughts are on a parallelAsyncCE? There exist parallelResultCE and parallelValidationCE, but no parallelAsyncCE.
Is it because there is no asyncCE because that is included in the F# Core libraries, or are there other reasons?
The different implementation possibilities are the reason why I'm not confident in implementing this correctly on my own. I don't know the implications of the different approaches.
You can use the Async.parallelMap2 implementation from this library with regular async:
#r "nuget: FsToolkit.ErrorHandling, 5"openFsToolkit.ErrorHandlingletfoo=async{return1}letbar=async{return2}async{let!x,y = Async.parallelMap2 (fun x y -> x, y) foo bar
return x + y
}
Or with CE syntax:
#r "nuget: FsToolkit.ErrorHandling, 5"openFsToolkit.ErrorHandlingtypeAsyncBuilderwithmemberthis.MergeSources(x,y)=
Async.parallelMap2 (fun i j -> i, j) x y
letfoo=async{return1}letbar=async{return2}async{let!x= foo
and! y = bar
return x + y
}
Yeah, IcedTasks has an parallelAsync implementation, however it doesn't support Fable like FsToolkit does. I'll have to think about if it makes sense to put it here because of that.
njlr's solution would work if you need it for Fable or you can used IcedTask's implementation.
We use the implementation of IcedTask in our own extension to the normal AsyncBuilder.
I guess it would be nice to have a parallelAsync in FsToolkit, though.
Coming back to this. Does including a parallelAsync CE make sense to you? And if so, how to get it in there? I'd make a pull request, but CEs are really not my strong suit. I'd need a bit of help (Pair programming, Amplifying F# session, ...).
I found out that I can copy the ParallelAsyncBuilderBase from IcedTasks and add the MergeSources as proposed by @njlr
The question remains whether you want the additional parallelAsync Builder in this library or not.
I did some simple benchmarks to compare parallelism based on Async.parallel with the IcedTasks implementation. They are almost identical - around 0.2ns difference.
Activity
njlr commentedon Jun 13, 2025
I think this would be a good addition since
and!for the officialasyncCE was rejected.There might be overlap with IcedTasks, however: https://github.com/TheAngryByrd/IcedTasks/blob/7c9ab05fc64e4f2dca99d130eae91a0243516cf8/src/IcedTasks/ParallelAsync.fs#L130-L133
Note that there are several different ways to "zip" two asyncs. This library uses
Async.Parallel, which is different to IcedTasks.ursenzler commentedon Jun 13, 2025
The different implementation possibilities are the reason why I'm not confident in implementing this correctly on my own. I don't know the implications of the different approaches.
njlr commentedon Jun 13, 2025
You can use the
Async.parallelMap2implementation from this library with regularasync:Or with CE syntax:
TheAngryByrd commentedon Jun 16, 2025
Yeah, IcedTasks has an
parallelAsyncimplementation, however it doesn't support Fable like FsToolkit does. I'll have to think about if it makes sense to put it here because of that.njlr's solution would work if you need it for Fable or you can used IcedTask's implementation.
ursenzler commentedon Jun 18, 2025
We use the implementation of IcedTask in our own extension to the normal AsyncBuilder.
I guess it would be nice to have a parallelAsync in FsToolkit, though.
ursenzler commentedon May 20, 2026
Coming back to this. Does including a parallelAsync CE make sense to you? And if so, how to get it in there? I'd make a pull request, but CEs are really not my strong suit. I'd need a bit of help (Pair programming, Amplifying F# session, ...).
ursenzler commentedon May 20, 2026
I found out that I can copy the ParallelAsyncBuilderBase from IcedTasks and add the MergeSources as proposed by @njlr
The question remains whether you want the additional parallelAsync Builder in this library or not.
I did some simple benchmarks to compare parallelism based on Async.parallel with the IcedTasks implementation. They are almost identical - around 0.2ns difference.
TheAngryByrd commentedon May 22, 2026
Yeah, I think it can live in Fstoolkit proper. Probably doesnt require IcedTasks.