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

Add IORef-based State carrier. #422

Merged
merged 6 commits into from
Mar 10, 2022
Merged

Add IORef-based State carrier. #422

merged 6 commits into from
Mar 10, 2022

Conversation

patrickt
Copy link
Collaborator

@patrickt patrickt commented Mar 2, 2022

This was copied straight from fused-effects-exceptions.

This was copied straight from `fused-effects-exceptions`.
Copy link
Contributor

@robrix robrix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good!

Can we add tests? I know it's a bit awkward given the whole IO thing, but I'd rather not have this untested if possible. It would also pave the way toward testing its interactions with nondeterministic carriers like EmptyC, ErrorC, and ChooseC, which would be good to pin down properly.

ChangeLog.md Show resolved Hide resolved
ChangeLog.md Show resolved Hide resolved
src/Control/Carrier/State/IORef.hs Show resolved Hide resolved
src/Control/Carrier/State/IORef.hs Outdated Show resolved Hide resolved
src/Control/Carrier/State/IORef.hs Outdated Show resolved Hide resolved
src/Control/Carrier/State/IORef.hs Show resolved Hide resolved
src/Control/Carrier/State/IORef.hs Show resolved Hide resolved
src/Control/Carrier/State/IORef.hs Outdated Show resolved Hide resolved
src/Control/Carrier/State/IORef.hs Outdated Show resolved Hide resolved
Copy link
Contributor

@robrix robrix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some API doc stuff left now!

src/Control/Carrier/State/IORef.hs Outdated Show resolved Hide resolved

{- | A carrier for the 'State' effect. It uses an 'IORef' internally to handle its state, and thus admits a 'MonadUnliftIO' instance. Because the state operations are performed impurely, this carrier will not lose state effects even with nefarious uses of 'liftWith'.

Unlike the other carriers for 'State', this carrier's effects will not backtrack when run in conjuction with 'NonDet' effects.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👨🏻‍🍳💋

@robrix
Copy link
Contributor

robrix commented Mar 6, 2022

@patrickt NB: I've gone ahead and renamed the default branch to main. You'll have to update your local config as per the docs.

@robrix
Copy link
Contributor

robrix commented Mar 6, 2022

(Note also that this PR has been correctly retargeted to merge into main, so there's nothing you have to do on the remote side.)

@patrickt
Copy link
Collaborator Author

patrickt commented Mar 7, 2022

@robrix I think this is ready for another look. I agree we should test this, but propose to do this in a separate PR, as generalizing the existing machinery to either Identity or IO is somewhat fraught, and I agree that the existing tests are those that exercise paths like lifting catch and friends. Besides, we know the Monad, MonadFix etc. laws are sound because those are derived from those for ReaderC, which is already tested.

Copy link
Contributor

@robrix robrix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Beautiful 👍🏻

@robrix robrix merged commit ea2ea62 into main Mar 10, 2022
@robrix robrix deleted the impure-carrier branch March 10, 2022 00:06
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

Successfully merging this pull request may close these issues.

None yet

2 participants