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

S

the source of a PPrism

T

the modified source of a PPrism

A

the target of a PPrism

B

the modified target of a PPrism

Self Type
PPrism[S, T, A, B]
Source
Prism.scala
See also

monocle.law.PrismLaws

Linear Supertypes
POptional[S, T, A, B], PTraversal[S, T, A, B], Fold[S, A], PSetter[S, T, A, B], Serializable, AnyRef, Any
Known Subclasses
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. PPrism
  2. POptional
  3. PTraversal
  4. Fold
  5. PSetter
  6. Serializable
  7. AnyRef
  8. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Abstract Value Members

  1. abstract 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

    Definition Classes
    POptional
  2. abstract 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

    Definition Classes
    POptional
  3. abstract def reverseGet(b: B): T

    get the modified source of a PPrism

Concrete Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##: Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. 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
    POptionalFold
  5. def andThen[C, D](other: PPrism[A, B, C, D]): PPrism[S, T, C, D]

    compose a PPrism with another PPrism

  6. 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

    Definition Classes
    POptional
  7. 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

    Definition Classes
    PTraversal
  8. def andThen[B](other: Fold[A, B]): Fold[S, B]

    compose a Fold with another Fold

    compose a Fold with another Fold

    Definition Classes
    Fold
  9. 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

    Definition Classes
    PSetter
  10. def apply[C, D, E, F, G, H](c: C, d: D, e: E, f: F, g: G, h: H)(implicit ev: <~<[(C, D, E, F, G, H), B]): T
  11. def apply[C, D, E, F, G](c: C, d: D, e: E, f: F, g: G)(implicit ev: <~<[(C, D, E, F, G), B]): T
  12. def apply[C, D, E, F](c: C, d: D, e: E, f: F)(implicit ev: <~<[(C, D, E, F), B]): T
  13. def apply[C, D, E](c: C, d: D, e: E)(implicit ev: <~<[(C, D, E), B]): T
  14. def apply[C, D](c: C, d: D)(implicit ev: <~<[(C, D), B]): T
  15. def apply(b: B): T
  16. def apply()(implicit ev: Is[B, Unit]): T

    **********************************************************************

  17. def asFold: Fold[S, A]

    view a PTraversal as a Fold

    view a PTraversal as a Fold

    Definition Classes
    PTraversal
  18. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  19. def asOptional: POptional[S, T, A, B]

    view a PPrism as a POptional

  20. def asSetter: PSetter[S, T, A, B]

    view a PTraversal as a PSetter

    view a PTraversal as a PSetter

    Definition Classes
    PTraversal
  21. def asTraversal: PTraversal[S, T, A, B]

    view a POptional as a PTraversal

    view a POptional as a PTraversal

    Definition Classes
    POptional
  22. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @native()
  23. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  24. def equals(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef → Any
  25. 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

    Definition Classes
    POptionalFold
  26. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable])
  27. def find(p: (A) => Boolean): (S) => Option[A]

    find if the target satisfies the predicate

    find if the target satisfies the predicate

    Definition Classes
    POptionalFold
  28. 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

    Definition Classes
    Fold
  29. def foldMap[M](f: (A) => M)(s: S)(implicit arg0: Monoid[M]): M

    map each target to a Monoid and combine the results

    map each target to a Monoid and combine the results

    Definition Classes
    PTraversalFold
  30. def getAll(s: S): List[A]

    get all the targets of a Fold

    get all the targets of a Fold

    Definition Classes
    Fold
  31. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  32. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  33. def headOption(s: S): Option[A]

    get the first target

    get the first target

    Definition Classes
    Fold
  34. def index[I, A1](i: I)(implicit evIndex: Index[A, I, A1], evMonoS: =:=[S, T], evMonoA: =:=[A, B]): Optional[S, A1]
    Definition Classes
    PPrismPOptionalPTraversalPSetter
  35. def index[I, A1](i: I)(implicit evIndex: Index[A, I, A1]): Fold[S, A1]
    Definition Classes
    Fold
  36. def isEmpty(s: S): Boolean

    check if there is no target

    check if there is no target

    Definition Classes
    POptionalFold
  37. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  38. def lastOption(s: S): Option[A]

    get the last target

    get the last target

    Definition Classes
    Fold
  39. def length(s: S): Int

    calculate the number of targets

    calculate the number of targets

    Definition Classes
    Fold
  40. 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

    Definition Classes
    PPrismPTraversalPSetter
  41. def modifyA[F[_]](f: (A) => F[B])(s: S)(implicit arg0: Applicative[F]): F[T]

    modify polymorphically the target of a PPrism with an Applicative function

    modify polymorphically the target of a PPrism with an Applicative function

    Definition Classes
    PPrismPTraversal
  42. def modifyOption(f: (A) => B): (S) => Option[T]

    modify polymorphically the target of a POptional with a function.

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

    Definition Classes
    POptional
  43. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  44. def nonEmpty(s: S): Boolean

    check if there is a target

    check if there is a target

    Definition Classes
    POptionalFold
  45. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  46. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  47. 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

    Definition Classes
    POptional
  48. 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.

    Definition Classes
    PTraversal
  49. def re: Getter[B, T]

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

  50. def replace(b: B): (S) => T

    get the modified source of a POptional

    get the modified source of a POptional

    Definition Classes
    PPrismPOptionalPTraversalPSetter
  51. def replaceOption(b: B): (S) => Option[T]

    replace polymorphically the target of a POptional with a value.

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

    Definition Classes
    POptional
  52. def some[A1, B1](implicit ev1: =:=[A, Option[A1]], ev2: =:=[B, Option[B1]]): PPrism[S, T, A1, B1]
    Definition Classes
    PPrismPOptionalPTraversalPSetter
  53. def some[A1](implicit ev1: =:=[A, Option[A1]]): Fold[S, A1]
    Definition Classes
    Fold
  54. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  55. 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

    Definition Classes
    Fold
  56. def toString(): String
    Definition Classes
    AnyRef → Any
  57. def unapply(obj: S): Option[A]
  58. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  59. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  60. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()

