Foldable
Trait for types that can be folded, and its functions.
trait Foldable[t: Type -> Type]SourceTrait for types that can be folded.
Associated Types
type Aef: Eff = {}SourceThe associated effect of the Foldable which represents the effect of accessing its elements.
Sub-traits
Instances
Signatures
def foldLeft(f: b -> (a -> b \ ef), s: b, t: t[a]): b \ { ef, Foldable.Aef[t] } with Foldable[t]§ SourceLeft-associative fold of a structure.
Applies f to a start value s and all elements in t going from left to right.
def foldRight(f: a -> (b -> b \ ef), s: b, t: t[a]): b \ { ef, Foldable.Aef[t] } with Foldable[t]§ SourceRight-associative fold of a structure.
Applies f to a start value s and all elements in t going from right to left.
Trait Definitions
Returns the number of elements in t that satisfy the predicate f.
Returns t without the longest prefix that satisfies the predicate f.
Returns an immutable list.
Returns true if and only if at least one element in t satisfies the predicate f.
Returns false if t is empty.
Returns an immutable list of all the elements in t that satisfy the predicate f.
def findLeft(f: a -> Bool \ ef, t: t[a]): Option[a] \ { ef, Foldable.Aef[t] } with Foldable[t]§ SourceOptionally returns the first element of t that satisfies the predicate f when searching from left to right.
Returns None if t is empty.
Optionally returns the first element of t that satisfies the predicate f when searching from right to left.
Returns None if t is empty.
def foldLeftM(f: b -> (a -> m[b] \ ef), s: b, t: t[a]): m[b] \ { ef, Foldable.Aef[t] } with Foldable[t], Monad[m]§ SourceA monadic version of foldLeft.
Applies the monadic f to a start value s and all elements in t going
from left to right.
def foldMap(f: a -> b \ ef, t: t[a]): b \ { ef, Foldable.Aef[t] } with Foldable[t], Monoid[b]§ SourceReturns the result of mapping each element and combining the results.
def foldRightM(f: a -> (b -> m[b] \ ef), s: b, t: t[a]): m[b] \ { ef, Foldable.Aef[t] } with Foldable[t], Monad[m]§ SourceA monadic version of foldRight.
Applies the monadic f to a start value s and all elements in t going
from right to left.
Returns true if and only if all elements in t satisfy the predicate f.
Returns true if t is empty.
def forEach(f: a -> Unit \ ef, t: t[a]): Unit \ { ef, Foldable.Aef[t] } with Foldable[t]§ SourceApplies f to each element in t.
def forEachM(f: a -> m[b] \ ef, t: t[a]): m[Unit] \ { ef, Foldable.Aef[t] } with Foldable[t], Monad[m]§ SourceA monadic version of forEach.
Apply f to every value in t. f is applied for its monadic effect,
the answer it produces is discarded.
def head(t: t[a]): Option[a] \ Foldable.Aef[t] with Foldable[t]§ SourceOptionally returns the first element of t.
Returns None if t is empty.
def isEmpty(t: t[a]): Bool \ Foldable.Aef[t] with Foldable[t]§ SourceReturns true if and only if t is empty.
Returns the concatenation of the string representation
of each element in t with sep inserted between each element.
def joinWith(f: a -> String \ ef, sep: String, t: t[a]): String \ { ef, Foldable.Aef[t] } with Foldable[t]§ SourceReturns the concatenation of the string representation
of each element in t according to f with sep inserted between each element.
def last(t: t[a]): Option[a] \ Foldable.Aef[t] with Foldable[t]§ SourceOptionally returns the last element of t.
Returns None if t is empty.
def length(t: t[a]): Int32 \ Foldable.Aef[t] with Foldable[t]§ SourceReturns the number of elements in t.
Optionally finds the largest element of t according to the Order on a.
Returns None if t is empty.
def maximumBy(cmp: a -> (a -> Comparison), t: t[a]): Option[a] \ Foldable.Aef[t] with Foldable[t]§ SourceOptionally finds the largest element of t according to the given comparator cmp.
Returns None if t is empty.
Returns true if and only if the element x is in t.
Optionally finds the smallest element of t according to the Order on a.
Returns None if t is empty.
def minimumBy(cmp: a -> (a -> Comparison), t: t[a]): Option[a] \ Foldable.Aef[t] with Foldable[t]§ SourceOptionally finds the smallest element of t according to the given comparator cmp.
Returns None if t is empty.
def nonEmpty(t: t[a]): Bool \ Foldable.Aef[t] with Foldable[t]§ SourceReturns true if and only if t is non-empty.
def reduceLeft(f: a -> (a -> a \ ef), t: t[a]): Option[a] \ { ef, Foldable.Aef[t] } with Foldable[t]§ SourceOptionally applies f to all elements in t going from left to right until a single value is obtained.
Returns None if t is empty.
def reduceRight(f: a -> (a -> a \ ef), t: t[a]): Option[a] \ { ef, Foldable.Aef[t] } with Foldable[t]§ SourceOptionally applies f to all elements in t going from right to left until a single value is obtained.
Returns None if t is empty.
Returns the sum of all elements in t.
Returns the sum of all elements in t according to the function f.
Returns the longest prefix of t that satisfies the predicate f.
Returns an immutable list.
def toArray(rc: Region[r], t: t[a]): Array[a, r] \ { Foldable.Aef[t], Write[r] } with Foldable[t]§ SourceReturns t as an array.
def toChain(t: t[a]): Chain[a] \ Foldable.Aef[t] with Foldable[t]§ SourceReturns t as a chain.
def toList(t: t[a]): List[a] \ Foldable.Aef[t] with Foldable[t]§ SourceReturns t as an immutable list.
Returns t as a map.
Returns a map with elements of s as keys and f applied as values.
Optionally returns t as a non empty chain.
Optionally returns t as a non empty list.
def toVector(t: t[a]): Vector[a] \ Foldable.Aef[t] with Foldable[t]§ SourceReturns t as a vector.
Module Definitions
def fold(t: t[a]): a \ Foldable.Aef[t] with Foldable[t], Monoid[a]§ SourceReturns the result of applying combine to all the elements in t, using empty as the initial value.
def size(t: t[a]): Int32 \ Foldable.Aef[t] with Foldable[t]§ SourceReturns the number of elements in t.