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 <A, B, C> (A) -> B.c(f: (B) -> C): (A) -> C

Composes 2 functions See Credits to Alex Hart.

Link copied to clipboard
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
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

Link copied to clipboard
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.