IorEagerEffectScope

Constructors

Link copied to clipboard
fun <E> IorEagerEffectScope(semigroup: Semigroup<E>, effect: EagerEffectScope<E>)

Functions

Link copied to clipboard
open suspend fun <E, A> attempt(f: suspend EagerEffectScope<E>.() -> A): suspend EagerEffectScope<E>.() -> A

Encloses an action for which you want to catch any shift. attempt is used in combination with catch.

Link copied to clipboard
open suspend fun <B> Either<E, B>.bind(): B

Folds Either into EagerEffect, by returning B or a shift with R.

open suspend fun <B> Validated<E, B>.bind(): B

Folds Validated into EagerEffect, by returning B or a shift with R.

open suspend fun <B> EagerEffect<E, B>.bind(): B

Runs the EagerEffect to finish, returning B or shift in case of R.

suspend fun <B> Ior<E, B>.bind(): B

open suspend fun <B> Option<B>.bind(shift: () -> E): B

Folds Option into EagerEffect, by returning B or a transforming None into R and shifting the result.

open suspend fun <B> Result<B>.bind(transform: (Throwable) -> E): B

Folds Result into EagerEffect, by returning B or a transforming Throwable into R and shifting the result.

Link copied to clipboard
open infix fun <E, A> suspend EagerEffectScope<E>.() -> A.catch(recover: EagerEffectScope<E>.(E) -> A): A

When the EagerEffect has shifted with R it will recover the shifted value to A, and when it ran the computation to completion it will return the value A. catch is used in combination with attempt.

Link copied to clipboard
open override fun E.combine(b: E): E

Combine two A values.

Link copied to clipboard
open suspend fun ensure(condition: Boolean, shift: () -> E)

ensure that condition is true, if it's false it will shift with the provided value R. Monadic version of kotlin.require.

Link copied to clipboard
open override fun E.maybeCombine(b: E?): E
Link copied to clipboard
open operator override fun E.plus(b: E): E
Link copied to clipboard
open suspend override fun <B> shift(r: E): B

Short-circuit the EagerEffect computation with value R.

Extensions

Link copied to clipboard
suspend fun <R, B : Any> EagerEffectScope<R>.ensureNotNull(value: B?, shift: () -> R): B

Ensure that value is not null. if it's non-null it will be smart-casted and returned if it's false it will shift with the provided value R. Monadic version of kotlin.requireNotNull.