Suppose we have a list of lenses [Lens' (S a) a]
on a data structure S a
. I want to modify the focus of each lens in the data structure in the same way.
I could do this like so:
s :: S a
s = _
ls :: [Lens' (S a) a]
ls = [a, b, c]
a, b, c = _
f :: a -> a
f = _
s' :: S a
s' = s
& a %~ f
& b %~ f
& c %~ f
That's OK, but what if I have 10, 100 lenses? I would like to have something like
s' :: S a
s' = s & ls ??? f
(???) :: *
where I cannot find the operator (???)
.
Maybe it is also possible to convert ls
to a traversal and simply use (%~)
, I
don't know.
Do you have an idea?