I have a question about merging multiple effects. My goal is to run N commands (eg Random or Http) in parallel, then merge the results and kick off an update. Think of it an an extension of the Elm Architecture Dice exercises for N dice.
I understand you can do this with Task.map2
or Task.sequence
, but I’m looking specifically for parallel execution.
Cmd.batch
sounds like the parallel part I want, but I can’t figure out how to merge the results of the executions.
Here’s my full Elm code and here's how I'm guessing at transforming it to act in parallel (doesn't work).
For what it’s worth, in JS I’d accomplish this with Promise.all
Promise.all([promise1, promise2, …]).then(resultsList => …)
Can’t find anything on this topic online except this, which sidesteps the question: How to perform multiple Http requests (Tasks) in bulk in Elm lang and this which avoids multiple effects: How do I add a second die to this elm effects example?. Hoping this isn't still the case: Is there parallelism in Elm? (2015 answer was no).