NonEmptySet

value class NonEmptySet<out T> : Set<T>

Constructors

Link copied to clipboard
fun <out T> NonEmptySet(first: T, rest: Set<T>)

Functions

Link copied to clipboard
open operator override fun contains(element: T): Boolean
Link copied to clipboard
open override fun containsAll(elements: Collection<T>): Boolean
Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
Link copied to clipboard
open override fun hashCode(): Int
Link copied to clipboard
open override fun isEmpty(): Boolean
Link copied to clipboard
open operator override fun iterator(): Iterator<T>
Link copied to clipboard
fun <R> map(transform: (@UnsafeVariance T) -> R): NonEmptySet<R>
Link copied to clipboard
operator fun plus(element: @UnsafeVariance T): NonEmptySet<T>
operator fun plus(set: Set<@UnsafeVariance T>): NonEmptySet<T>
Link copied to clipboard
open override fun toString(): String

Properties

Link copied to clipboard
open override val size: Int

Extensions

Link copied to clipboard
inline fun <A, B, C> Iterable<A>.align(b: Iterable<B>, fa: (Ior<A, B>) -> C): List<C>

Combines two structures by taking the union of their shapes and combining the elements with the given function.

fun <A, B> Iterable<A>.align(b: Iterable<B>): List<Ior<A, B>>

Combines two structures by taking the union of their shapes and using Ior to hold the elements.

Link copied to clipboard
fun <A, B> Iterable<Either<A, B>>.combineAll(MA: Monoid<A>, MB: Monoid<B>): Either<A, B>
fun <A> Iterable<A>.combineAll(MA: Monoid<A>): A
fun <K, A> Iterable<Map<K, A>>.combineAll(SG: Semigroup<A>): Map<K, A>
Link copied to clipboard
operator fun <A : Comparable<A>> Iterable<A>.compareTo(other: Iterable<A>): Int
Link copied to clipboard
fun <A, B> Iterable<A>.crosswalk(f: (A) -> Iterable<B>): List<List<B>>
Link copied to clipboard
fun <A, K, V> Iterable<A>.crosswalkMap(f: (A) -> Map<K, V>): Map<K, List<V>>
Link copied to clipboard
fun <A, B> Iterable<A>.crosswalkNull(f: (A) -> B?): List<B>?
Link copied to clipboard

Returns an element as Some(element) at the given index or None if the index is out of bounds of this iterable.

Link copied to clipboard
Link copied to clipboard

Returns the first element as Some(element), or None if the iterable is empty.

inline fun <T> Iterable<T>.firstOrNone(predicate: (T) -> Boolean): Option<T>

Returns the first element as Some(element) matching the given predicate, or None if element was not found.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Flatten a list of Either into a single Either with a list of values, or accumulates all errors using combine.

Flatten a list of Either into a single Either with a list of values, or accumulates all errors with into an NonEmptyList.

Link copied to clipboard
fun <A> Iterable<A>.fold(MA: Monoid<A>): A
Link copied to clipboard
fun <A, B> Iterable<A>.foldMap(MB: Monoid<B>, f: (A) -> B): B
Link copied to clipboard
inline fun <A, B> Iterable<A>.ifThen(fb: Iterable<B>, ffa: (A) -> Iterable<B>): Iterable<B>

Logical conditional. The equivalent of Prolog's soft-cut. If its first argument succeeds at all, then the results will be fed into the success branch. Otherwise, the failure branch is taken.

Link copied to clipboard
fun <A> Iterable<A>.interleave(other: Iterable<A>): List<A>

interleave both computations in a fair way.

Link copied to clipboard

Returns the last element as Some(element), or None if the iterable is empty.

inline fun <T> Iterable<T>.lastOrNone(predicate: (T) -> Boolean): Option<T>

Returns the last element as Some(element) matching the given predicate, or None if no such element was found.

Link copied to clipboard
inline fun <A, B, C> Iterable<A>.leftPadZip(other: Iterable<B>, fab: (A?, B) -> C): List<C>

Returns a List containing the result of applying some transformation (A?, B) -> C on a zip, excluding all cases where the right value is null.

fun <A, B> Iterable<A>.leftPadZip(other: Iterable<B>): List<Pair<A?, B>>

Returns a List> containing the zipped values of the two lists with null for padding on the left.

Link copied to clipboard
fun <A, B> Iterable<A>.padZip(other: Iterable<B>): List<Pair<A?, B?>>

Returns a List> containing the zipped values of the two lists with null for padding.

inline fun <A, B, C> Iterable<A>.padZip(other: Iterable<B>, fa: (A?, B?) -> C): List<C>

Returns a List containing the result of applying some transformation (A?, B?) -> C on a zip.

Link copied to clipboard
fun <A, B> Iterable<A>.reduceOrNull(initial: (A) -> B, operation: (acc: B, A) -> B): B?
Link copied to clipboard
fun <A> Iterable<A>.replicate(n: Int): List<List<A>>
fun <A> Iterable<A>.replicate(n: Int, MA: Monoid<A>): List<A>
Link copied to clipboard
inline fun <A, B, C> Iterable<A>.rightPadZip(other: Iterable<B>, fa: (A, B?) -> C): List<C>

Returns a List containing the result of applying some transformation (A, B?) -> C on a zip, excluding all cases where the left value is null.

fun <A, B> Iterable<A>.rightPadZip(other: Iterable<B>): List<Pair<A, B?>>

Returns a List> containing the zipped values of the two lists with null for padding on the right.

Link copied to clipboard
fun <A> Iterable<A>.salign(SG: Semigroup<A>, other: Iterable<A>): Iterable<A>

aligns two structures and combine them with the given Semigroup.combine

Link copied to clipboard

