Given such a data structure ```data class X(val na...
# arrow
f
Given such a data structure
Copy code
data class X(val name : String)
data class Y(val x1: X, x2: X, x3 :X, x4: X)
Is there an easy way to change the
name
value of all ocurrences of
X
instances in
Y
? Using optics perhaps? Something like this:
Copy code
val y = Y(...)
val newY = changeAllNames(y) {it + "foo"}
r
Not close to an editor but with lenses it may be something like…
Copy code
X.run {
 (x1 compose x2 compose...).modify(..) { s ->
   s.toUpperCase()
 }
}