Foldable

trait Foldable[F[_]]

A type parameter implying the ability to extract zero or more values of that type.

Companion
object
class Object
trait Matchable
class Any
trait FromFoldMap[F]
trait FromFoldr[F]
trait Foldable1[F]
trait Traverse1[F]
trait Traverse[F]

Type members

Classlikes

Value members

Abstract methods

def foldMap[A, B](fa: F[A])(f: A => B)(implicit F: Monoid[B]): B

Map each element of the structure to a scalaz.Monoid, and combine the results.

Map each element of the structure to a scalaz.Monoid, and combine the results.

def foldRight[A, B](fa: F[A], z: => B)(f: (A, => B) => B): B

Right-associative fold of a structure.

Right-associative fold of a structure.

Concrete methods

def all[A](fa: F[A])(p: A => Boolean): Boolean

Whether all As in fa yield true from p.

Whether all As in fa yield true from p.

def allM[G[_], A](fa: F[A])(p: A => G[Boolean])(implicit G: Monad[G]): G[Boolean]

all with monadic traversal.

all with monadic traversal.

def any[A](fa: F[A])(p: A => Boolean): Boolean

Whether any As in fa yield true from p.

Whether any As in fa yield true from p.

def anyM[G[_], A](fa: F[A])(p: A => G[Boolean])(implicit G: Monad[G]): G[Boolean]

any with monadic traversal.

any with monadic traversal.

final
def asum[G[_], A](fa: F[G[A]])(implicit G: PlusEmpty[G]): G[A]

Alias for psum. asum is the name used in Haskell.

Alias for psum. asum is the name used in Haskell.

def bicompose[G[_, _] : Bifoldable]: Bifoldable[[α, β] =>> F[G[α, β]]]

The composition of Foldable F and Bifoldable G, [x, y]F[G[x, y]], is a Bifoldable

The composition of Foldable F and Bifoldable G, [x, y]F[G[x, y]], is a Bifoldable

def collapse[X[_], A](x: F[A])(implicit A: ApplicativePlus[X]): X[A]
def compose[G[_]](implicit G0: Foldable[G]): Foldable[[α] =>> F[G[α]]]

The composition of Foldables F and G, [x]F[G[x]], is a Foldable

The composition of Foldables F and G, [x]F[G[x]], is a Foldable

final
def count[A](fa: F[A]): Int

Alias for length.

Alias for length.

def distinct[A](fa: F[A])(implicit A: Order[A]): IList[A]

O(n log n) complexity

O(n log n) complexity

def distinctBy[A, B : Equal](fa: F[A])(f: A => B): IList[A]
def distinctE[A](fa: F[A])(implicit A: Equal[A]): IList[A]

O(n^2^) complexity

O(n^2^) complexity

def element[A : Equal](fa: F[A], a: A): Boolean

Whether a is an element of fa.

Whether a is an element of fa.

def empty[A](fa: F[A]): Boolean

Deforested alias for toStream(fa).isEmpty.

Deforested alias for toStream(fa).isEmpty.

def extrema[A : Order](fa: F[A]): Option[(A, A)]

The smallest and largest elements of fa or None if fa is empty

The smallest and largest elements of fa or None if fa is empty

def extremaBy[A, B : Order](fa: F[A])(f: A => B): Option[(A, A)]

The elements (amin, amax) of fa which yield the smallest and largest values of f(a), respectively, or None if fa is empty

The elements (amin, amax) of fa which yield the smallest and largest values of f(a), respectively, or None if fa is empty

def extremaOf[A, B : Order](fa: F[A])(f: A => B): Option[(B, B)]

The smallest and largest values of f(a) for each element a of fa , or None if fa is empty

The smallest and largest values of f(a) for each element a of fa , or None if fa is empty

def filterLength[A](fa: F[A])(f: A => Boolean): Int
def findLeft[A](fa: F[A])(f: A => Boolean): Option[A]
final
def findMapM[M[_] : Monad, A, B](fa: F[A])(f: A => M[Option[B]]): M[Option[B]]

map elements in a Foldable with a monadic function and return the first element that is mapped successfully

map elements in a Foldable with a monadic function and return the first element that is mapped successfully

def findRight[A](fa: F[A])(f: A => Boolean): Option[A]
def fold[M : Monoid](t: F[M]): M

Combine the elements of a structure using a monoid.

Combine the elements of a structure using a monoid.

def fold1Opt[A : Semigroup](fa: F[A]): Option[A]

Like fold but returning None if the foldable is empty and Some otherwise

