-
Notifications
You must be signed in to change notification settings - Fork 9
Capability-retaining zoom and magnify
#73
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
Conversation
This change allows callers of the `Capability.State.zoom` and `Capability.Reader.magnify` functions to pass along a set of capabilities from the current monadic context to the focusing action. Retained capabilities are specified via a typelevel parameter of kind `[(* -> *) -> Constraint]`. Implementation relies on `unsafeCoerce` to convert a dictionary for a wrapped monad instance to the original monad. Fixes #46.
a521fb9 to
fbedb0d
Compare
| @"foobar" @"foo" @(Rename 1 :.: Pos 1 "foobar") | ||
| @('[HasState "foobar" (Int,Int)]) $ do | ||
| incFoo | ||
| incFoobar |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure that we should encourage people to have to concurrent HasState instances. It's technically legal, but it may be surprising. I shouldn't prevent us from merging this, but maybe we will want to split this into a two-state example and a zoom-while-preserving-stuff example (with, for instance, a magnifyError while preservinig a state).
aherrmann
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| -- See <https://github.com/tweag/capability/issues/46>. | ||
| zoom :: forall outertag innertag t outer inner m a. | ||
| ( forall x. Coercible (t m x) (m x) | ||
| zoom :: forall outertag innertag t (cs :: [(* -> *) -> Constraint]) outer inner m a. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same question about aliasing. Maybe it's worth a sentence in the docs.
|
@aherrmann Right, I skipped |
ed634df to
3450330
Compare
This change allows callers of the
Capability.State.zoomandCapability.Reader.magnifyfunctions to pass along a set of capabilities from the current monadic context to the focusing action. Retained capabilities are specified via a typelevel parameter of kind[(* -> *) -> Constraint].Implementation relies on
unsafeCoerceto convert a dictionary for a wrapped monad instance to the original monad.Fixes #46.