Getter

dev.constructive.eo.optics.Getter
See theGetter companion class
object Getter

Constructor for Getter — read-only single-focus optic, backed by Direct with T = B = Unit. .get(s) is the only meaningful operation; the write path is vestigial.

Both the leftover T and the back-focus B are Unit, which makes the read-only-ness explicit in the type (there is no B to put back). Getter.apply returns a concrete Getter, so a Getter composes with another Getter through the ordinary andThen (the fused Getter.andThen) — g1.andThen(g2) reads s => g2.get(g1.get(s)) — exactly as Iso / Lens compose via their own fused subclasses.

Attributes

Companion
class
Source
Getter.scala
Graph
Supertypes
class Object
trait Matchable
class Any
Self type
Getter.type

Members list

Grouped members

Constructors

def apply[S, A](get: S => A): Getter[S, A]

Construct from get: S => A.

Construct from get: S => A.

Attributes

Example
case class Person(name: String, age: Int)
val nameLength = Getter[Person, Int](_.name.length)
Source
Getter.scala