RunDSL

class RunDSL<A>(defaultValueOnFailure: suspend () -> A, successful: suspend (Outcome.Success<A>) -> A = { it.value }, failed: suspend (Outcome.Failure) -> A = { _ -> defaultValueOnFailure() })

A DSL for configuring the behavior of run and runSync methods.

Parameters

A

The type of the value produced by the computation.

defaultValueOnFailure

A suspendable function that provides the default value on failure.

successful

A function to handle successful outcomes.

failed

A function to handle failed outcomes.

Constructors

Link copied to clipboard
constructor(defaultValueOnFailure: suspend () -> A, successful: suspend (Outcome.Success<A>) -> A = { it.value }, failed: suspend (Outcome.Failure) -> A = { _ -> defaultValueOnFailure() })
constructor(defaultValueOnFailure: A)

Constructs a RunDSL with a constant default value.

Functions

Link copied to clipboard
fun build(): Pair<suspend (Outcome.Success<A>) -> A, suspend (Outcome.Failure) -> A>

Builds the configuration into a pair of success and failure handlers.

Link copied to clipboard
fun defaultValueOnFailure(block: suspend () -> A): Effect.RunDSL<A>

Sets the default value provider for failed computations.

Link copied to clipboard
fun failed(block: suspend Outcome.Failure.() -> A): Effect.RunDSL<A>

Configures the handling of failed outcomes.

Link copied to clipboard
fun successful(block: suspend Outcome.Success<A>.() -> A): Effect.RunDSL<A>

Configures the handling of successful outcomes.