Left

data class Left<out A>(val value: A) : Either<A, Nothing>

The left side of the disjoint union, as opposed to the Right side.

Constructors

Link copied to clipboard
fun <out A> Left(value: A)

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
inline fun all(predicate: (Nothing) -> Boolean): Boolean

Returns true if Left or returns the result of the application of the given predicate to the Right value.

Link copied to clipboard
inline fun <C> bifoldLeft(c: C, f: (C, A) -> C, g: (C, Nothing) -> C): C
Link copied to clipboard
inline fun <C> bifoldMap(MN: Monoid<C>, f: (A) -> C, g: (Nothing) -> C): C
Link copied to clipboard
inline fun <C, D> bimap(leftOperation: (left: A) -> C, rightOperation: (right: Nothing) -> D): Either<C, D>

Map over Left and Right of this Either

Link copied to clipboard
inline fun <AA, C> bitraverse(fe: (A) -> Iterable<AA>, fa: (Nothing) -> Iterable<C>): List<Either<AA, C>>
Link copied to clipboard
inline fun <AA, C> bitraverseNullable(fl: (A) -> AA?, fr: (Nothing) -> C?): Either<AA, C>?
Link copied to clipboard
inline fun <AA, C> bitraverseOption(fl: (A) -> Option<AA>, fr: (Nothing) -> Option<C>): Option<Either<AA, C>>
Link copied to clipboard
inline fun <AA, C, D> bitraverseValidated(fe: (A) -> Validated<AA, C>, fa: (Nothing) -> Validated<AA, D>): Validated<AA, Either<C, D>>
Link copied to clipboard
inline fun exists(predicate: (Nothing) -> Boolean): Boolean

Returns false if Left or returns the result of the application of the given predicate to the Right value.

Link copied to clipboard
inline fun findOrNull(predicate: (Nothing) -> Boolean): Nothing?
Link copied to clipboard
inline fun <C> fold(ifLeft: (left: A) -> C, ifRight: (right: Nothing) -> C): C

Transform an Either into a value of C. Alternative to using when to fold an Either into a value C.

Link copied to clipboard
inline fun <C> foldLeft(initial: C, rightOperation: (C, Nothing) -> C): C
Link copied to clipboard
fun <C> foldMap(MN: Monoid<C>, f: (Nothing) -> C): C
Link copied to clipboard

Transforms Either into Option, where the encapsulated value B is wrapped in Some when this instance represents Either.Right, or None if it is Either.Left.

Link copied to clipboard

Returns the encapsulated value B if this instance represents Either.Right or null if it is Either.Left.

Link copied to clipboard

Returns true if Left

Link copied to clipboard
Link copied to clipboard

Returns true if Right

Link copied to clipboard
Link copied to clipboard
inline fun <C> map(f: (right: Nothing) -> C): Either<A, C>

Map, or transform, the right value B of this Either to a new value C.

Link copied to clipboard
inline fun <C> mapLeft(f: (A) -> C): Either<C, Nothing>

Map, or transform, the left value A of this Either to a new value C.

Link copied to clipboard
inline fun onLeft(action: (left: A) -> Unit): Either<A, Nothing>

Performs the given action on the encapsulated A if this instance represents Either.Left. Returns the original Either unchanged.

Link copied to clipboard
inline fun onRight(action: (right: Nothing) -> Unit): Either<A, Nothing>

Performs the given action on the encapsulated B value if this instance represents Either.Right. Returns the original Either unchanged.

Link copied to clipboard
Link copied to clipboard
fun orNull(): Nothing?
Link copied to clipboard
Link copied to clipboard
fun swap(): Either<Nothing, A>

Swap the generic parameters A and B of this Either.

Link copied to clipboard
inline fun tap(f: (right: Nothing) -> Unit): Either<A, Nothing>
Link copied to clipboard
inline fun tapLeft(f: (left: A) -> Unit): Either<A, Nothing>
Link copied to clipboard
open override fun toString(): String
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
inline fun <C> traverse(fa: (Nothing) -> Option<C>): Option<Either<A, C>>
inline fun <AA, C> traverse(fa: (Nothing) -> Validated<AA, C>): Validated<AA, Either<A, C>>
inline fun <C> traverse(fa: (Nothing) -> Iterable<C>): List<Either<A, C>>
Link copied to clipboard
inline fun <C> traverseNullable(fa: (Nothing) -> C?): Either<A, C>?
Link copied to clipboard
inline fun <C> traverseOption(fa: (Nothing) -> Option<C>): Option<Either<A, C>>
Link copied to clipboard
inline fun <AA, C> traverseValidated(fa: (Nothing) -> Validated<AA, C>): Validated<AA, Either<A, C>>
Link copied to clipboard
fun void(): Either<A, Unit>

Properties

Link copied to clipboard
val value: A

Extensions

