Mix DerivedOptics.Of[S] into any object to get the optics of S when S is not the class of that object's companion: a generic instantiation such as Box[Int], a type alias, or a type whose companion you cannot change. It works like DerivedOptics, with S given explicitly. optics needs an implicit Schema[S] where it is called, so a schema defined in the object has to be imported there.
// scala-3-only
case class Box[A](value: A)
object BoxInt extends DerivedOptics.Of[Box[Int]] {
implicit val schema: Schema[Box[Int]] = Schema.derived
}
import BoxInt.schema
val value: Lens[Box[Int], Int] = BoxInt.optics.value
Scala 3 only: the conversion that makes the derived optics of S members of the object itself, so that BoxInt.value works like BoxInt.optics.value. It takes the optics from an OpticsFor instance, which the optics macro derives. Like optics, it needs an implicit Schema[S] where it is used.
Scala 3 only: the conversion that makes the derived optics of S members of the object itself, so that BoxInt.value works like BoxInt.optics.value. It takes the optics from an OpticsFor instance, which the optics macro derives. Like optics, it needs an implicit Schema[S] where it is used.