-
Notifications
You must be signed in to change notification settings - Fork 9
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
Enclosing call to 'local' resets accumulated Writer value when the values share a record #93
Comments
Edited to add: it turns out that it works (i.e. both print 1) if we switch the order of the strategies |
@byorgey Thank you for reporting! This is indeed expected behavior. I agree that this should be clarified better in the docs. The following ordering
first creates a reader in the record On the other hand, if the order of
|
Ah, I get it now, thanks for the explanation! I suggest... a big fat warning attached to the I wonder if there could be a way to prevent or warn about this. It is unfortunate that there are valid ways to compose the strategies that give bogus results. You need a type system for your type-level strategy combinators... =) |
Describe the bug
Sometimes an enclosing call to 'local' for a particular Reader capability causes the accumulated value for a (conceptually unrelated) Writer capability to be reset. This only seems to happen when the concrete monad implementing the capabilities stores the values in the same record, though it's possible the record thing is a red herring.
To Reproduce
Below is the smallest example I have been able to come up with.
Expected behavior
I expect the above code to print 1 twice; which concrete monad + deriving strategies we use should not change the semantics of 'act', especially when only Reader + Writer are involved (which should commute etc.) and there are no IO or exceptions anywhere to be seen.
Instead, the above code prints 1, then 0.
Environment
The text was updated successfully, but these errors were encountered: