Follow one execution
This Denied failure selects the Denied handler from the handler table.
catchTagsTick 0. Input: guide; Output: guide.
Read this diagram
Follow each lane from left to right. Events stacked vertically share a tick; the green cursor marks the current time across every lane.
- A value
The text inside the pill is the emitted value. - Work starts
The raised chevron starts an inner run (^in the source). - The run returns
The vertical bar ends this lane’s run. - A cause is delivered
The exclamation mark belongs to this lane. - Work is interrupted
The cross marks cancellation of this run. - Current time
The line and diamond move together across all lanes. - Happening now
A highlighted event is at the current tick. - Still ahead
Muted, dashed values have not happened yet. - Time continues
The lane’s arrow is not a return marker. An empty stretch can be quiet work that is still running.
Illustrated ticks start at 0. At 1×, one illustrated tick takes one second; captions specify real durations when timing matters. A cause or interruption belongs to its lane, and other work may continue. Scroll horizontally to inspect the rest of a long timeline.
The first Fail found anywhere in the source Cause is inspected. A listed tag starts exactly one handler Fx and replaces the entire original Cause, including any defects or interrupts composed with that Fail. An untagged or unlisted first Fail, or a Cause with no Fail, propagates intact. Handlers are lazy and contribute their individual errors and service requirements.
Import
import { catchTags } from "@typed/fx/Fx";Signatures
export declare const catchTags: {
<E, Cases extends TaggedCase<E>>(cases: Cases): <A, R>(self: Fx<A, E, R>) => Fx<A | {
[K in keyof Cases]: CaseSuccess<Cases[K]>;
}[keyof Cases], Exclude<E, {
_tag: keyof Cases;
}> | {
[K in keyof Cases]: CaseError<Cases[K]>;
}[keyof Cases], R | {
[K in keyof Cases]: CaseServices<Cases[K]>;
}[keyof Cases]>;
<A, E, R, Cases extends TaggedCase<E>>(self: Fx<A, E, R>, cases: Cases): Fx<A | {
[K in keyof Cases]: CaseSuccess<Cases[K]>;
}[keyof Cases], Exclude<E, {
_tag: keyof Cases;
}> | {
[K in keyof Cases]: CaseError<Cases[K]>;
}[keyof Cases], R | {
[K in keyof Cases]: CaseServices<Cases[K]>;
}[keyof Cases]>;
};Why
A handler table keeps multi-variant recovery exhaustive and preserves the precise success, error, and service unions produced by each selected case. Unlisted variants remain visible in the returned error channel.
Ownership and lifetime
The first Fail found anywhere in the source Cause is inspected. A listed tag starts exactly one handler Fx and replaces the entire original Cause, including any defects or interrupts composed with that Fail. An untagged or unlisted first Fail, or a Cause with no Fail, propagates intact. Handlers are lazy and contribute their individual errors and service requirements.
Examples
import { catchTags } from "@typed/fx/Fx"
import { fail, succeed } from "@typed/fx/Fx"
type Failure =
| { readonly _tag: "Missing"; readonly id: string }
| { readonly _tag: "Forbidden" }
const source = fail<Failure>({ _tag: "Missing", id: "42" })
const recovered = catchTags(source, {
Missing: ({ id }) => succeed(`missing:${id}`),
Forbidden: () => succeed("forbidden")
})Other public imports
These import paths expose the same declaration. Each page retains its own public name and signature.