PLens

trait PLens[S, T, A, B] extends POptional[S, T, A, B] with Getter[S, A]

A PLens can be seen as a pair of functions:

A PLens can be seen as a pair of functions:

  • get: S => A i.e. from an S, we can extract an A
  • set: (B, S) => T i.e. if we replace an A by a B in an S, we obtain a T

A PLens could also be defined as a weaker PIso where replace requires an additional parameter than reverseGet.

PLens stands for Polymorphic Lens as it replace and modify methods change a type A to B and S to T. Lens is a type alias for PLens restricted to monomorphic updates:

type Lens[S, A] = PLens[S, S, A, A]

A PLens is also a valid Getter, Fold, POptional, PTraversal and PSetter

Typically a PLens or Lens can be defined between a Product (e.g. case class, tuple, HList) and one of its component.

Type Params
A

the target of a PLens

B

the modified target of a PLens

S

the source of a PLens

T

the modified source of a PLens

See also
Companion
object
Source
Lens.scala
trait Getter[S, A]
trait POptional[S, T, A, B]
trait PTraversal[S, T, A, B]
trait Fold[S, A]
trait PSetter[S, T, A, B]
trait Serializable
class Object
trait Matchable
class Any
trait PIso[S, T, A, B]

Value members

Abstract methods

def get(s: S): A

get the target of a PLens

get the target of a PLens

Source
Lens.scala
def modify(f: A => B): S => T

modify polymorphically the target of a PLens using a function

modify polymorphically the target of a PLens using a function

Source
Lens.scala
def modifyF[F[_]](f: A => F[B])(s: S)(`evidence$1`: Functor[F]): F[T]

modify polymorphically the target of a PLens using Functor function

modify polymorphically the target of a PLens using Functor function

Source
Lens.scala
def replace(b: B): S => T

replace polymorphically the target of a PLens using a function

replace polymorphically the target of a PLens using a function

Source
Lens.scala

Concrete methods

def andThen[C, D](other: PLens[A, B, C, D]): PLens[S, T, C, D]

compose a PLens with a PLens

compose a PLens with a PLens

Source
Lens.scala
override def asFold: Fold[S, A]

view a PLens as a Fold

view a PLens as a Fold

Definition Classes
Source
Lens.scala
def asGetter: Getter[S, A]

view a PLens as a Getter

view a PLens as a Getter

Source
Lens.scala
def asOptional: POptional[S, T, A, B]

view a PLens as an POptional

view a PLens as an POptional

Source
Lens.scala
override def exist(p: A => Boolean): S => Boolean

check if the target satisfies the predicate

check if the target satisfies the predicate

Definition Classes
Source
Lens.scala
override def find(p: A => Boolean): S => Option[A]

find if the target satisfies the predicate

find if the target satisfies the predicate

Definition Classes
Source
Lens.scala
override def foldMap[M](f: A => M)(s: S)(`evidence$3`: Monoid[M]): M
Definition Classes
Source
Lens.scala
def getOption(s: S): Option[A]
def getOrModify(s: S): Either[T, A]
override def modifyA[F[_]](f: A => F[B])(s: S)(`evidence$2`: Applicative[F]): F[T]
Definition Classes
Source
Lens.scala
override def some[A1, B1](ev1: A =:= Option[A1], ev2: B =:= Option[B1]): POptional[S, T, A1, B1]
Definition Classes
Source
Lens.scala
override def to[C](f: A => C): Getter[S, C]

Compose with a function lifted into a Getter

Compose with a function lifted into a Getter

Definition Classes
Source
Lens.scala

Deprecated methods

@deprecated("use andThen", since = "3.0.0-M1")
def ^<->[C, D](other: PIso[A, B, C, D]): PLens[S, T, C, D]
Implicitly added by pLensSyntax

alias to composeIso

alias to composeIso

Deprecated
[Since version 3.0.0-M1]
Source
Lens.scala
@deprecated("use andThen", since = "3.0.0-M1")
def ^<-?[C, D](other: PPrism[A, B, C, D]): POptional[S, T, C, D]
Implicitly added by pLensSyntax

alias to composePrism

alias to composePrism

Deprecated
[Since version 3.0.0-M1]
Source
Lens.scala
@deprecated("use andThen", since = "3.0.0-M1")
def ^|->[C, D](other: PLens[A, B, C, D]): PLens[S, T, C, D]
Implicitly added by pLensSyntax

alias to composeLens

alias to composeLens

Deprecated
[Since version 3.0.0-M1]
Source
Lens.scala
@deprecated("use andThen", since = "3.0.0-M1")
def ^|->>[C, D](other: PTraversal[A, B, C, D]): PTraversal[S, T, C, D]
Implicitly added by pLensSyntax

