How to create Monocle lenses with sequences?

247 Views Asked by At

I am trying to create a Monocle lens with nested case classes and sequences.

import monocle.macros.GenLens
import monocle.function.Each.each

case class A(bs: Seq[B])
case class B(c: Int)

val bs = GenLens[A](_.bs)
val c = GenLens[B](_.c)

val cs = (bs composeTraversal each composeLens c)

Compilation fails on the last line. I am using Monocle 1.5.0-cats.

PS: replacing Seq[B] by List[B] works, but my case classes are generated by scalaxb, which uses sequences.

1

There are 1 best solutions below

1
On

I know this is not a "real answer" but I also have issues with Seq in Monokle. I get exactly the same answer from my very experienced colleague: "There is no support to Seq from Cats. This is the reason good enough to not use it. Use Vector as the Seq default implementation". :(