Like fold but returning None if the foldable is empty and Some otherwise

def foldLeft[A, B](fa: F[A], z: B)(f: (B, A) => B): B

Left-associative fold of a structure.

Left-associative fold of a structure.

def foldLeft1Opt[A](fa: F[A])(f: (A, A) => A): Option[A]
def foldLeftM[G[_], A, B](fa: F[A], z: B)(f: (B, A) => G[B])(implicit M: Monad[G]): G[B]

Left-associative, monadic fold of a structure.

Left-associative, monadic fold of a structure.

def foldMap1Opt[A, B](fa: F[A])(f: A => B)(implicit F: Semigroup[B]): Option[B]

As foldMap but returning None if the foldable is empty and Some otherwise

As foldMap but returning None if the foldable is empty and Some otherwise

def foldMapLeft1Opt[A, B](fa: F[A])(z: A => B)(f: (B, A) => B): Option[B]
def foldMapM[G[_], A, B](fa: F[A])(f: A => G[B])(implicit B: Monoid[B], G: Monad[G]): G[B]

Specialization of foldRightM when B has a Monoid.

Specialization of foldRightM when B has a Monoid.

def foldMapRight1Opt[A, B](fa: F[A])(z: A => B)(f: (A, => B) => B): Option[B]
def foldRight1Opt[A](fa: F[A])(f: (A, => A) => A): Option[A]
def foldRightM[G[_], A, B](fa: F[A], z: => B)(f: (A, => B) => G[B])(implicit M: Monad[G]): G[B]

Right-associative, monadic fold of a structure.

Right-associative, monadic fold of a structure.

final
def foldl[A, B](fa: F[A], z: B)(f: B => A => B): B

Curried version of foldLeft

Curried version of foldLeft

def foldl1Opt[A](fa: F[A])(f: A => A => A): Option[A]
final
def foldlM[G[_], A, B](fa: F[A], z: => B)(f: B => A => G[B])(implicit M: Monad[G]): G[B]

Curried version of foldLeftM

Curried version of foldLeftM

final
def foldr[A, B](fa: F[A], z: => B)(f: A => (=> B) => B): B

Curried version of foldRight

Curried version of foldRight

def foldr1Opt[A](fa: F[A])(f: A => (=> A) => A): Option[A]
final
def foldrM[G[_], A, B](fa: F[A], z: => B)(f: A => (=> B) => G[B])(implicit M: Monad[G]): G[B]

Curried version of foldRightM

Curried version of foldRightM

def index[A](fa: F[A], i: Int): Option[A]
Returns

the element at index i in a Some, or None if the given index falls outside of the range

def indexOr[A](fa: F[A], default: => A, i: Int): A
Returns

the element at index i, or default if the given index falls outside of the range

def intercalate[A](fa: F[A], a: A)(implicit A: Monoid[A]): A

Insert an A between every A, yielding the sum.

Insert an A between every A, yielding the sum.

def length[A](fa: F[A]): Int

Deforested alias for toStream(fa).size.

Deforested alias for toStream(fa).size.

def longDigits[A](fa: F[A])(implicit d: A <:< Digit): Long
def maximum[A : Order](fa: F[A]): Option[A]

The greatest element of fa, or None if fa is empty.

The greatest element of fa, or None if fa is empty.

def maximumBy[A, B : Order](fa: F[A])(f: A => B): Option[A]

The element a of fa which yields the greatest value of f(a), or None if fa is empty.

The element a of fa which yields the greatest value of f(a), or None if fa is empty.

def maximumOf[A, B : Order](fa: F[A])(f: A => B): Option[B]

The greatest value of f(a) for each element a of fa, or None if fa is empty.

The greatest value of f(a) for each element a of fa, or None if fa is empty.

def minimum[A : Order](fa: F[A]): Option[A]

The smallest element of fa, or None if fa is empty.

The smallest element of fa, or None if fa is empty.

def minimumBy[A, B : Order](fa: F[A])(f: A => B): Option[A]

The element a of fa which yields the smallest value of f(a), or None if fa is empty.

The element a of fa which yields the smallest value of f(a), or None if fa is empty.

def minimumOf[A, B : Order](fa: F[A])(f: A => B): Option[B]

The smallest value of f(a) for each element a of fa, or None if fa is empty.

The smallest value of f(a) for each element a of fa, or None if fa is empty.

def product[G[_]](implicit G0: Foldable[G]): Foldable[[α] =>> (F[α], G[α])]

