YieldableErrorBase interface for error classes that can be yielded directly inside
Effect.gen. Yielding one of these errors fails the generator with that
error as the typed failure value.
Details
All built-in error classes in this module (NoSuchElementError,
TimeoutError, IllegalArgumentError, ExceededCapacityError,
AsyncFiberError, and UnknownError) implement this interface.
Example (Yielding an error in Effect.gen)
import { Cause, Effect } from "effect"
const error = new Cause.NoSuchElementError("not found")
const program = Effect.gen(function*() {
return yield* error // fails the effect with NoSuchElementError
})export interface YieldableError extends Error, Pipeable, Inspectable {
readonly [import EffectEffect.const TypeId: TypeIdType-level identifier for Effect values.
Runtime identifier used to recognize Effect values.
TypeId]: import EffectEffect.interface Variance<A, E, R>Variance interface for Effect, encoding the type parameters' variance.
Variance<never, this, never>
[var Symbol: SymbolConstructorSymbol.SymbolConstructor.iterator: typeof Symbol.iteratorA method that returns the default iterator for an object. Called by the semantics of the
for-of statement.
iterator](): import EffectEffect.interface EffectIterator<T extends Effect.Effect<any, any, any>>Iterator interface for Effect generators, enabling Effect values to work with generator functions.
When to use
Use when defining or typing [Symbol.iterator]() for values typed as
Effects so yield* can pass their success type back into Effect.gen.
EffectIterator<import EffectEffect.interface Effect<out A, out E = never, out R = never>The Effect interface defines a value that lazily describes a workflow or
job. The workflow requires some context R, and may fail with an error of
type E, or succeed with a value of type A.
When to use
Use when you need to represent a lazy, composable workflow that can require
services, fail with a typed error, or succeed with a typed value.
Details
Effect values model resourceful interaction with the outside world,
including synchronous, asynchronous, concurrent, and parallel interaction.
They use a fiber-based concurrency model, with built-in support for
scheduling, fine-grained interruption, structured concurrency, and high
scalability.
To run an Effect value, you need a Runtime, which is a type that is
capable of executing Effect values.
Effect<never, this, never>>
}