Open masaeedu opened 4 years ago
This looks like mapping
yet for arbitrary Setter
(Traversal
is too strong), e.g.
Prelude Control.Lens Data.Monoid> :t mapping _Wrapped :: Iso' [Any] [Bool]
mapping _Wrapped :: Iso' [Any] [Bool]
:: (Profunctor p, Functor f) =>
p [Bool] (f [Bool]) -> p [Any] (f [Any])
So I guess if it's generalized to Setter
, mapping
can be recovered as:
liftIso :: Setter s t a b -> Setter t s b a -> Iso' a b -> Iso' s t
liftIso f b i = iso (over f (view i)) (over b (view $ re i))
mapping :: Functor f => Iso' a b -> Iso' (f a) (f b)
mapping = liftIso mapped mapped
But this is more specialized than mapping
from the library. Is there a way to generalize liftIso
further so that plugging in mapped
twice recovers the original mapping
?
Hi there. What do you think about adding an operator like:
This lets us do:
Ideally we'd have some sort of indirection that lets us accept a single traversal and
re
it, but as far as I can tell there
in the library is specialized to lenses and prisms.In the profunctor optics demanding
Foo
andCoFoo
constraints simultaneously gives you reversibility of the relevant optic. I don't know how that translates to the Haskell lens approach, so my dumb approach is just asking for two traversals.