If I have ```val lens1: Lens<S, A> val lens...
# arrow
d
If I have
Copy code
val lens1: Lens<S, A>
val lens2: Lens<S, B>
how do I apply them one after another to change field
A
then change field
B
and return
S
?
Copy code
fun modify(s: S): S {
  return lens1.modify { a.doStuff() } ?? lens2.modify { b.doStuff() }
}
i.e. I want not to compose them but to sequence them.
s
d
Nice! I also wonder how this would be done in Haskell. I'm in process of reading the book on optics, didn't see something similar there yet. My hunch is that this looks like "sequencing in context" and this speaks "Monad", but lenses are not monads, so this hunch must be wrong 🙂 Still
copy
in this PR looks like haskell's
do
🙂
s
This uses a mutable
var
in the underlying impl and applies the transformations in sequence