Package-level declarations

Types

Link copied to clipboard
sealed class Either<out L, out R>

Represents a value of one of two possible types (a disjoint union). Instances of Either are either an instance of Left or Right. FP Convention dictates that Left is used for "failure" and Right is used for "success".

Functions

Link copied to clipboard
fun <T1, T2> <Error class: unknown class><T1>.combine(flow: <Error class: unknown class><T2>): <Error class: unknown class><<Error class: unknown class><T1, T2>>
Link copied to clipboard
fun <T> <Error class: unknown class><T>.distinct(): <Error class: unknown class><T>
Link copied to clipboard
inline fun <T, L, R> Either<L, R>.flatMap(fn: (R) -> Either<L, T>): Either<L, T>

Right-biased flatMap() FP convention which means that Right is assumed to be the default case to operate on. If it is Left, operations like map, flatMap, ... return the Left value unchanged.

Link copied to clipboard
inline suspend fun <A, B> Collection<A>.flatMapFromIterable(crossinline block: suspend (A) -> <Error class: unknown class><B>): <Error class: unknown class><List<B>>
Link copied to clipboard
inline fun <L, R> Either<L, R>.flatMapLeft(fn: (L) -> Either<L, R>): Either<L, R>

Left-biased flatMap() FP convention which means that Left is assumed to be the default case to operate on. If it is Right, operations like map, flatMap, ... return the Right value unchanged.

Link copied to clipboard
fun <L, R, T> <Error class: unknown class><Either<L, R>>.flatMapRight(block: suspend (R) -> <Error class: unknown class><T>): <Error class: unknown class><Either<L, T>>

flatMapLatest the Flow> into Flow>.

Link copied to clipboard
fun <L, R, T> <Error class: unknown class><Either<L, R>>.flatMapRightWithEither(block: suspend (R) -> <Error class: unknown class><Either<L, T>>): <Error class: unknown class><Either<L, T>>

flatMapLatest the Flow> into Flow>.

Link copied to clipboard
fun <T> <Error class: unknown class><List<T>>.flatten(): <Error class: unknown class>
Link copied to clipboard
inline fun <L, R, T : Any> Either<L, R>.fold(fnL: (L) -> T, fnR: (R) -> T): T

Applies fnL if this is a Left or fnR if this is a Right.

Link copied to clipboard
inline fun <T, L, R> Iterable<T>.foldToEitherWhileRight(initialValue: R, fn: (item: T, accumulated: R) -> Either<L, R>): Either<L, R>

Folds a list into an Either while it doesn't go Left. Allows for accumulation of value through iterations.

Link copied to clipboard
inline fun <L, R> Either<L, R>.getOrElse(value: R): R

Returns the value from this Right or the given argument if this is a Left. Right(12).getOrElse(17) RETURNS 12 and Left(12).getOrElse(17) RETURNS 17

inline fun <L, R> Either<L, R>.getOrElse(fn: (L) -> R): R

Returns the value from this Right or the result of fn if this is a Left. Right(12).getOrElse{ it + 3 } RETURNS 12 and Left(12).getOrElse{ it + 3 } RETURNS 15

Link copied to clipboard
inline fun <L, R> Either<L, R>.getOrFail(fn: (failure: L) -> R): R

Right-biased getOrFail() FP convention which means that Right is assumed to be the default case to operate on and return the result. If it is Left, operations like map, flatMap, ... return the Left value unchanged.

Link copied to clipboard
inline fun <L, R> Either<L, R>.getOrNull(): R?

Returns the value from this Right or null if this is a Left. Right(12).getOrNull() RETURNS 12 and Left(12).getOrNull() RETURNS null

Link copied to clipboard
fun intervalFlow(periodMs: Long, initialDelayMs: Long = 0, stopWhen: () -> Boolean = { false }): <Error class: unknown class>
Link copied to clipboard
fun <L, R> Either<L, R>.isLeft(): Boolean

Returns true if this is a Left, false otherwise.

Link copied to clipboard
fun <L, R> Either<L, R>.isRight(): Boolean

Returns true if this is a Right, false otherwise.

Link copied to clipboard
inline fun <T> T.left(): Either.Left<T>
Link copied to clipboard
inline fun <T, L, R> Either<L, R>.map(fn: (R) -> T): Either<L, T>

Right-biased map() FP convention which means that Right is assumed to be the default case to operate on. If it is Left, operations like map, flatMap, ... return the Left value unchanged.

Link copied to clipboard
fun <L, R, T> <Error class: unknown class><Either<L, R>>.mapLeft(block: suspend (L) -> T): <Error class: unknown class><Either<T, R>>

inline fun <T, L, R> Either<L, R>.mapLeft(fn: (L) -> T): Either<T, R>

Left-biased map() FP convention which means that Right is assumed to be the default case to operate on. If it is Right, operations like map, flatMap, ... return the Right value unchanged.

Link copied to clipboard
fun <L, R, T> <Error class: unknown class><Either<L, R>>.mapRight(block: suspend (R) -> T): <Error class: unknown class><Either<L, T>>
Link copied to clipboard
fun <L, R> <Error class: unknown class><Either<L, R>>.mapToRightOr(value: R): <Error class: unknown class><R>

map Flow> to the Flow.

Link copied to clipboard
inline fun <L, R, T> Either<L, R>.nullableFold(fnL: (L) -> T?, fnR: (R) -> T?): T?

Applies fnL if this is a Left or fnR if this is a Right.

Link copied to clipboard
inline fun <L, R> Either<L, R>.onFailure(fn: (failure: L) -> Unit): Either<L, R>

Left-biased onFailure() FP convention dictates that when this class is Left, it'll perform the onFailure functionality passed as a parameter, but, overall will still return an Either object, so you chain calls.

Link copied to clipboard
fun <L, R> <Error class: unknown class><Either<L, R>>.onlyRight(): <Error class: unknown class><R>
Link copied to clipboard
inline fun <L, R> Either<L, R>.onSuccess(fn: (success: R) -> Unit): Either<L, R>

Right-biased onSuccess() FP convention dictates that when this class is Right, it'll perform the onSuccess functionality passed as a parameter, but, overall will still return an Either object, so you chain calls.

Link copied to clipboard
inline fun <T> T.right(): Either.Right<T>