Foldable

org.specs2.fp.Foldable
See theFoldable companion object
trait Foldable[F[_]]

Inspired from the scalaz (https://github.com/scalaz/scalaz) project

Attributes

Companion
object
Graph
Supertypes
class Object
trait Matchable
class Any

Members list

Value members

Abstract methods

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.

Attributes

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

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

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

Attributes

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.

Attributes

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.

Attributes

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.

Attributes

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.

Attributes

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.

Attributes

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

Alias for length.

Alias for length.

Attributes

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

Deforested alias for toStream(fa).isEmpty.

Deforested alias for toStream(fa).isEmpty.

Attributes

def findLeft[A](fa: F[A])(f: A => Boolean): Option[A]
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.

Attributes

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.

Attributes

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.

Attributes

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.

Attributes

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

Attributes

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

Attributes

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.

Attributes

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

Deforested alias for toStream(fa).size.

Deforested alias for toStream(fa).size.

Attributes

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.

Attributes

def suml[A](fa: F[A])(implicit A: Monoid[A]): A
def sumr[A](fa: F[A])(implicit A: Monoid[A]): 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 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.

Attributes