Of

zio.blocks.schema.DerivedOptics.Of
trait Of[S]

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

Attributes

Source
DerivedOptics.scala
Graph
Supertypes
class Object
trait Matchable
class Any

Members list

Value members

Concrete methods

transparent inline def optics(using schema: Schema[S]): Any

Returns the derived optics of S, like DerivedOptics#optics. It needs an implicit Schema[S] where it is called.

Returns the derived optics of S, like DerivedOptics#optics. It needs an implicit Schema[S] where it is called.

Attributes

Source
DerivedOptics.scala

Givens

Givens

given toDerivedOptics: OpticsFor[S] => Conversion[this.type, opticsFor.Out]

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.

Attributes

Source
DerivedOptics.scala