ContEffect

interface ContEffect<R>

Context of the Cont DSL.

Functions

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

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

open suspend fun <B> Either<R, B>.bind(): B

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

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

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

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

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

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

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

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

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

shift
Link copied to clipboard
abstract suspend fun <B> shift(r: R): B

Short-circuit the Cont computation with value R.

Inheritors

IorEffect
Link copied to clipboard
OptionEffect
Link copied to clipboard

Extensions

ensureNotNull
Link copied to clipboard
suspend fun <R, B : Any> ContEffect<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.

suspend fun <B : Any> ContEffect<None>.ensureNotNull(value: B?): B

Sources

common source
Link copied to clipboard