Deprecated Value Members

  1. def first[C]: PPrism[(S, C), (T, C), (A, C), (B, C)]
    Definition Classes
    PPrismPOptional
    Annotations
    @deprecated
    Deprecated

    (Since version 3.0.0-M4) no replacement

  2. def left[C]: PPrism[Either[S, C], Either[T, C], Either[A, C], Either[B, C]]
    Definition Classes
    PPrismFold
    Annotations
    @deprecated
    Deprecated

    (Since version 3.0.0-M4) no replacement

  3. def right[C]: PPrism[Either[C, S], Either[C, T], Either[C, A], Either[C, B]]
    Definition Classes
    PPrismFold
    Annotations
    @deprecated
    Deprecated

    (Since version 3.0.0-M4) no replacement

  4. def second[C]: PPrism[(C, S), (C, T), (C, A), (C, B)]
    Definition Classes
    PPrismPOptional
    Annotations
    @deprecated
    Deprecated

    (Since version 3.0.0-M4) no replacement

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

    alias to replace

    alias to replace

    Definition Classes
    PSetter
    Annotations
    @deprecated
    Deprecated

    (Since version 3.0.0-M1) use replace instead

  6. def setOption(b: B): (S) => Option[T]

    alias to replaceOption

    alias to replaceOption

    Definition Classes
    POptional
    Annotations
    @deprecated
    Deprecated

    (Since version 3.0.0-M1) use replaceOption instead

Inherited from POptional[S, T, A, B]

Inherited from PTraversal[S, T, A, B]

Inherited from Fold[S, A]

Inherited from PSetter[S, T, A, B]

Inherited from Serializable

Inherited from AnyRef

Inherited from Any

Ungrouped