Companion

object Companion

Functions

Link copied to clipboard
@JvmName(name = "tryCatch")
inline fun <R> catch(f: () -> R): Either<Throwable, R>
@JvmName(name = "tryCatch")
inline fun <L, R> catch(fe: (Throwable) -> L, f: () -> R): Either<L, R>
Link copied to clipboard
@JvmName(name = "tryCatchAndFlatten")
inline fun <R> catchAndFlatten(f: () -> Either<Throwable, R>): Either<Throwable, R>
Link copied to clipboard
inline fun <L, R> conditionally(    test: Boolean,     ifFalse: () -> L,     ifTrue: () -> R): Either<L, R>

Will create an Either from the result of evaluating the first parameter using the functions provided on second and third parameters. Second parameter represents function for creating an Left in case of a false result of evaluation and third parameter will be used to create a Right in case of a true result.

Link copied to clipboard
fun <A> fromNullable(a: A?): Either<Unit, A>
Link copied to clipboard
fun <A, B, C> lift(f: (B) -> C): (Either<A, B>) -> Either<A, C>

Lifts a function (B) -> C to the Either structure returning a polymorphic function that can be applied over all Either values in the shape of Either

fun <A, B, C, D> lift(fa: (A) -> C, fb: (B) -> D): (Either<A, B>) -> Either<C, D>
Link copied to clipboard
inline fun <E, A, B> resolve(    f: () -> Either<E, A>,     success: (A) -> Either<Throwable, B>,     error: (E) -> Either<Throwable, B>,     throwable: (throwable: Throwable) -> Either<Throwable, B>,     unrecoverableState: (throwable: Throwable) -> Either<Throwable, Unit>): B

The resolve function can resolve any suspended function that yields an Either into one type of value.