There are number of great tutorials and posts out there covering the more straightforward of Lens's methods, e.g. Cleaner way to update nested structures; can anyone provide example uses for these three other methods? Thanks.
Unfortunately, Scalaz7 lens examples are a WIP. You need to ask this question of the Scalaz Google Group. Before you ask, try these examples here and watch Emmett's videos.
Look at the source code again. What can you puzzle out from this?
def xmapbA[X, A >: A2 <: A1](b: Bijection[A, X]): LensFamily[X, X, B1, B2] =
xmapA(b to _)(b from _)
def xmapB[X1, X2](f: B1 => X1)(g: X2 => B2): LensFamily[A1, A2, X1, X2] =
lensFamily(a => run(a).xmap(f)(g))
def xmapbB[X, B >: B1 <: B2](b: Bijection[B, X]): LensFamily[A1, A2, X, X] =
xmapB(b to _)(b from _)
/** Modify the value viewed through the lens, returning a functor `X` full of results. */
def modf[X[+_]](f: B1 => X[B2], a: A1)(implicit XF: Functor[X]): X[A2] = {
val c = run(a)
XF.map(f(c.pos))(c put _)
}
Sorry for the minimal help. I can just point at whom to ask and what you need to know before you ask.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With