Foldable
trait Foldable[t: Type -> Type]
SourceA trait for data structures that can be folded.
Associated Types
type Aef: Eff
SourceThe associated effect of the Foldable which represents the effect of accessing its elements.
Instances
Signatures
Left-associative fold of a structure.
Applies f
to a start value s
and all elements in t
going from left to right.
Right-associative fold of a structure.
Applies f
to a start value s
and all elements in t
going from right to left.
def foldRightWithCont(f: a -> ((Unit -> b \ ef) -> b \ ef), s: b, t: t[a]): b \ ef + 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.
A foldRightWithCont
allows early termination by not calling the continuation.
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
.
Optionally 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 + 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.
Returns 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 + 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.
Applies f
to each element in t
.
A monadic version of forEach
.
Apply f
to every value in t
. f
is applied for its monadic effect,
the answer it produces is discarded.
Optionally returns the first element of t
.
Returns None
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 + 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.
Optionally returns the last element of t
.
Returns None
if t
is empty.
Optionally finds the largest element of t
according to the Order
on a
.
Returns None
if t
is empty.
Optionally 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.
Optionally finds the smallest element of t
according to the given comparator cmp
.
Returns None
if t
is empty.
Returns true if and only if t
is non-empty.
Optionally applies f
to all elements in t
going from left to right until a single value is obtained.
Returns None
if t
is empty.
Optionally 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
according to the function f
.
Returns the longest prefix of t
that satisfies the predicate f
.
Returns an immutable list.
Returns t
as an array.
Returns t
as a DelayMap
Returns a map with elements of s
as keys and f
applied as values.
Returns t
as a MutDeque
.
Returns t
as a mutable list.
def toMutMap(rc: Region[r], t: t[(k, v)]): MutMap[k, v, r] \ r + Aef[t] with Foldable[t], Order[k]
SourceReturns t
as a MutMap
.
Returns the set s
as a MutSet
.
Optionally returns t
as a non empty chain.
Optionally returns t
as a non empty list.
Module Definitions
Returns the result of applying combine
to all the elements in t
, using empty
as the initial value.