flix

0.55.0

Nel

enum Nel[a: Type] with SendableSource
case Nel(a, List[a])

The NonEmptyList type.

Instances

instance Applicative[Nel]Source
instance Eq[Nel[a]] with Eq[a]Source
instance Foldable[Nel]Source
instance Functor[Nel]Source
instance Hash[Nel[a]] with Hash[a]Source
instance Iterable[Nel[a]]Source
instance Monad[Nel]Source
instance MonadZip[Nel]Source
instance Order[Nel[a]] with Order[a]Source
instance Reducible[Nel]Source
instance SemiGroup[Nel[a]]Source
instance Sendable[Nel[a]] with Sendable[a]Source
instance ToJava[Nel[a]]Source
instance ToString[Nel[a]] with ToString[a]Source
instance Traversable[Nel]Source

Definitions

def ap(f: Nel[a -> b \ ef], l: Nel[a]): Nel[b] \ ef Source

Apply every function from f to every argument from l and return a non-empty list with all results. For f = f1, f2, ... and x = x1, x2, ... the results appear in the order f1(x1), f1(x2), ..., f2(x1), f2(x2), ....

def append(l1: Nel[a], l2: Nel[a]): Nel[a] Source

Returns l2 appended to l1.

def cons(x: a, l: Nel[a]): Nel[a] Source

Returns the non-empty list l prefixed with the new element x.

def count(f: a -> Bool \ ef, l: Nel[a]): Int32 \ ef Source

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

def dropWhile(f: a -> Bool \ ef, l: Nel[a]): List[a] \ ef Source

Returns l without the longest prefix that satisfies the predicate f.

def enumerator(rc: Region[r], l: Nel[a]): Iterator[(Int32, a), r, r] \ r Source

Returns an iterator over l zipped with the indices of the elements.

def exists(f: a -> Bool \ ef, l: Nel[a]): Bool \ ef Source

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

def filter(f: a -> Bool, l: Nel[a]): List[a] Source

Returns a list of every element in l that satisfies the predicate f.

def find(f: a -> Bool \ ef, l: Nel[a]): Option[a] \ ef Source

Alias for findLeft.

def findLeft(f: a -> Bool \ ef, l: Nel[a]): Option[a] \ ef Source

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

def findRight(f: a -> Bool \ ef, l: Nel[a]): Option[a] \ ef Source

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

def flatMap(f: a -> Nel[b] \ ef, l: Nel[a]): Nel[b] \ ef Source

Returns the result of applying f to every element in l and concatenating the results.

def flatten(l: Nel[Nel[a]]): Nel[a] Source

Returns the concatenation of the elements in l.

def fold(l: Nel[a]): a with Monoid[a] Source

Returns the result of applying combine to all the elements in l, using empty as the initial value.

def foldLeft(f: b -> (a -> b \ ef), s: b, l: Nel[a]): b \ ef Source

Applies f to a start value s and all elements in l going from left to right.

That is, the result is of the form: f(...f(f(s, x1), x2)..., xn).

def foldMap(f: a -> b \ ef, l: Nel[a]): b \ ef with Monoid[b] Source

Returns the result of mapping each element and combining the results.

def foldRight(f: a -> (b -> b \ ef), s: b, l: Nel[a]): b \ ef Source

Applies f to a start value s and all elements in l going from right to left.

That is, the result is of the form: f(x1, ...f(xn-1, f(xn, s))...).

def foldRightWithCont(f: a -> ((Unit -> b \ ef) -> b \ ef), z: b, l: Nel[a]): b \ ef Source

Applies f to a start value z and all elements in l going from right to left.

That is, the result is of the form: f(x1, ...f(xn-1, f(xn, z))...). A foldRightWithCont allows early termination by not calling the continuation.

def forAll(f: a -> Bool \ ef, l: Nel[a]): Bool \ ef Source

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

def forEach(f: a -> Unit \ ef, l: Nel[a]): Unit \ ef Source

Applies f to every element of l.

def forEachWithIndex(f: Int32 -> (a -> Unit \ ef), l: Nel[a]): Unit \ ef Source

Applies f to every element of l along with that element's index.

def head(l: Nel[a]): a Source

Returns the first element of l.

def init(l: Nel[a]): List[a] Source

Returns all elements in l without the last element.

def intersperse(a: a, l: Nel[a]): Nel[a] Source

Returns l with a inserted between every two adjacent elements.

def iterator(rc: Region[r], l: Nel[a]): Iterator[a, r, r] \ r Source

Returns an iterator over l.

def join(sep: String, l: Nel[a]): String with ToString[a] Source

Returns the concatenation of the string representation of each element in l with sep inserted between each element.

def joinWith(f: a -> String \ ef, sep: String, l: Nel[a]): String \ ef Source

Returns the concatenation of the string representation of each element in l according to f with sep inserted between each element.

def last(l: Nel[a]): a Source

Returns the last element of l.

def length(l: Nel[a]): Int32 Source

Returns the number of elements in l.

def map(f: a -> b \ ef, l: Nel[a]): Nel[b] \ ef Source

Returns the result of applying f to every element in l.

That is, the result is of the form: f(x1) :: f(x2) :: ....

def mapWithIndex(f: Int32 -> (a -> b \ ef), l: Nel[a]): Nel[b] \ ef Source

Returns the result of applying f to every element in l along with that element's index.

That is, the result is of the form: f(x1, 0) :: f(x2, 1) :: ....

def maximum(l: Nel[a]): a with Order[a] Source

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

def maximumBy(cmp: a -> (a -> Comparison), l: Nel[a]): a Source

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

def memberOf(a: a, l: Nel[a]): Bool with Eq[a] Source

Returns true if and only if l contains the element a.