The product of Foldables F and G, [x](F[x], G[x]]), is a Foldable

The product of Foldables F and G, [x](F[x], G[x]]), is a Foldable

def product0[G[_]](implicit G0: Foldable1[G]): Foldable1[[α] =>> (F[α], G[α])]

The product of Foldable F and Foldable1 G, [x](F[x], G[x]]), is a Foldable1

The product of Foldable F and Foldable1 G, [x](F[x], G[x]]), is a Foldable1

def psum[G[_], A](fa: F[G[A]])(implicit G: PlusEmpty[G]): G[A]

Sum using a polymorphic monoid (PlusEmpty). Should support early termination, i.e. summing no more elements than is needed to determine the result.

Sum using a polymorphic monoid (PlusEmpty). Should support early termination, i.e. summing no more elements than is needed to determine the result.

def psumMap[A, B, G[_]](fa: F[A])(f: A => G[B])(implicit G: PlusEmpty[G]): G[B]

Map elements to G[B] and sum using a polymorphic monoid (PlusEmpty). Should support early termination, i.e. mapping and summing no more elements than is needed to determine the result.

Map elements to G[B] and sum using a polymorphic monoid (PlusEmpty). Should support early termination, i.e. mapping and summing no more elements than is needed to determine the result.

def selectSplit[A](fa: F[A])(p: A => Boolean): List[NonEmptyList[A]]

Selects groups of elements that satisfy p and discards others.

Selects groups of elements that satisfy p and discards others.

def sequenceF_[M[_], A](ffa: F[Free[M, A]]): Free[M, Unit]

sequence_ for Free. collapses into a single Free *

sequence_ for Free. collapses into a single Free *

def sequenceS_[S, A](fga: F[State[S, A]]): State[S, Unit]

sequence_ specialized to State *

sequence_ specialized to State *

def sequence_[M[_], A](fa: F[M[A]])(implicit a: Applicative[M]): M[Unit]

Strict sequencing in an applicative functor M that ignores the value in fa.

Strict sequencing in an applicative functor M that ignores the value in fa.

def splitBy[A, B : Equal](fa: F[A])(f: A => B): IList[(B, NonEmptyList[A])]

Splits the elements into groups that produce the same result by a function f.

Splits the elements into groups that produce the same result by a function f.

def splitByRelation[A](fa: F[A])(r: (A, A) => Boolean): IList[NonEmptyList[A]]

Splits into groups of elements that are transitively dependant by a relation r.

Splits into groups of elements that are transitively dependant by a relation r.

def splitWith[A](fa: F[A])(p: A => Boolean): List[NonEmptyList[A]]

Splits the elements into groups that alternatively satisfy and don't satisfy the predicate p.

Splits the elements into groups that alternatively satisfy and don't satisfy the predicate p.

def suml[A](fa: F[A])(implicit A: Monoid[A]): A
def suml1Opt[A](fa: F[A])(implicit A: Semigroup[A]): Option[A]
def sumr[A](fa: F[A])(implicit A: Monoid[A]): A
def sumr1Opt[A](fa: F[A])(implicit A: Semigroup[A]): Option[A]
def toEphemeralStream[A](fa: F[A]): EphemeralStream[A]
def toIList[A](fa: F[A]): IList[A]
def toList[A](fa: F[A]): List[A]
def toSet[A](fa: F[A]): Set[A]
def toStream[A](fa: F[A]): Stream[A]
def toVector[A](fa: F[A]): Vector[A]
def traverseS_[S, A, B](fa: F[A])(f: A => State[S, B]): State[S, Unit]

traverse_ specialized to State *

traverse_ specialized to State *

final
def traverseU_[A, GB](fa: F[A])(f: A => GB)(implicit G: Unapply[[F[_]] =>> Applicative[F], GB]): M[Unit]

A version of traverse_ that infers the type constructor M.

A version of traverse_ that infers the type constructor M.

def traverse_[M[_], A, B](fa: F[A])(f: A => M[B])(implicit a: Applicative[M]): M[Unit]

Strict traversal in an applicative functor M that ignores the result of f.

Strict traversal in an applicative functor M that ignores the result of f.

Deprecated methods

@deprecated("use psum", "7.3.0")
def msuml[G[_], A](fa: F[G[A]])(implicit G: PlusEmpty[G]): G[A]
Deprecated
@deprecated("use psum", "7.3.0")
def msumlU[GA](fa: F[GA])(implicit G: Unapply[[F[_]] =>> PlusEmpty[F], GA]): M[A]
Deprecated

Concrete fields