Gopal S Akshintala
08/15/2020, 3:20 AMparTraverse
operation is different from traverse
operation. It's not just traverse
operation in parallel. If I am not missing something, aren't their names kind of misleading?simon.vergauwen
08/15/2020, 12:50 PMparTraverse
works in a similar way as traverse
. Although the signature is a little different in Concurrent
as it is in Traverse
.
We could've implemented parTraverse
as an extension function of Traverse
which would then require Concurrent
instead of Applicative
.
Additionally, as it's with all parallel operations. if you'd launch parTraverse
on a single threaded pool, it'll behave the same as traverse
on that single pool.
That's why in Arrow Fx Coroutines you see the following optimisation.
https://github.com/arrow-kt/arrow-fx/blob/master/arrow-fx-coroutines/src/main/kotlin/arrow/fx/coroutines/ParTraverse.kt#L93
Where having no dispatcher, or having an EmptyCoroutineContext
parTraverse == traverse
.Gopal S Akshintala
08/15/2020, 2:24 PM