<const C extends StoreContractValue>(
scope: string | StoreScopeTag,
contract: C
): Effect.Effect<StoreHandleOf<C>, never, Storage>Like resolve, but guarantees a handle (resolve hardened with orDie). With the baked-in
default store in context (it materializes any scope on demand), this never fails — the always-on
observability path, where a resource's engine records unconditionally with no service-sniffing. If a
custom store is in context and lacks this scope, that's a wiring error and it dies with a clear
message (bake the default so it can materialize the scope).
export const const resolveOrDie: <
C extends StoreContractValue
>(
scope: string | StoreScopeTag,
contract: C
) => Effect.Effect<
StoreHandleOf<C>,
never,
Storage
>
Like
resolve
, but guarantees a handle (resolve hardened with orDie). With the baked-in
default store in context (it materializes any scope on demand), this never fails — the always-on
observability path, where a resource's engine records unconditionally with no service-sniffing. If a
custom store is in context and lacks this scope, that's a wiring error and it dies with a clear
message (bake the default so it can materialize the scope).
resolveOrDie = <const function (type parameter) C in <const C extends StoreContractValue>(scope: string | StoreScopeTag, contract: C): Effect.Effect<StoreHandleOf<C>, never, Storage>C extends import StoreContractValueStoreContractValue>(
scope: anyscope: string | import StoreScopeTagStoreScopeTag,
contract: const C extends StoreContractValuecontract: function (type parameter) C in <const C extends StoreContractValue>(scope: string | StoreScopeTag, contract: C): Effect.Effect<StoreHandleOf<C>, never, Storage>C,
): 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<import StoreHandleOfStoreHandleOf<function (type parameter) C in <const C extends StoreContractValue>(scope: string | StoreScopeTag, contract: C): Effect.Effect<StoreHandleOf<C>, never, Storage>C>, never, class Storageclass Storage {
Service: Service;
key: Identifier;
}
Scope bridge every store handle resolves through — provided by an app
Service
layer or
the soft-default
layerDefaultMemory
(via
withDefaultStorage
). Engines resolve
handles via
withDefault
/
withStorage
(preferred) or bridge.at.
Storage> =>
const resolve: <
C extends StoreContractValue
>(
scope: string | StoreScopeTag,
contract: C
) => Effect.Effect<
StoreHandleOf<C>,
StoreScopeNotRegistered,
Storage
>
Resolve the store handle for a scope from the storage in context (an app
Service
, or the
baked-in in-memory default). Collapses the flatMap(bridge, (b) => b.at(scope, contract)) plumbing
so consumers never touch the underlying service directly.
Fails
StoreScopeNotRegistered
when the provided storage doesn't carry this scope — the
opt-in path (e.g. persist only if the app wired durable storage for me). For the always-on
observability path, use
resolveOrDie
.
resolve(scope: anyscope, contract: const C extends StoreContractValuecontract).Pipeable.pipe<Effect.Effect<StoreHandleOf<C>, StoreScopeNotRegistered, Storage>, Effect.Effect<StoreHandleOf<C>, any, Storage>>(this: Effect.Effect<StoreHandleOf<C>, StoreScopeNotRegistered, Storage>, ab: (_: Effect.Effect<StoreHandleOf<C>, StoreScopeNotRegistered, Storage>) => Effect.Effect<StoreHandleOf<C>, any, Storage>): Effect.Effect<StoreHandleOf<C>, any, Storage> (+21 overloads)pipe(
import EffectEffect.const catchTag: <"StoreScopeNotRegistered", any, never, never, never, unassigned, never, never>(k: "StoreScopeNotRegistered", f: (e: any) => Effect.Effect<never, never, never>, orElse?: ((e: any) => Effect.Effect<unassigned, never, never>) | undefined) => <A, R>(self: Effect.Effect<A, any, R>) => Effect.Effect<A, any, R> (+1 overload)Catches and handles specific errors by their _tag field, which is used as a
discriminator.
When to use
Use when you need to recover from one specific tagged error in an effect
error channel.
Details
The error type must have a readonly _tag field. catchTag matches that
field and only handles errors with the requested tag.
Example (Handling a tagged error)
import { Effect } from "effect"
class NetworkError {
readonly _tag = "NetworkError"
constructor(readonly message: string) {}
}
class ValidationError {
readonly _tag = "ValidationError"
constructor(readonly message: string) {}
}
declare const task: Effect.Effect<string, NetworkError | ValidationError>
const program = Effect.catchTag(
task,
"NetworkError",
(error) => Effect.succeed(`Recovered from network error: ${error.message}`)
)
catchTag("StoreScopeNotRegistered", (e: anye) =>
import EffectEffect.const die: (
defect: unknown
) => Effect.Effect<never>
Creates an effect that terminates a fiber with a specified error.
When to use
Use when you need an Effect to report an unrecoverable defect instead of a
typed error.
Details
The die function is used to signal a defect, which represents a critical
and unexpected error in the code. When invoked, it produces an effect that
does not handle the error and instead terminates the fiber.
The error channel of the resulting effect is of type never, indicating that
it cannot recover from this failure.
Example (Failing on division by zero)
import { Effect } from "effect"
const divide = (a: number, b: number) =>
b === 0
? Effect.die(new Error("Cannot divide by zero"))
: Effect.succeed(a / b)
// ┌─── Effect<number, never, never>
// ▼
const program = divide(1, 0)
Effect.runPromise(program).catch(console.error)
// Output:
// (FiberFailure) Error: Cannot divide by zero
// ...stack trace...
die(
`Store.resolveOrDie: scope "${e: anye.key}" is not registered in the provided store. ` +
`If Soft override captured an AppStore, register this engine on that Store.Service ` +
`(Process.store / QueueHyperlink.store / CustomQueueHyperlink.store / RunHyperlink.store) ` +
`alongside Node.logs — or omit Soft override so Memory soft-default materializes the scope.`,
),
),
);