fold

suspend fun <Error, A, B> Effect<Error, A>.fold(catch: suspend (throwable: Throwable) -> B, recover: suspend (error: Error) -> B, transform: suspend (value: A) -> B): B(source)

invoke the Effect and fold the result:

This method should never be wrapped in try/catch as it will not throw any unexpected errors, it will only result in CancellationException, or fatal exceptions such as OutOfMemoryError.


suspend fun <Error, A, B> Effect<Error, A>.fold(recover: suspend (error: Error) -> B, transform: suspend (value: A) -> B): B(source)

invoke the Effect and fold the result:

This function re-throws any exceptions thrown within the Effect.


inline fun <Error, A, B> EagerEffect<Error, A>.fold(catch: (throwable: Throwable) -> B, recover: (error: Error) -> B, transform: (value: A) -> B): B(source)

invoke the EagerEffect and fold the result:

This method should never be wrapped in try/catch as it will not throw any unexpected errors, it will only result in CancellationException, or fatal exceptions such as OutOfMemoryError.


inline fun <Error, A, B> EagerEffect<Error, A>.fold(recover: (error: Error) -> B, transform: (value: A) -> B): B(source)

invoke the EagerEffect and fold the result:

This function re-throws any exceptions thrown within the Effect.


@JvmName(name = "_foldOrThrow")
inline fun <Error, A, B> fold(block: Raise<Error>.() -> A, recover: (error: Error) -> B, transform: (value: A) -> B): B(source)

The most general way to execute a computation using Raise. Depending on the outcome of the block, one of the two continuations is run:

This function re-throws any exceptions thrown within the Raise block.


@JvmName(name = "_fold")
inline fun <Error, A, B> fold(block: Raise<Error>.() -> A, catch: (throwable: Throwable) -> B, recover: (error: Error) -> B, transform: (value: A) -> B): B(source)

The most general way to execute a computation using Raise. Depending on the outcome of the block, one of the three continuations is run:

This method should never be wrapped in try/catch as it will not throw any unexpected errors, it will only result in CancellationException, or fatal exceptions such as OutOfMemoryError.