variable / @typed/fx

Sink.flip

Exchanges a sink’s typed success and failure channels.

Package version
2.0.0-beta.13
Category
Failure handling
Since
1.0.0
Member of
Sink

Import

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

Access Sink.flip through the imported Sink export. Its declaration below describes the member.

This public exposure is a re-export. Its import path is supported; declaration documentation is shared with the other public exposures below.

Signatures

export declare const flip: <A, E, R>(sink: Sink<A, E, R>) => Sink<E, A, R>;

Why

Error-oriented consumers can be reused as value consumers, and vice versa, without changing the producer-side protocol.

Ownership and lifetime

A successful input becomes Cause.fail downstream. For an incoming Cause, the first typed Fail reason becomes a success and every remaining reason is discarded, including later failures, defects, or interruption reasons. A Cause with no typed failure passes through intact. The adapter is synchronous, ordered, and resource-free; use exit when the whole Cause must remain observable.

Examples

import { Effect } from "effect"
import * as Sink from "@typed/fx/Sink"
const errorsAsValues = Sink.flip(Sink.make(Effect.logError, (value: number) => Effect.log(value)))

Other public imports

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

Source