ResultRaise

Constructors

Link copied to clipboard

Functions

Link copied to clipboard
open suspend fun <E, A> attempt(f: suspend EffectScope<E>.() -> A): Effect<E, A>
Link copied to clipboard
open fun <A> Either<Throwable, A>.bind(): A

Extract the Either.Right value of an Either. Any encountered Either.Left will be raised as a logical failure in this Raise context. You can wrap the bind call in recover if you want to attempt to recover from any logical failure.

open fun <A> Validated<Throwable, A>.bind(): A
open suspend fun <B> EagerEffect<Throwable, B>.bind(): B
open suspend fun <B> Effect<Throwable, B>.bind(): B
open fun <A> EagerEffect<Throwable, A>.bind(): A
open suspend fun <A> Effect<Throwable, A>.bind(): A
fun <B> Result<B>.bind(): B

open fun <A> Option<A>.bind(transform: Raise<Throwable>.(None) -> A): A

Extract the Some value out of Option, because Option works with None as its error type you need to transform to R.

open fun <A> Result<A>.bind(transform: (Throwable) -> Throwable): A

Extract the Result.success value out of Result, because Result works with Throwable as its error type you need to transform to R.

Link copied to clipboard
open infix suspend fun <E, A> Effect<E, A>.catch(recover: suspend Raise<Throwable>.(E) -> A): A
open fun <A> EagerEffect<Throwable, A>.catch(catch: Raise<Throwable>.(Throwable) -> A): A
open suspend fun <A> Effect<Throwable, A>.catch(catch: suspend Raise<Throwable>.(Throwable) -> A): A
Link copied to clipboard
open operator fun <A> EagerEffect<Throwable, A>.invoke(): A

Invoke an EagerEffect inside this Raise context. Any logical failure is raised in this Raise context, and thus short-circuits the computation.

open suspend operator fun <A> Effect<Throwable, A>.invoke(): A

Invoke an Effect inside this Raise context. Any logical failure raised are raised in this Raise context, and thus short-circuits the computation.

Link copied to clipboard
open fun <A, B> Iterable<A>.mapOrAccumulate(semigroup: Semigroup<Throwable>, block: Raise<Throwable>.(A) -> B): List<B>

Accumulate the errors obtained by executing the block over every element of this using the given semigroup.

Link copied to clipboard
open override fun raise(r: Throwable): Nothing

Raise a logical failure of type R

Link copied to clipboard
open infix fun <E, A> EagerEffect<E, A>.recover(resolve: Raise<Throwable>.(E) -> A): A
open infix suspend fun <E, A> Effect<E, A>.recover(resolve: suspend Raise<Throwable>.(E) -> A): A

open suspend fun <E, A> Effect<E, A>.recover(action: suspend Raise<E>.() -> A, recover: suspend Raise<Throwable>.(E) -> A, catch: suspend Raise<Throwable>.(Throwable) -> A): A

Execute the Effect resulting in A, and recover from any logical error of type E, and Throwable, by providing a fallback value of type A, or raising a new error of type R.

Link copied to clipboard
open fun <B> shift(r: Throwable): B
Link copied to clipboard
open fun <A, B, C> zipOrAccumulate(semigroup: Semigroup<Throwable>, action1: Raise<Throwable>.() -> A, action2: Raise<Throwable>.() -> B, block: Raise<Throwable>.(A, B) -> C): C

Accumulate the errors from running both action1 and action2 using the given semigroup.

open fun <A, B, C, D> zipOrAccumulate(semigroup: Semigroup<Throwable>, action1: Raise<Throwable>.() -> A, action2: Raise<Throwable>.() -> B, action3: Raise<Throwable>.() -> C, block: Raise<Throwable>.(A, B, C) -> D): D

Accumulate the errors from running action1, action2, and action3 using the given semigroup.

open fun <A, B, C, D, E> zipOrAccumulate(semigroup: Semigroup<Throwable>, action1: Raise<Throwable>.() -> A, action2: Raise<Throwable>.() -> B, action3: Raise<Throwable>.() -> C, action4: Raise<Throwable>.() -> D, block: Raise<Throwable>.(A, B, C, D) -> E): E

Accumulate the errors from running action1, action2, action3, and action4 using the given semigroup.

Extensions

Link copied to clipboard
inline fun <R, A> Raise<R>.catch(action: Raise<R>.() -> A, catch: Raise<R>.(Throwable) -> A): A
@JvmName(name = "catchReified")
inline fun <T : Throwable, R, A> Raise<R>.catch(action: Raise<R>.() -> A, catch: Raise<R>.(T) -> A): A
Link copied to clipboard
inline fun <R> Raise<R>.ensure(condition: Boolean, raise: () -> R)
Link copied to clipboard
inline fun <R, B : Any> Raise<R>.ensureNotNull(value: B?, raise: () -> R): B
Link copied to clipboard
inline fun <R, A> Raise<NonEmptyList<R>>.mapErrorNel(crossinline block: Raise<R>.() -> A): A
Link copied to clipboard
inline fun <R, A, B> Raise<NonEmptyList<R>>.mapOrAccumulate(list: Iterable<A>, crossinline block: Raise<R>.(A) -> B): List<B>

Accumulate the errors obtained by executing the block over every element of list.

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

Execute the Raise context function resulting in A or any logical error of type E, and recover by providing a fallback value of type A or raising a new error of type R.

inline fun <R, E, A> Raise<R>.recover(action: Raise<E>.() -> A, recover: Raise<R>.(E) -> A, catch: Raise<R>.(Throwable) -> A): A
Link copied to clipboard
inline fun <R, A, B, C> Raise<NonEmptyList<R>>.zipOrAccumulate(crossinline action1: Raise<R>.() -> A, crossinline action2: Raise<R>.() -> B, crossinline block: Raise<R>.(A, B) -> C): C

Accumulate the errors from running both action1 and action2.

inline fun <R, A, B, C, D> Raise<NonEmptyList<R>>.zipOrAccumulate(crossinline action1: Raise<R>.() -> A, crossinline action2: Raise<R>.() -> B, crossinline action3: Raise<R>.() -> C, crossinline block: Raise<R>.(A, B, C) -> D): D

Accumulate the errors from running action1, action2, and action3.

inline fun <R, A, B, C, D, E> Raise<NonEmptyList<R>>.zipOrAccumulate(crossinline action1: Raise<R>.() -> A, crossinline action2: Raise<R>.() -> B, crossinline action3: Raise<R>.() -> C, crossinline action4: Raise<R>.() -> D, crossinline block: Raise<R>.(A, B, C, D) -> E): E

Accumulate the errors from running action1, action2, action3, and action4.