Lens

object Lens
Companion:
class
class Object
trait Matchable
class Any
Lens.type

Value members

Concrete methods

def apply[A, B](getter: A => B, setter: (A, B) => A): Lens[A, B]

Lens constructor

Lens constructor

Value parameters:
getter

function that notionally reads a value B from a given A

setter

function that notionally sets a value B into a given A

Returns:

Lens[A, B] - a lens that in some way works with a B nested in an A

def fixed[A, B](default: B): Lens[A, B]

Fixed will always get the default argument and never set it back.

Fixed will always get the default argument and never set it back.

def identity[A]: Lens[A, A]

A NoOp where the outer type is equal to the inner type and never changes. Alias for Lens.keepOriginal[A].

A NoOp where the outer type is equal to the inner type and never changes. Alias for Lens.keepOriginal[A].

def keepLatest[A]: Lens[A, A]

Simple replacement. The outer type is equal to the inner type and we always keep the latest one.

Simple replacement. The outer type is equal to the inner type and we always keep the latest one.

def keepOriginal[A]: Lens[A, A]

A NoOp where the outer type is equal to the inner type and never changes.

A NoOp where the outer type is equal to the inner type and never changes.

def readOnly[A, B](get: A => B): Lens[A, B]

Get but don't set. Implies the value B nested in A never changes. B is read only / immutable in this scope.

Get but don't set. Implies the value B nested in A never changes. B is read only / immutable in this scope.

def unit[A]: Lens[A, Unit]

Unit is like Lens.fixed(()) without the arguments, where there is no inner type (or rather, the inner type is hard coded to Unit)

Unit is like Lens.fixed(()) without the arguments, where there is no inner type (or rather, the inner type is hard coded to Unit)