-
Notifications
You must be signed in to change notification settings - Fork 43
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 roam method to Mapping
#50
Conversation
Urk. I hate how Github note things work. It would be much, much nicer to use |
Trying to pin down the representable functor to a function doesn't seem to work too well; things that can be coercions end up not. So I guess |
3c9fb9a
to
3e813d4
Compare
I don't know if this is useful or not, but `Mapping` supports a `roam` method similar to `wander`.
Is there some adjunction-like interaction happening between
|
FWIW: |
I don't know any of this theory, really. Anything The trouble with |
And for usefulness: In profunctor based optics type Setter s t a b = forall p. Mapping p => Optic p s t a b
type Optic p s t a b = p a b -> p s t
-- I don't see easy way to define without `Distributive` and `Applicative` only
setting :: ((a -> b) -> s -> t) -> Setter s t a b
setting f = roam $ \g s -> tabulate $ \idx ->
f (flip index idx . g) s
-- Distributive and Applicative constraint would be enough, if one don't need `setting`
collecting
:: (forall f. Representable f => (a -> f b) -> s -> f t)
-> Setter s t a b
collecting = roam EDIT: And because we have >>> overMany (mapped . traverse') (\i -> V2 (negate i) i) [[1,2],[3]]
V2 [[-1,-2],[-3]] [[1,2],[3]] |
I wasn't very smart about the way I defined `roam` back in ekmett#50. As @phadej noted in ekmett#50 (comment) it's practically unusable. Let's make it much simpler and more useful. This is a breaking change, but I very much doubt much code will break.
I wasn't very smart about the way I defined `roam` back in ekmett#50. As @phadej noted in ekmett#50 (comment) it's practically unusable. Let's make it much simpler and more useful. This is a breaking change, but I very much doubt much code will break.
I wasn't very smart about the way I defined `roam` back in ekmett#50. As @phadej noted in ekmett#50 (comment) it's practically unusable. Let's make it much simpler and more useful. This is a breaking change, but I very much doubt much code will break.
I wasn't very smart about the way I defined `roam` back in ekmett#50. As @phadej noted in ekmett#50 (comment) it's practically unusable. Let's make it much simpler and more useful. This is a breaking change, but I very much doubt much code will break.
I wasn't very smart about the way I defined `roam` back in #50. As @phadej noted in #50 (comment) it's practically unusable. Let's make it much simpler and more useful. This is a breaking change, but I very much doubt much code will break.
I don't know if this is useful or not, but
Mapping
supports a
roam
method similar towander
.