relude
relude copied to clipboard
Relude.Array.IO.sequence/traverse should be Sequential (Or Clearly Indicated As Such)
A rather tricky pitfal is that The sequence/traverse behaviours run their effects immediately, which, for performance reasons, is perfectly understandable to want as a feature, but the documentarion does not make this clear, resulting in a risk of unexpected race conditions.
I'd propose that this be documented clearly in their comments, and that additional functionals that perform the sequential effects be added at the same module level (so as to make finding the right behaviour trivial).
Unless there are other suggestions?
I'd be happy to write the PR later this week, as it's not complex to implement.
Confusion around this is also party the cause of #297
Yeah, one idea might be to implement a separate version of the apply
function that runs the effects in sequence, and then create secondary Apply
/Applicative
and maybe Monad
instances that use those semantics. The Monad
instances are sequential by nature, but there are some subtle differences in how it works when the underlying applicative has parallel or sequential semantics. I think there have been debates about whether a parallel, error-collecting applicative can work with a Monad - like what's mentioned here https://hackage.haskell.org/package/validation . I think other people maybe contest this claim, so maybe it's more of a convention than something related to laws.
Some other libraries have a similar setup for async effect types like IO/Task/Future/etc. - I can try to link to examples.
I'm open to whatever you'd like to propose though - I want this library to be useful to the users!