In this case all effects (in this case kind of expensive) are ran and then the alternatives are alt’d. This isn’t what I want, and what I think I want is parTraverse but I don’t quite understand how it works in this setup.
Applicative do on its own won’t parallelize things, it’ll only ensure you’re using your type’s Applicative instance rather than its Monad instance. Because Applicative and Monad have to agree, that means that it’ll still run sequentially. Instead, you have to use a newtype wrapper to get parallel execution. For Aff, that’s ParAff, which you can access via the sequential and parallel methods of the Parallel class:
Come to think of it, my snippet above will run all three of those to completion and then return the first Just result, which might also not be what you want. If you want to race those actions and return the first success then you might want to use the Alt ParAff instance, although that’ll require you to represent failure with an exception rather than with Nothing.
Ah, but I don’t want it to paralellized … unecessary computations/requests. Maybe do ds fine as it is sequential then? I’m mostly concerned with the unnecessary work while having alt’s <|> short-circuiting the computations while also moving on to the next Aff if it failed.
In that case I think you might want to use the Alt (MaybeT Aff) instance, which will only attempt the right hand side if the left hand side finishes with a Nothing result.