flix

0.54.0

Reducible

trait Reducible[t: Type -> Type]Source

A trait for types that can be reduced to a summary value.

Reducible is like a non-empty Foldable and may only be implemented on non-empty data structures.

Instances

instance Reducible[Nec]Source
instance Reducible[Nel]Source

Signatures

def reduceLeftTo(f: b -> (a -> b \ ef1), g: a -> b \ ef2, t: t[a]): b \ ef1 + ef2 with Reducible[t] Source

Left-associative reduction of a structure. Applies g to the initial element of t and combines it with the remainder of t using f going from left to right.

def reduceRightTo(f: a -> (b -> b \ ef1), g: a -> b \ ef2, t: t[a]): b \ ef1 + ef2 with Reducible[t] Source

Right-associative reduction of a structure. Applies g to the initial element of t and combines it with the remainder of t using f going from right to left.

Trait Definitions

def count(f: a -> Bool \ ef, t: t[a]): Int32 \ ef with Reducible[t] Source

Returns the number of elements in t that satisfy the predicate f.

def dropWhile(f: a -> Bool \ ef, t: t[a]): List[a] \ ef with Reducible[t] Source

Returns t as a list without the longest prefix that satisfies the predicate f.

def exists(f: a -> Bool \ ef, t: t[a]): Bool \ ef with Reducible[t] Source

Returns true if and only if at least one element in t satisfies the predicate f.

def find(f: a -> Bool \ ef, t: t[a]): Option[a] \ ef with Reducible[t] Source

Alias for findLeft.

Optionally returns the first element of t that satisfies the predicate f when searching from left to right.

def findLeft(f: a -> Bool \ ef, t: t[a]): Option[a] \ ef with Reducible[t] Source

Optionally returns the first element of t that satisfies the predicate f when searching from left to right.

def findRight(f: a -> Bool \ ef, t: t[a]): Option[a] \ ef with Reducible[t] Source

Optionally returns the first element of t that satisfies the predicate f when searching from right to left.

def fold(t: t[a]): a with Reducible[t], SemiGroup[a] Source

Alias for reduce.

Reduce t using the derived SemiGroup instance.

def foldLeft(f: b -> (a -> b \ ef), s: b, t: t[a]): b \ ef with Reducible[t] Source

Left-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 with Reducible[t] Source

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), z: b, t: t[a]): b \ ef with Reducible[t] Source

Right-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.

def forAll(f: a -> Bool \ ef, t: t[a]): Bool \ ef with Reducible[t] Source

Returns true if and only if all elements in t satisfy the predicate f.

def forEach(f: a -> Unit \ ef, t: t[a]): Unit \ ef with Reducible[t] Source

Applies f to each element in t.

def head(t: t[a]): a with Reducible[t] Source

Returns the first element of t.

def init(t: t[a]): List[a] with Reducible[t] Source

Returns t as a list without the last element.

def intersperse(a: a, t: t[a]): List[a] with Reducible[t] Source

Returns t as a list with a inserted between every two adjacent elements.

def last(t: t[a]): a with Reducible[t] Source

Returns the last element of t.

def length(t: t[a]): Int32 with Reducible[t] Source

Returns the number of elements in t.

def maximum(t: t[a]): a with Reducible[t], Order[a] Source

Finds the largest element of t according to the Order on a.

def maximumBy(cmp: a -> (a -> Comparison), t: t[a]): a with Reducible[t] Source

Finds the largest element of t according to the given comparator cmp.

def memberOf(a: a, t: t[a]): Bool with Reducible[t], Eq[a] Source

Returns true if and only if the element a is in t.

def minimum(t: t[a]): a with Reducible[t], Order[a] Source

Finds the smallest element of t according to the Order on a.

def minimumBy(cmp: a -> (a -> Comparison), t: t[a]): a with Reducible[t] Source

Finds the smallest element of t according to the given comparator cmp.

def reduce(t: t[a]): a with Reducible[t], SemiGroup[a] Source

Reduce t using the derived SemiGroup instance.

def reduceLeft(f: a -> (a -> a \ ef), t: t[a]): a \ ef with Reducible[t] Source

Left-associative reduction on t using f.

def reduceMap(f: a -> b \ ef, t: t[a]): b \ ef with Reducible[t], SemiGroup[b] Source

Applies f to each element of t and combines them using the derived SemiGroup instance.

def reduceRight(f: a -> (a -> a \ ef), t: t[a]): a \ ef with Reducible[t] Source

Right-associative reduction on t using f.

def reverse(t: t[a]): List[a] with Reducible[t] Source

Returns the reverse of t as a list.

def sum(t: t[Int32]): Int32 with Reducible[t] Source

Returns the sum of all elements in t.

def sumWith(f: a -> Int32 \ ef, t: t[a]): Int32 \ ef with Reducible[t] Source

Returns the sum of all elements in t according to the function f.

def tail(t: t[a]): List[a] with Reducible[t] Source

Returns the tail of t as a list.

def takeWhile(f: a -> Bool \ ef, t: t[a]): List[a] \ ef with Reducible[t] Source

Returns the longest prefix of t as a list that satisfies the predicate f.

def toArray(rc: Region[r], t: t[a]): Array[a, r] \ r with Reducible[t] Source

Returns t as an array.

def toList(t: t[a]): List[a] with Reducible[t] Source

Returns t as a list.

def toMap(t: t[(k, v)]): Map[k, v] with Reducible[t], Order[k] Source

Returns t as a map.

def toNel(t: t[a]): Nel[a] with Reducible[t] Source

Returns t as a non-empty list.

def toSet(t: t[a]): Set[a] with Reducible[t], Order[a] Source

Returns t as a set.

def toVector(t: t[a]): Vector[a] with Reducible[t] Source

Returns t as a vector.

Module Definitions

def size(t: t[a]): Int32 with Reducible[t] Source

Returns the number of elements in t.