EagerEffect

interface EagerEffect<out R, out A>(source)

RestrictsSuspension version of Effect. This version runs eagerly, and can be used in non-suspending code. An effect computation interoperates with an EagerEffect via bind.

See also

Functions

Link copied to clipboard
open fun attempt(): EagerEffect<R, Result<A>>
Link copied to clipboard
abstract fun <B> fold(recover: (R) -> B, transform: (A) -> B): B

Runs the non-suspending computation by creating a Continuation with an EmptyCoroutineContext, and running the fold function over the computation.

open fun <B> fold(error: (error: Throwable) -> B, recover: (shifted: R) -> B, transform: (value: A) -> B): B

Like fold but also allows folding over any unexpected Throwable that might have occurred.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open fun orNull(): A?

fold the EagerEffect into an A?. Where the shifted value R is mapped to null, and result value A.

Link copied to clipboard
open fun <B> redeem(f: (R) -> B, g: (A) -> B): EagerEffect<Nothing, B>
Link copied to clipboard
open fun <R2, B> redeemWith(f: (R) -> EagerEffect<R2, B>, g: (A) -> EagerEffect<R2, B>): EagerEffect<R2, B>
Link copied to clipboard
open fun toEither(): Either<R, A>

fold the EagerEffect into an Either. Where the shifted value R is mapped to Either.Left, and result value A is mapped to Either.Right.

Link copied to clipboard
open fun toIor(): Ior<R, A>

fold the EagerEffect into an Ior. Where the shifted value R is mapped to Ior.Left, and result value A is mapped to Ior.Right.

Link copied to clipboard
open fun toOption(orElse: (R) -> Option<@UnsafeVariance A>): Option<A>

fold the EagerEffect into an Option. Where the shifted value R is mapped to Option by the provided function orElse, and result value A is mapped to Some.

Link copied to clipboard
open fun toValidated(): Validated<R, A>

fold the EagerEffect into an Validated. Where the shifted value R is mapped to Validated.Invalid, and result value A is mapped to Validated.Valid.

Extensions

Link copied to clipboard
fun <A> EagerEffect<A, A>.merge(): A
Link copied to clipboard
Link copied to clipboard