Fold

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.

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

Type Params
A

the target of a Fold

S

the source of a Fold

Companion
object
Source
Fold.scala
trait Serializable
class Object
trait Matchable
class Any
trait Getter[S, A]
trait PLens[S, T, A, B]
trait PIso[S, T, A, B]
trait PTraversal[S, T, A, B]
trait POptional[S, T, A, B]
trait PPrism[S, T, A, B]

Value members

Abstract methods

def foldMap[M](f: A => M)(s: S)(`evidence$1`: 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

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

Source
Fold.scala

Concrete methods

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

check if all targets satisfy the predicate

check if all targets satisfy the predicate

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

compose a Fold with another Fold

compose a Fold with another Fold

Source
Fold.scala
def at[I, A1](i: I)(evAt: At[A, I, A1]): Fold[S, A1]
Implicitly added by foldSyntax
def each[C](evEach: Each[A, C]): Fold[S, C]
Implicitly added by foldSyntax
def exist(p: A => Boolean): S => Boolean

check if at least one target satisfies the predicate

check if at least one target satisfies the predicate

Source
Fold.scala
def filter(predicate: A => Boolean): Fold[S, A]
Implicitly added by foldSyntax

Select all the elements which satisfies the predicate. This combinator can break the fusion property see Optional.filter for more details.

Select all the elements which satisfies the predicate. This combinator can break the fusion property see Optional.filter for more details.

Source
Fold.scala
def filterIndex[I, A1](predicate: I => Boolean)(ev: FilterIndex[A, I, A1]): Fold[S, A1]
Implicitly added by foldSyntax
def find(p: A => Boolean): S => Option[A]

find the first target matching the predicate

find the first target matching the predicate

Source
Fold.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

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

get all the targets of a Fold

get all the targets of a Fold

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

get the first target

get the first target

Source
Fold.scala
def index[I, A1](i: I)(evIndex: Index[A, I, A1]): Fold[S, A1]
Implicitly added by foldSyntax
def isEmpty(s: S): Boolean

check if there is no target

check if there is no target

Source
Fold.scala
def lastOption(s: S): Option[A]

get the last target

get the last target

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

calculate the number of targets

calculate the number of targets

Source
Fold.scala
def nonEmpty(s: S): Boolean

check if there is at least one target

check if there is at least one target

Source
Fold.scala
def some[A1](ev1: A =:= Option[A1]): Fold[S, A1]
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

Source
Fold.scala
def withDefault[A1](defaultValue: A1)(evOpt: A =:= Option[A1]): Fold[S, A1]
Implicitly added by foldSyntax

Deprecated methods

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

alias to composeIso

alias to composeIso

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

alias to composePrism

alias to composePrism

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

alias to composeLens

alias to composeLens

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

alias to composeTraversal

alias to composeTraversal

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

alias to composeOptional

alias to composeOptional

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

compose a Fold with a Fold

compose a Fold with a Fold

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

compose a Fold with a Getter

compose a Fold with a Getter

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

compose a Fold with a PIso

compose a Fold with a PIso

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

compose a Fold with a PLens

compose a Fold with a PLens

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

compose a Fold with a POptional

compose a Fold with a POptional

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

compose a Fold with a PPrism

compose a Fold with a PPrism

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

compose a Fold with a PTraversal

compose a Fold with a PTraversal

Deprecated
[Since version 3.0.0-M1]
Source
Fold.scala
@deprecated("no replacement", since = "3.0.0-M4")
def left[C]: Fold[Either[S, C], Either[A, C]]
Deprecated
[Since version 3.0.0-M4]
Source
Fold.scala
@deprecated("no replacement", since = "3.0.0-M4")
def right[C]: Fold[Either[C, S], Either[C, A]]
Deprecated
[Since version 3.0.0-M4]
Source
Fold.scala

Inherited methods

def productElementNames: Iterator[String]
Implicitly added by foldSyntax
Inherited from
Product
def productIterator: Iterator[Any]
Implicitly added by foldSyntax
Inherited from
Product