alias to composeTraversal

alias to composeTraversal

Deprecated
[Since version 3.0.0-M1]
Source
Lens.scala
@deprecated("use andThen", since = "3.0.0-M1")
def ^|-?[C, D](other: POptional[A, B, C, D]): POptional[S, T, C, D]
Implicitly added by pLensSyntax

alias to composeOptional

alias to composeOptional

Deprecated
[Since version 3.0.0-M1]
Source
Lens.scala
@deprecated("use andThen", since = "3.0.0-M1")
def composeFold[C](other: Fold[A, C]): Fold[S, C]
Implicitly added by pLensSyntax

compose a PLens with a Fold

compose a PLens with a Fold

Deprecated
[Since version 3.0.0-M1]
Source
Lens.scala
@deprecated("use andThen", since = "3.0.0-M1")
def composeGetter[C](other: Getter[A, C]): Getter[S, C]
Implicitly added by pLensSyntax

compose a PLens with a Getter

compose a PLens with a Getter

Deprecated
[Since version 3.0.0-M1]
Source
Lens.scala
@deprecated("use andThen", since = "3.0.0-M1")
def composeIso[C, D](other: PIso[A, B, C, D]): PLens[S, T, C, D]
Implicitly added by pLensSyntax

compose a PLens with an PIso

compose a PLens with an PIso

Deprecated
[Since version 3.0.0-M1]
Source
Lens.scala
@deprecated("use andThen", since = "3.0.0-M1")
def composeLens[C, D](other: PLens[A, B, C, D]): PLens[S, T, C, D]
Implicitly added by pLensSyntax

compose a PLens with a PLens

compose a PLens with a PLens

Deprecated
[Since version 3.0.0-M1]
Source
Lens.scala
@deprecated("use andThen", since = "3.0.0-M1")
def composeOptional[C, D](other: POptional[A, B, C, D]): POptional[S, T, C, D]
Implicitly added by pLensSyntax

compose a PLens with an POptional

compose a PLens with an POptional

Deprecated
[Since version 3.0.0-M1]
Source
Lens.scala
@deprecated("use andThen", since = "3.0.0-M1")
def composePrism[C, D](other: PPrism[A, B, C, D]): POptional[S, T, C, D]
Implicitly added by pLensSyntax

compose a PLens with a PPrism

compose a PLens with a PPrism

Deprecated
[Since version 3.0.0-M1]
Source
Lens.scala
@deprecated("use andThen", since = "3.0.0-M1")
def composeSetter[C, D](other: PSetter[A, B, C, D]): PSetter[S, T, C, D]
Implicitly added by pLensSyntax

compose a PLens with a PSetter

compose a PLens with a PSetter

Deprecated
[Since version 3.0.0-M1]
Source
Lens.scala
@deprecated("use andThen", since = "3.0.0-M1")
def composeTraversal[C, D](other: PTraversal[A, B, C, D]): PTraversal[S, T, C, D]
Implicitly added by pLensSyntax

compose a PLens with a PTraversal

compose a PLens with a PTraversal

Deprecated
[Since version 3.0.0-M1]
Source
Lens.scala
@deprecated("no replacement", since = "3.0.0-M4")
override def first[C]: PLens[(S, C), (T, C), (A, C), (B, C)]
Deprecated
[Since version 3.0.0-M4]
Definition Classes
Source
Lens.scala
@deprecated("no replacement", since = "3.0.0-M4")
override def second[C]: PLens[(C, S), (C, T), (C, A), (C, B)]
Deprecated
[Since version 3.0.0-M4]
Definition Classes
Source
Lens.scala
@deprecated("no replacement", since = "3.0.0-M4")
def split[S1, T1, A1, B1](other: PLens[S1, T1, A1, B1]): PLens[(S, S1), (T, T1), (A, A1), (B, B1)]

pair two disjoint PLens

pair two disjoint PLens

Deprecated
[Since version 3.0.0-M4]
Source
Lens.scala

Inherited methods

override def all(p: A => Boolean): S => Boolean

check if there is no target or the target satisfies the predicate

check if there is no target or the target satisfies the predicate

Definition Classes
Inherited from
POptional
Source
Optional.scala
def andThen[B](other: Getter[A, B]): Getter[S, B]

compose a Getter with a Getter

compose a Getter with a Getter

Inherited from
Getter
Source
Getter.scala
def andThen[B](other: Fold[A, B]): Fold[S, B]

compose a Fold with another Fold

compose a Fold with another Fold

Inherited from
Fold
Source
Fold.scala
def andThen[C, D](other: POptional[A, B, C, D]): POptional[S, T, C, D]

compose a POptional with a POptional

compose a POptional with a POptional

Inherited from
POptional
Source
Optional.scala
def andThen[C, D](other: PTraversal[A, B, C, D]): PTraversal[S, T, C, D]

compose a PTraversal with another PTraversal

compose a PTraversal with another PTraversal

Inherited from
PTraversal
Source
Traversal.scala
def andThen[C, D](other: PSetter[A, B, C, D]): PSetter[S, T, C, D]

compose a PSetter with another PSetter

compose a PSetter with another PSetter

Inherited from
PSetter
Source
Setter.scala
def asSetter: PSetter[S, T, A, B]

view a PTraversal as a PSetter

view a PTraversal as a PSetter

Inherited from
PTraversal
Source
Traversal.scala
def asTraversal: PTraversal[S, T, A, B]

view a POptional as a PTraversal

view a POptional as a PTraversal

Inherited from
POptional
Source
Optional.scala
def choice[S1](other: Getter[S1, A]): Getter[Either[S, S1], A]

join two Getter with the same target

join two Getter with the same target

Inherited from
Getter
Source
Getter.scala
def fold(s: S)(ev: Monoid[A]): A

combine all targets using a target's Monoid

combine all targets using a target's Monoid

Inherited from
Fold
Source
Fold.scala
def getAll(s: S): List[A]

get all the targets of a Fold

get all the targets of a Fold

Inherited from
Fold
Source
Fold.scala
def headOption(s: S): Option[A]

get the first target

get the first target

Inherited from
Fold
Source
Fold.scala
override def isEmpty(s: S): Boolean

check if there is no target

check if there is no target

Definition Classes
Inherited from
POptional
Source
Optional.scala
def lastOption(s: S): Option[A]

get the last target

get the last target

Inherited from
Fold
Source
Fold.scala
def length(s: S): Int

calculate the number of targets

calculate the number of targets

Inherited from
Fold
Source
Fold.scala
def modifyOption(f: A => B): S => Option[T]

modify polymorphically the target of a POptional with a function. return empty if the POptional is not matching

modify polymorphically the target of a POptional with a function. return empty if the POptional is not matching

Inherited from
POptional
Source
Optional.scala
override def nonEmpty(s: S): Boolean

check if there is a target

check if there is a target

Definition Classes
Inherited from
POptional
Source
Optional.scala
def orElse(other: POptional[S, T, A, B]): POptional[S, T, A, B]

fall-back to another POptional in case this one doesn't match

fall-back to another POptional in case this one doesn't match

Inherited from
POptional
Source
Optional.scala
def parModifyF[F[_]](f: A => F[B])(s: S)(F: Parallel[F]): F[T]

PTraversal.modifyA for a Parallel applicative functor.

PTraversal.modifyA for a Parallel applicative functor.

Inherited from
PTraversal
Source
Traversal.scala
def productElementNames: Iterator[String]
Implicitly added by pLensSyntax
Inherited from
Product
def productIterator: Iterator[Any]
Implicitly added by pLensSyntax
Inherited from
Product
def replaceOption(b: B): S => Option[T]

replace polymorphically the target of a POptional with a value. return empty if the POptional is not matching

replace polymorphically the target of a POptional with a value. return empty if the POptional is not matching

Inherited from
POptional
Source
Optional.scala
override def some[A1](ev1: A =:= Option[A1]): Fold[S, A1]
Definition Classes
Inherited from
Getter
Source
Getter.scala
def split[S1, A1](other: Getter[S1, A1]): Getter[(S, S1), (A, A1)]

pair two disjoint Getter

pair two disjoint Getter

Inherited from
Getter
Source
Getter.scala
def zip[A1](other: Getter[S, A1]): Getter[S, (A, A1)]
Inherited from
Getter
Source
Getter.scala

Deprecated and Inherited methods

@deprecated("no replacement", since = "3.0.0-M4")
override def left[C]: Getter[Either[S, C], Either[A, C]]
Deprecated
[Since version 3.0.0-M4]
Definition Classes
Inherited from
Getter
Source
Getter.scala
@deprecated("no replacement", since = "3.0.0-M4")
override def right[C]: Getter[Either[C, S], Either[C, A]]
Deprecated
[Since version 3.0.0-M4]
Definition Classes
Inherited from
Getter
Source
Getter.scala
@deprecated("use replace instead", since = "3.0.0-M1")
def set(b: B): S => T

alias to replace

alias to replace

Deprecated
[Since version 3.0.0-M1]
Inherited from
PSetter
Source
Setter.scala
@deprecated("use replaceOption instead", since = "3.0.0-M1")
def setOption(b: B): S => Option[T]

alias to replaceOption

alias to replaceOption

Deprecated
[Since version 3.0.0-M1]
Inherited from
POptional
Source
Optional.scala