Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Relude.Array.IO.sequence/traverse should be Sequential (Or Clearly Indicated As Such) #298

Open
AlexaDeWit opened this issue May 13, 2021 · 1 comment

Comments

@AlexaDeWit
Copy link

AlexaDeWit commented May 13, 2021

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

@andywhite37
Copy link
Member

andywhite37 commented May 14, 2021

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants