function / @typed/fx/Sink

mapError

Maps the error channel of a sink using the provided function. Failures are mapped via Cause.map; defects and interrupts are preserved.

Package version
2.0.0-beta.7
Category
Failure handling
Since
1.0.0

Import

import { mapError } from "@typed/fx/Sink";

Signatures

export declare function mapError<A, E, E2, R>(sink: Sink<A, E2, R>, f: (e: E) => E2): Sink<A, E, R>;

Why

A producer’s typed error can be translated into the vocabulary expected by an existing consumer without losing Cause structure.

Ownership and lifetime

Mapping is synchronous and resource-free. Success order is unchanged; only Fail reasons are mapped, while defects and interruption reasons pass through untouched.

Examples

import { Effect } from "effect"
import * as Sink from "@typed/fx/Sink"
const target: Sink.Sink<number, string> = Sink.make(Effect.logError, Effect.log)
const acceptsNumbers = Sink.mapError(target, (error: number) => `code:${error}`)

Other public imports

These import paths expose the same declaration. Each page retains its own public name and signature.

Source