Link copied to clipboard
fun <A> Either<Throwable, A>.bind(): A
Link copied to clipboard
Link copied to clipboard
fun <A, B> Either<A?, B?>.bisequenceNullable(): Either<A, B>?
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
inline fun <E, A> Either<Throwable, A>.catch(catch: Raise<E>.(Throwable) -> A): Either<E, A>

Catch allows for transforming Throwable in the Either.Left side. This API is the same as recover, but offers the same APIs for working over Throwable as Effect&EagerEffect.

@JvmName(name = "catchReified")
inline fun <E, T : Throwable, A> Either<Throwable, A>.catch(catch: Raise<E>.(T) -> A): Either<E, A>
Link copied to clipboard
fun <A, B> Either<A, B>.combine(SGA: Semigroup<A>, SGB: Semigroup<B>, b: Either<A, B>): Either<A, B>
Link copied to clipboard
fun <A, B> Either<A, B>.combineK(y: Either<A, B>): Either<A, B>
Link copied to clipboard
operator fun <A : Comparable<A>, B : Comparable<B>> Either<A, B>.compareTo(other: Either<A, B>): Int
Link copied to clipboard
fun <A, B> Either<A, B>.contains(elem: B): Boolean

Returns true if this is a Right and its value is equal to elem (as determined by ==), returns false otherwise.

Link copied to clipboard
inline fun <A, B> Either<A, B>.ensure(error: () -> A, predicate: (B) -> Boolean): Either<A, B>
Link copied to clipboard
inline fun <A, B> Either<A, B>.filterOrElse(predicate: (B) -> Boolean, default: () -> A): Either<A, B>

Returns Right with the existing value of Right if this is a Right and the given predicate holds for the right value.

Link copied to clipboard
inline fun <A, B> Either<A, B>.filterOrOther(predicate: (B) -> Boolean, default: (B) -> A): Either<A, B>

Returns Right with the existing value of Right if this is a Right and the given predicate holds for the right value.

Link copied to clipboard
inline fun <A, B, C> Either<A, B>.flatMap(f: (right: B) -> Either<A, C>): Either<A, C>

Map, or transform, the right value B of this Either into a new Either with a right value of type C. Returns a new Either with either the original left value of type A or the newly transformed right value of type C.

Link copied to clipboard
fun <A, B> Either<A, Either<A, B>>.flatten(): Either<A, B>
Link copied to clipboard
inline fun <A, B> Either<A, B>.getOrElse(default: (A) -> B): B

Get the right value B of this Either, or compute a default value with the left value A.

Link copied to clipboard
inline fun <A, B> Either<A, B>.getOrHandle(default: (A) -> B): B

Returns the value from this Right or allows clients to transform the value from Left with the default lambda.

Link copied to clipboard
inline fun <A, B> Either<A, B>.handleError(f: (A) -> B): Either<A, B>
Link copied to clipboard
inline fun <A, B, C> Either<A, B>.handleErrorWith(f: (A) -> Either<C, B>): Either<C, B>
Link copied to clipboard
inline fun <A, B> Either<A, B?>.leftIfNull(default: () -> A): Either<A, B>

Returns Right with the existing value of Right if this is an Right with a non-null value. The returned Either.Right type is not nullable.

Link copied to clipboard
fun <AA, A : AA, B> Either<A, B>.leftWiden(): Either<AA, B>
Link copied to clipboard
inline fun <A> Either<A, A>.merge(): A

Returns the value from this Right or Left.

Link copied to clipboard
fun <B> Either<*, B>.orNull(): B?

Returns the value from this Right or null if this is a Left.

Link copied to clipboard
inline fun <E, EE, A> Either<E, A>.recover(recover: Raise<EE>.(E) -> A): Either<EE, A>

Recover from any Either.Left if encountered.

Link copied to clipboard
inline fun <A, B, C> Either<A, B>.redeem(fe: (A) -> C, fa: (B) -> C): Either<A, C>
Link copied to clipboard
inline fun <A, B, C, D> Either<A, B>.redeemWith(fa: (A) -> Either<C, D>, fb: (B) -> Either<C, D>): Either<C, D>
Link copied to clipboard
fun <A, B> Either<A, B>.replicate(n: Int, MB: Monoid<B>): Either<A, B>
Link copied to clipboard
fun <A, B> Either<A, Iterable<B>>.sequence(): List<Either<A, B>>
fun <A, B> Either<A, Option<B>>.sequence(): Option<Either<A, B>>
fun <A, B> Either<A, B?>.sequence(): Either<A, B>?
fun <A, B, C> Either<A, Validated<B, C>>.sequence(): Validated<B, Either<A, C>>
Link copied to clipboard
fun <A, B> Either<A, B?>.sequenceNullable(): Either<A, B>?
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
fun <E, A> Either<E, A>.toEitherNel(): EitherNel<E, A>
Link copied to clipboard
fun <A, C, B : C> Either<A, B>.widen(): Either<A, C>

Given B is a sub type of C, re-type this value from Either to Either

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