Lens

dev.constructive.eo.optics.Lens
object Lens

Constructors for Lens — the always-present single-focus optic, backed by Tuple2. A Lens[S, A] (short for Optic[S, S, A, A, Tuple2]) reads a field via get(s) and rewrites it via modify / replace. The eo-generics module's lens[S](_.field) macro derives both.

Attributes

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

Members list

Grouped members

Constructors

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

Monomorphic constructor (S = T, A = B).

Monomorphic constructor (S = T, A = B).

Attributes

Example
case class Person(name: String, age: Int)
val ageL = Lens[Person, Int](_.age, (p, a) => p.copy(age = a))
Source
Lens.scala
def curried[S, A](get: S => A, replace: A => S => S): GetReplaceLens[S, S, A, A]

Curried variant — accepts replace: A => S => S instead of (S, A) => S.

Curried variant — accepts replace: A => S => S instead of (S, A) => S.

Attributes

Source
Lens.scala
def first[A, B]: SimpleLens[(A, B), A, B]

Lens focusing the first element of a Tuple2. Returns a SimpleLens so place / transfer / transform land without extra evidence (S = T, A = B).

Lens focusing the first element of a Tuple2. Returns a SimpleLens so place / transfer / transform land without extra evidence (S = T, A = B).

Attributes

Source
Lens.scala
def pCurried[S, T, A, B](get: S => A, replace: B => S => T): GetReplaceLens[S & B, T, A, S]

Polymorphic counterpart to curried.

Polymorphic counterpart to curried.

Attributes

Source
Lens.scala
def pLens[S, T, A, B](get: S => A, enplace: (S, B) => T): GetReplaceLens[S, T, A, B]

Polymorphic constructor — allows S and T to differ.

Polymorphic constructor — allows S and T to differ.

Attributes

Source
Lens.scala
def second[A, B]: SimpleLens[(A, B), B, A]

Lens focusing the second element of a Tuple2.

Lens focusing the second element of a Tuple2.

Attributes

Source
Lens.scala