trait Fold[S, A] extends Serializable

A Fold can be seen as a Getter with many targets or a weaker PTraversal which cannot modify its target.

Fold is on the top of the Optic hierarchy which means that Getter, PTraversal, POptional, PLens, PPrism and PIso are valid Fold

S

the source of a Fold

A

the target of a Fold

Self Type
Fold[S, A]
Source
Fold.scala
Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Fold
  2. Serializable
  3. AnyRef
  4. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Abstract Value Members

  1. abstract def foldMap[M](f: (A) => M)(s: S)(implicit arg0: Monoid[M]): M

    map each target to a Monoid and combine the results underlying representation of Fold, all Fold methods are defined in terms of foldMap

Concrete Value Members

  1. def all(p: (A) => Boolean): (S) => Boolean

    check if all targets satisfy the predicate

  2. def andThen[B](other: Fold[A, B]): Fold[S, B]

    compose a Fold with another Fold

  3. def exist(p: (A) => Boolean): (S) => Boolean

    check if at least one target satisfies the predicate

  4. def find(p: (A) => Boolean): (S) => Option[A]

    find the first target matching the predicate

  5. def fold(s: S)(implicit ev: Monoid[A]): A

    combine all targets using a target's Monoid

  6. def getAll(s: S): List[A]

    get all the targets of a Fold

  7. def headOption(s: S): Option[A]

    get the first target

  8. def index[I, A1](i: I)(implicit evIndex: Index[A, I, A1]): Fold[S, A1]
  9. def isEmpty(s: S): Boolean

    check if there is no target

  10. def lastOption(s: S): Option[A]

    get the last target

  11. def length(s: S): Int

    calculate the number of targets

  12. def nonEmpty(s: S): Boolean

    check if there is at least one target

  13. def some[A1](implicit ev1: =:=[A, Option[A1]]): Fold[S, A1]
  14. def to[C](f: (A) => C): Fold[S, C]

    Compose with a function lifted into a Getter

Deprecated Value Members

  1. def left[C]: Fold[Either[S, C], Either[A, C]]
    Annotations
    @deprecated
    Deprecated

    (Since version 3.0.0-M4) no replacement

  2. def right[C]: Fold[Either[C, S], Either[C, A]]
    Annotations
    @deprecated
    Deprecated

    (Since version 3.0.0-M4) no replacement