Package-level declarations

Functions

Link copied to clipboard
inline fun <T> Iterable<KotlinResult<T>>.aggregate(reduce: (List<Throwable>) -> Throwable = { it.first() }): KotlinResult<List<T>>
Link copied to clipboard
inline fun <T> KotlinResult<T>.andIf(predicate: (T) -> Boolean, onSuccess: (T) -> T): KotlinResult<T>

If the predicate is true, transforms value inside a resultOf scope.

Link copied to clipboard
inline fun <In, Out> KotlinResult<In>.andThen(onSuccess: (In) -> Out): KotlinResult<Out>

Transforms value inside a resultOf scope.

Link copied to clipboard
inline fun <In, Out> Iterable<KotlinResult<In>>.andThenEach(success: (In) -> Out): List<KotlinResult<Out>>

Serial KotlinResult.andThen of multiple KotlinResults. Each result is processed in a separate coroutine, and the results are collected as a List of KotlinResult.

Serial KotlinResult.andThen of multiple KotlinResults. Each result is processed in a separate coroutine, and the results are collected as a Sequence of KotlinResult.

Link copied to clipboard

Try to get the exception of this Result.

Link copied to clipboard
inline fun <T> KotlinResult<T>.exceptionOrElse(onSuccess: (T) -> Throwable): Throwable

Try to get the exception of this Result.

Link copied to clipboard

Try to get the exception of this Result.

Link copied to clipboard
inline fun <In, Out> KotlinResult<In>.flatMap(onSuccess: (In) -> KotlinResult<Out>): KotlinResult<Out>

Like Result.map, applies the onSuccess function to the encapsulated value.

Link copied to clipboard
Link copied to clipboard
inline fun <In, Out> Iterable<KotlinResult<In>>.foldEach(success: (In) -> Out, failure: (Throwable) -> Out): List<Out>

Serial KotlinResult.fold of multiple KotlinResults. Each result is processed in a separate coroutine, and the results are collected as a List of Out.

fun <In, Out> Sequence<KotlinResult<In>>.foldEach(success: (In) -> Out, failure: (Throwable) -> Out): Sequence<Out>

Serial KotlinResult.fold of multiple KotlinResults. Each result is processed in a separate coroutine, and the results are collected as a Sequence of Out.

Link copied to clipboard
inline fun <T> KotlinResult<T>.mapFailure(onFailure: (Throwable) -> Throwable): KotlinResult<T>

Transform exception into some other Throwable.

Link copied to clipboard
inline fun <T> nullable(block: () -> T): T?

Context runner that catches and normalises all non-fatal thrown exceptions into a null value.

Link copied to clipboard
inline fun <In, Out> In.nullable(block: In.() -> Out): Out?

Context runner that catches and normalises all non-fatal thrown exceptions into a null value.

Link copied to clipboard
inline fun <T> resultOf(block: () -> T): KotlinResult<T>

Context runner to encapsulate the result of block as a nz.adjmunro.outcome.result.KotlinResult.

Link copied to clipboard
inline fun <In, Out> In.resultOf(block: In.() -> Out): KotlinResult<Out>

Context runner to encapsulate the result of block as a KotlinResult.

Link copied to clipboard
fun <T> resultOfEach(vararg blocks: () -> T): List<KotlinResult<T>>

Serial execution of multiple resultOf lambdas. Each lambda is executed in a separate coroutine, and the results are collected as a List of KotlinResult.

Link copied to clipboard

Serial execution of multiple resultOf lambdas. Each lambda is executed in a separate coroutine, and the results are collected as a List of KotlinResult.

Serial execution of multiple resultOf lambdas. Each lambda is executed in a separate coroutine, and the results are collected as a sequence of KotlinResult.

Link copied to clipboard
inline fun <T> KotlinResult<T>.tryRecover(onFailure: (Throwable) -> T): KotlinResult<T>

Transform exception into value.

Link copied to clipboard
inline fun <T> Iterable<KotlinResult<T>>.tryRecoverEach(failure: (Throwable) -> T): List<KotlinResult<T>>

Serial KotlinResult.tryRecover of multiple KotlinResults. Each result is processed in a separate coroutine, and the results are collected as a List of KotlinResult.

Serial KotlinResult.tryRecover of multiple KotlinResults. Each result is processed in a separate coroutine, and the results are collected as a Sequence of KotlinResult.