Separate the inner Either values into the Either.Left and Either.Right.

Link copied to clipboard

Separate the inner Validated values into the Validated.Invalid and Validated.Valid.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Returns single element as Some(element), or None if the iterable is empty or has more than one element.

inline fun <T> Iterable<T>.singleOrNone(predicate: (T) -> Boolean): Option<T>

Returns the single element as Some(element) matching the given predicate, or None if element was not found or more than one element was found.

Link copied to clipboard
fun <A> Iterable<A>.split(): Pair<List<A>, A>?

attempt to split the computation, giving access to the first result.

Link copied to clipboard
fun <A> Iterable<A>.tail(): List<A>
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
inline fun <E, A, B> Iterable<A>.traverse(f: (A) -> Either<E, B>): Either<E, List<B>>
inline fun <A, B> Iterable<A>.traverse(f: (A) -> Result<B>): Result<List<B>>
inline fun <E, A, B> Iterable<A>.traverse(semigroup: Semigroup<E>, f: (A) -> Validated<E, B>): Validated<E, List<B>>
inline fun <E, A, B> Iterable<A>.traverse(f: (A) -> ValidatedNel<E, B>): ValidatedNel<E, List<B>>
inline fun <A, B> Iterable<A>.traverse(f: (A) -> Option<B>): Option<List<B>>
inline fun <A, B> Iterable<A>.traverse(f: (A) -> B?): List<B>?
Link copied to clipboard
inline fun <E, A, B> Iterable<A>.traverseEither(f: (A) -> Either<E, B>): Either<E, List<B>>
Link copied to clipboard
inline fun <A, B> Iterable<A>.traverseNullable(f: (A) -> B?): List<B>?
Link copied to clipboard
inline fun <A, B> Iterable<A>.traverseOption(f: (A) -> Option<B>): Option<List<B>>
Link copied to clipboard
inline fun <A, B> Iterable<A>.traverseResult(f: (A) -> Result<B>): Result<List<B>>
Link copied to clipboard
inline fun <E, A, B> Iterable<A>.traverseValidated(semigroup: Semigroup<E>, f: (A) -> Validated<E, B>): Validated<E, List<B>>
inline fun <E, A, B> Iterable<A>.traverseValidated(f: (A) -> ValidatedNel<E, B>): ValidatedNel<E, List<B>>
Link copied to clipboard
fun <A, B> Iterable<Ior<A, B>>.unalign(): Pair<List<A>, List<B>>

splits a union into its component parts.

inline fun <A, B, C> Iterable<C>.unalign(fa: (C) -> Ior<A, B>): Pair<List<A>, List<B>>

after applying the given function, splits the resulting union shaped structure into its components parts

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
fun <A, B> Iterable<A>.unweave(ffa: (A) -> Iterable<B>): List<B>

Fair conjunction. Similarly to interleave

Link copied to clipboard
fun <A, B> Iterable<Pair<A, B>>.unzip(): Pair<List<A>, List<B>>

unzips the structure holding the resulting elements in an Pair

inline fun <A, B, C> Iterable<C>.unzip(fc: (C) -> Pair<A, B>): Pair<List<A>, List<B>>

after applying the given function unzip the resulting structure into its elements.

Link copied to clipboard
fun <A> Iterable<A>.void(): List<Unit>
Link copied to clipboard
fun <B, A : B> Iterable<A>.widen(): Iterable<B>

Given A is a sub type of B, re-type this value from Iterable to Iterable

Link copied to clipboard
inline fun <B, C, D, E> Iterable<B>.zip(c: Iterable<C>, d: Iterable<D>, transform: (B, C, D) -> E): List<E>
inline fun <B, C, D, E, F> Iterable<B>.zip(c: Iterable<C>, d: Iterable<D>, e: Iterable<E>, transform: (B, C, D, E) -> F): List<F>
inline fun <B, C, D, E, F, G> Iterable<B>.zip(c: Iterable<C>, d: Iterable<D>, e: Iterable<E>, f: Iterable<F>, transform: (B, C, D, E, F) -> G): List<G>
inline fun <B, C, D, E, F, G, H> Iterable<B>.zip(c: Iterable<C>, d: Iterable<D>, e: Iterable<E>, f: Iterable<F>, g: Iterable<G>, transform: (B, C, D, E, F, G) -> H): List<H>
inline fun <B, C, D, E, F, G, H, I> Iterable<B>.zip(c: Iterable<C>, d: Iterable<D>, e: Iterable<E>, f: Iterable<F>, g: Iterable<G>, h: Iterable<H>, transform: (B, C, D, E, F, G, H) -> I): List<I>
inline fun <B, C, D, E, F, G, H, I, J> Iterable<B>.zip(c: Iterable<C>, d: Iterable<D>, e: Iterable<E>, f: Iterable<F>, g: Iterable<G>, h: Iterable<H>, i: Iterable<I>, transform: (B, C, D, E, F, G, H, I) -> J): List<J>
inline fun <B, C, D, E, F, G, H, I, J, K> Iterable<B>.zip(c: Iterable<C>, d: Iterable<D>, e: Iterable<E>, f: Iterable<F>, g: Iterable<G>, h: Iterable<H>, i: Iterable<I>, j: Iterable<J>, transform: (B, C, D, E, F, G, H, I, J) -> K): List<K>
inline fun <B, C, D, E, F, G, H, I, J, K, L> Iterable<B>.zip(c: Iterable<C>, d: Iterable<D>, e: Iterable<E>, f: Iterable<F>, g: Iterable<G>, h: Iterable<H>, i: Iterable<I>, j: Iterable<J>, k: Iterable<K>, transform: (B, C, D, E, F, G, H, I, J, K) -> L): List<L>