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

Feature request: AVar.take that can update and return a value #19

Open
maurges opened this issue Apr 8, 2020 · 2 comments
Open

Feature request: AVar.take that can update and return a value #19

maurges opened this issue Apr 8, 2020 · 2 comments

Comments

@maurges
Copy link

maurges commented Apr 8, 2020

Like MVar.modifyMVar:
modifyAVar :: AVar a -> (a -> Effect (Tuple a b)) -> Effect b

@maurges maurges changed the title Feature request: AVar.take that can return a value Feature request: AVar.take that can update and return a value Apr 8, 2020
@maurges
Copy link
Author

maurges commented Apr 8, 2020

Looking through the library again, the Effect part leaves out a lot of synchronization functions, i'm starting to think it was on purpose

@natefaubion
Copy link
Contributor

modify variations are a purposeful omission. I consider them a footgun, because on the surface one would assume they are atomic, but really anyone can put to an AVar at any given time. I think it's something that belongs in a higher-level API than AVar for locked resources.

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

No branches or pull requests

2 participants