def minimum(l: Nel[a]): a with Order[a] Source

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

def minimumBy(cmp: a -> (a -> Comparison), l: Nel[a]): a Source

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

def permutations(l: Nel[a]): Nel[List[a]] Source

Returns all permutations of l in lexicographical order by element indices in l.

That is, l is the first permutation and reverse(l) is the last permutation.

def reduce(l: Nel[a]): a with SemiGroup[a] Source

Applies combine to all elements in l until a single value is obtained.

def reduceLeft(f: a -> (a -> a \ ef), l: Nel[a]): a \ ef Source

Applies f to all elements in l going from left to right until a single value v is obtained.

That is, the result is of the form: f(...f(f(x1, x2), x3)..., xn)

def reduceLeftTo(f: b -> (a -> b \ ef1), g: a -> b \ ef2, l: Nel[a]): b \ ef1 + ef2 Source

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

def reduceRight(f: a -> (a -> a \ ef), l: Nel[a]): a \ ef Source

Applies f to all elements in l going from right to left until a single value v is obtained.

That is, the result is of the form: Some(f(x1, ...f(xn-2, f(xn-1, xn))...))

def reduceRightTo(f: a -> (b -> b \ ef1), g: a -> b \ ef2, l: Nel[a]): b \ ef1 + ef2 Source

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

def replace(src: { src = a }, dst: { dst = a }, l: Nel[a]): Nel[a] with Eq[a] Source

Returns l with every occurrence of src replaced by dst.

def reverse(l: Nel[a]): Nel[a] Source

Returns the reverse of l.

def sequence(l: Nel[m[a]]): m[Nel[a]] with Applicative[m] Source

Returns the result of applying the applicative mapping function f to all the elements of the non-empty list l.

def shuffle(l: Nel[a]): Option[Nel[a]] \ NonDet Source

Optionally returns the Nel l shuffled using the Fisher–Yates shuffle.

def singleton(x: a): Nel[a] Source

Returns a new non-empty list containing the single element x.

def size(l: Nel[a]): Int32 Source

Returns the number of elements in l.

def sort(l: Nel[a]): Nel[a] with Order[a] Source

Sort the non-empty list l so that elements are ordered from low to high according to their Order instance.

The sort is not stable, i.e., equal elements may appear in a different order than in the input l.

The sort implementation is a Quicksort.

def sortBy(f: a -> b, l: Nel[a]): Nel[a] with Order[b] Source

Sort the non-empty list l so that elements are ordered from low to high according to the Order instance for the values obtained by applying f to each element.

The sort is not stable, i.e., equal elements may appear in a different order than in the input l.

The sort implementation is a Quicksort.

def sortWith(cmp: a -> (a -> Comparison), l: Nel[a]): Nel[a] Source

Sort the non-empty list l so that elements are ordered from low to high according to the comparison function cmp.

The sort is not stable, i.e., equal elements may appear in a different order than in the input l.

The sort implementation is a Quicksort.

def subsequences(l: Nel[a]): Nel[List[a]] Source

Returns all subsequences of l in lexicographical order by element indices in l.

That is, l is the first subsequence and Nil is the last subsequence.

def sum(l: Nel[Int32]): Int32 Source

Returns the sum of all elements in the list l.

def sumWith(f: a -> Int32 \ ef, l: Nel[a]): Int32 \ ef Source

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

def tail(l: Nel[a]): List[a] Source

Returns all elements in l without the first element.

def takeWhile(f: a -> Bool \ ef, l: Nel[a]): List[a] \ ef Source

Returns the longest prefix of l that satisfies the predicate f.

def toArray(rc: Region[r], l: Nel[a]): Array[a, r] \ r Source

Returns l as an array.

def toList(l: Nel[a]): List[a] Source

Returns l as a normal list.

def toMapWith(f: a -> b, l: Nel[a]): Map[a, b] with Order[a] Source

Returns a map with elements of l as keys and f applied as values.

If l contains multiple mappings with the same key, toMapWith does not make any guarantees about which mapping will be in the resulting map.

def toMutDeque(rc: Region[r], l: Nel[a]): MutDeque[a, r] \ r Source

Returns l as a MutDeque.

def toString(l: Nel[a]): String with ToString[a] Source

Returns a string representation of the given non-empty list l.

def toVector(l: Nel[a]): Vector[a] Source

Returns l as a vector.

def traverse(f: a -> m[b] \ ef, l: Nel[a]): m[Nel[b]] \ ef with Applicative[m] Source

Returns the result of running all the actions in the non-empty list l.

def unzip(l: Nel[(a, b)]): (Nel[a], Nel[b]) Source

Returns a pair of non-empty lists, the first containing all first components in l and the second containing all second components in l.

def zip(l1: Nel[a], l2: Nel[b]): Nel[(a, b)] Source

Returns a non-empty list where the element at index i is (a, b) where a is the element at index i in l1 and b is the element at index i in l2.

If either l1 or l2 becomes depleted, then no further elements are added to the resulting list.

def zipWith(f: a -> (b -> c \ ef), l1: Nel[a], l2: Nel[b]): Nel[c] \ ef Source

Returns a non-empty list where the element at index i is f(a, b) where a is the element at index i in l1 and b is the element at index i in l2.

If either l1 or l2 becomes depleted, then no further elements are added to the resulting list.

def zipWithA(f: a -> (b -> m[c] \ ef), xs: Nel[a], ys: Nel[b]): m[Nel[c]] \ ef with Applicative[m] Source

Generalize zipWith to an applicative functor f.

def zipWithIndex(l: Nel[a]): Nel[(Int32, a)] Source

Returns a new non-empty list where each element e is mapped to (i, e) where i is the index of e.