Monocle
Monocle copied to clipboard
Variance for optics type parameters
Add variance to the optics type parameters, eg [-S, +T, +A, -B]
.
Julien:
It helps with
Some(1).focus(_.some).replace(2)
Without variance, I believe you get an error and need to manually upcast
Some(1): Option[Int]
This example used to work in Monocly: https://github.com/optics-dev/Monocly/blob/master/src/main/scala/Main.scala#L24-L26
It is likely we will have some issues with cats typeclasses beeing invariants like Functor
or Applicative
. We need to use @uncheckedVariance
annotations.