interface / @typed/async-data

Failure

Represents an Effect failure, optionally while a retry refreshes it.

Package version
1.0.0-beta.13
Category
State models
Since
1.0.0

Import

import { Failure } from "@typed/async-data";

Signatures

export interface Failure<E> {
    readonly _tag: "Failure";
    readonly cause: Cause.Cause<E>;
    readonly progress?: Progress | undefined;
}

Why

Retaining the complete Effect Cause preserves typed errors, defects, and interruption instead of flattening failure detail.

Ownership and lifetime

This plain wrapper acquires no resources; its Cause is persistent, but the wrapper itself is not frozen.

Property: _tag

The discriminant for a failed computation.

Property: _tag: Why

The literal tag separates failure from absence and loading.

Property: _tag: Ownership and lifetime

Inherits the resource-free lifetime of its enclosing state.

Property: cause

The complete Effect cause of failure.

Property: cause: Why

Cause preservation keeps defects and interruption observable alongside typed failures.

Property: cause: Ownership and lifetime

Inherits the enclosing state’s lifetime; Effect Cause is persistent.

Property: progress

Optional progress for a retry of the failed operation.

Property: progress: Why

Its presence distinguishes a refreshing failure from a settled failure.

Property: progress: Ownership and lifetime

Inherits the resource-free lifetime of its enclosing state.

Examples

import { failure } from "@typed/async-data"
import { Cause } from "effect"
const state = failure(Cause.fail("offline"))

See Effect Cause.

Source