Open KacperFKorban opened 2 years ago
a problematic comprehension might be:
for {
a <- doStuff
a <- doStuff1(a)
c <- doStuff2
a <- doStuff
} yield combine(a, c)
The most obvious desugaring of this comprehension will be wrong since the a
s will be shadowing each other (possibly in incorrect order). We use symbols though, so maybe we just need to be smart about the order of bindings picked.
Currently
avocADO
parallelizes the following comprehension:to sth conceptually like:
The reasoning behind it is that if one wants to parallelize comprehensions that have the effect monad abstracted away, the concrete monad at the end might use a sequential state. In that case, there can't be any parallelization done, because that would affect the end result of the program. In such cases, it should still be possible to use
ado
, but just provide a differentAvocADO
instance (with a sequential implementation ofzip
).Though for use cases that are more concrete, like programs based on god monads (ZIO etc.), a more aggressive parallelization should be available. One that can also reshuffle (change the order of) the expressions.
Concretely, it should be possible to convert our example (with a more aggressive strategy) to sth conceptually like: