PPrism

monocle.PPrism
See thePPrism companion object
trait PPrism[S, T, A, B] extends POptional[S, T, A, B]

A PPrism can be seen as a pair of functions:

  • getOrModify: S => Either[T, A]
  • reverseGet : B => T

A PPrism could also be defined as a weaker PIso where get can fail.

Typically a PPrism or Prism encodes the relation between a Sum or CoProduct type (e.g. sealed trait) and one of its element.

PPrism stands for Polymorphic Prism as it replace and modify methods change a type A to B and S to T. Prism is a type alias for PPrism where the type of target cannot be modified:

type Prism[S, A] = PPrism[S, S, A, A]

A PPrism is also a valid Fold, POptional, PTraversal and PSetter

Attributes

A

the target of a PPrism

B

the modified target of a PPrism

S

the source of a PPrism

T

the modified source of a PPrism

See also:
Companion:
object
Source:
Prism.scala
Graph
Supertypes
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
Known subtypes
trait PIso[S, T, A, B]
Self type
PPrism[S, T, A, B]

Members list

Concise view

Value members

Abstract methods

def reverseGet(b: B): T

get the modified source of a PPrism

get the modified source of a PPrism

Attributes

Source:
Prism.scala

Concrete methods

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

compose a PPrism with another PPrism

compose a PPrism with another PPrism

Attributes

Source:
Prism.scala
def apply()(implicit ev: Is[B, Unit]): T

Attributes

Source:
Prism.scala
def apply(b: B): T

Attributes

Source:
Prism.scala
def apply[C, D](c: C, d: D)(implicit ev: As[(C, D), B]): T

Attributes

Source:
Prism.scala
def apply[C, D, E](c: C, d: D, e: E)(implicit ev: As[(C, D, E), B]): T

Attributes

Source:
Prism.scala
def apply[C, D, E, F](c: C, d: D, e: E, f: F)(implicit ev: As[(C, D, E, F), B]): T

Attributes

Source:
Prism.scala
def apply[C, D, E, F, G](c: C, d: D, e: E, f: F, g: G)(implicit ev: As[(C, D, E, F, G), B]): T

Attributes

Source:
Prism.scala
def apply[C, D, E, F, G, H](c: C, d: D, e: E, f: F, g: G, h: H)(implicit ev: As[(C, D, E, F, G, H), B]): T

Attributes

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

view a PPrism as a POptional

view a PPrism as a POptional

Attributes

Source:
Prism.scala
override def index[I, A1](i: I)(implicit evIndex: Index[A, I, A1], evMonoS: S =:= T, evMonoA: A =:= B): Optional[S, A1]

Attributes

Definition Classes
Source:
Prism.scala
override def modify(f: A => B): S => T

modify polymorphically the target of a PPrism with a function

modify polymorphically the target of a PPrism with a function

Attributes

Definition Classes
Source:
Prism.scala
def modifyA[F[_] : Applicative](f: A => F[B])(s: S): F[T]

modify polymorphically the target of a PPrism with an Applicative function

modify polymorphically the target of a PPrism with an Applicative function

Attributes

Source:
Prism.scala
def re: Getter[B, T]

create a Getter from the modified target to the modified source of a PPrism

create a Getter from the modified target to the modified source of a PPrism

Attributes

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

get the modified source of a POptional

get the modified source of a POptional

Attributes

Definition Classes
Source:
Prism.scala
override def some[A1, B1](implicit ev1: A =:= Option[A1], ev2: B =:= Option[B1]): PPrism[S, T, A1, B1]

Attributes

Definition Classes
Source:
Prism.scala
def unapply(obj: S): Option[A]

Attributes

Source:
Prism.scala

Deprecated methods

def ^<->[C, D](other: PIso[A, B, C, D]): PPrism[S, T, C, D]
Implicitly added by pPrismSyntax

alias to composeIso

alias to composeIso

Attributes

Deprecated
[Since version 3.0.0-M1]
Source:
Prism.scala
def ^<-?[C, D](other: PPrism[A, B, C, D]): PPrism[S, T, C, D]
Implicitly added by pPrismSyntax

alias to composePrism

alias to composePrism

Attributes

Deprecated
[Since version 3.0.0-M1]
Source:
Prism.scala
def ^|->[C, D](other: PLens[A, B, C, D]): POptional[S, T, C, D]
Implicitly added by pPrismSyntax

alias to composeLens

alias to composeLens

Attributes

Deprecated
[Since version 3.0.0-M1]
Source:
Prism.scala
def ^|->>[C, D](other: PTraversal[A, B, C, D]): PTraversal[S, T, C, D]
Implicitly added by pPrismSyntax

alias to composeTraversal

alias to composeTraversal

Attributes

Deprecated
[Since version 3.0.0-M1]
Source:
Prism.scala
def ^|-?[C, D](other: POptional[A, B, C, D]): POptional[S, T, C, D]
Implicitly added by pPrismSyntax

alias to composeOptional

alias to composeOptional

Attributes

Deprecated
[Since version 3.0.0-M1]
Source:
Prism.scala
def composeFold[C](other: Fold[A, C]): Fold[S, C]
Implicitly added by pPrismSyntax

compose a PPrism with a Fold

compose a PPrism with a Fold

Attributes

Deprecated
[Since version 3.0.0-M1]
Source:
Prism.scala
def composeGetter[C](other: Getter[A, C]): Fold[S, C]
Implicitly added by pPrismSyntax

compose a PPrism with a Getter

compose a PPrism with a Getter

Attributes

Deprecated
[Since version 3.0.0-M1]
Source:
Prism.scala
def composeIso[C, D](other: PIso[A, B, C, D]): PPrism[S, T, C, D]
Implicitly added by pPrismSyntax

compose a PPrism with a PIso

compose a PPrism with a PIso

Attributes

Deprecated
[Since version 3.0.0-M1]
Source:
Prism.scala
def composeLens[C, D](other: PLens[A, B, C, D]): POptional[S, T, C, D]
Implicitly added by pPrismSyntax

compose a PPrism with a PLens

compose a PPrism with a PLens

Attributes

Deprecated
[Since version 3.0.0-M1]
Source:
Prism.scala
def composeOptional[C, D](other: POptional[A, B, C, D]): POptional[S, T, C, D]
Implicitly added by pPrismSyntax

compose a PPrism with a POptional

compose a PPrism with a POptional

Attributes

Deprecated
[Since version 3.0.0-M1]
Source:
Prism.scala
def composePrism[C, D](other: PPrism[A, B, C, D]): PPrism[S, T, C, D]
Implicitly added by pPrismSyntax

compose a PPrism with a PPrism

compose a PPrism with a PPrism

Attributes

Deprecated
[Since version 3.0.0-M1]
Source:
Prism.scala
def composeSetter[C, D](other: PSetter[A, B, C, D]): PSetter[S, T, C, D]
Implicitly added by pPrismSyntax

compose a PPrism with a PSetter

compose a PPrism with a PSetter

Attributes

Deprecated
[Since version 3.0.0-M1]
Source:
Prism.scala
def composeTraversal[C, D](other: PTraversal[A, B, C, D]): PTraversal[S, T, C, D]
Implicitly added by pPrismSyntax

compose a PPrism with a PTraversal

compose a PPrism with a PTraversal

Attributes

Deprecated
[Since version 3.0.0-M1]
Source:
Prism.scala
override def first[C]: PPrism[(S, C), (T, C), (A, C), (B, C)]

Attributes

Deprecated
[Since version 3.0.0-M4]
Definition Classes
Source:
Prism.scala
override def left[C]: PPrism[Either[S, C], Either[T, C], Either[A, C], Either[B, C]]

Attributes

Deprecated
[Since version 3.0.0-M4]
Definition Classes
Source:
Prism.scala
override def right[C]: PPrism[Either[C, S], Either[C, T], Either[C, A], Either[C, B]]

Attributes

Deprecated
[Since version 3.0.0-M4]
Definition Classes
Source:
Prism.scala
override def second[C]: PPrism[(C, S), (C, T), (C, A), (C, B)]

Attributes

Deprecated
[Since version 3.0.0-M4]
Definition Classes
Source:
Prism.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

Attributes

Definition Classes
Inherited from:
POptional
Source:
Optional.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

Attributes

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

Attributes

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

compose a Fold with another Fold

compose a Fold with another Fold

Attributes

Inherited from:
Fold
Source:
Fold.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

Attributes

Inherited from:
PSetter
Source:
Setter.scala
def asFold: Fold[S, A]

view a PTraversal as a Fold

view a PTraversal as a Fold

Attributes

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

view a PTraversal as a PSetter

view a PTraversal as a PSetter

Attributes

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

Attributes

Inherited from:
POptional
Source:
Optional.scala
override def exist(p: A => Boolean): S => Boolean

check if there is a target and it satisfies the predicate

check if there is a target and it satisfies the predicate

Attributes

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

find if the target satisfies the predicate

find if the target satisfies the predicate

Attributes

Definition Classes
Inherited from:
POptional
Source:
Optional.scala
def fold(s: S)(implicit ev: Monoid[A]): A

combine all targets using a target's Monoid

combine all targets using a target's Monoid

Attributes

Inherited from:
Fold
Source:
Fold.scala
def foldMap[M : Monoid](f: A => M)(s: S): M

map each target to a Monoid and combine the results

map each target to a Monoid and combine the results

Attributes

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

get all the targets of a Fold

get all the targets of a Fold

Attributes

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

get the target of a POptional or nothing if there is no target

get the target of a POptional or nothing if there is no target

Attributes

Inherited from:
POptional
Source:
Optional.scala
def getOrModify(s: S): Either[T, A]

get the target of a POptional or return the original value while allowing the type to change if it does not match

get the target of a POptional or return the original value while allowing the type to change if it does not match

Attributes

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

get the first target

get the first target

Attributes

Inherited from:
Fold
Source:
Fold.scala
def index[I, A1](i: I)(implicit evIndex: Index[A, I, A1]): Fold[S, A1]

Attributes

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

check if there is no target

check if there is no target

Attributes

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

get the last target

get the last target

Attributes

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

calculate the number of targets

calculate the number of targets

Attributes

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

Attributes

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

check if there is a target

check if there is a target

Attributes

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

Attributes

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

PTraversal.modifyA for a Parallel applicative functor.

PTraversal.modifyA for a Parallel applicative functor.

Attributes

Inherited from:
PTraversal
Source:
Traversal.scala
Implicitly added by pPrismSyntax

Attributes

Inherited from:
Product
Implicitly added by pPrismSyntax

Attributes

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

Attributes

Inherited from:
POptional
Source:
Optional.scala
def some[A1](implicit ev1: A =:= Option[A1]): Fold[S, A1]

Attributes

Inherited from:
Fold
Source:
Fold.scala
def to[C](f: A => C): Fold[S, C]

Compose with a function lifted into a Getter

Compose with a function lifted into a Getter

Attributes

Inherited from:
Fold
Source:
Fold.scala

Deprecated and Inherited methods

def set(b: B): S => T

alias to replace

alias to replace

Attributes

Deprecated
[Since version 3.0.0-M1]
Inherited from:
PSetter
Source:
Setter.scala
def setOption(b: B): S => Option[T]

alias to replaceOption

alias to replaceOption

Attributes

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