Import
import { Sink } from "@typed/fx";Access Sink.loop 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 loop: {
<B, A, C>(seed: B, f: (acc: B, a: A) => readonly [
C,
B
]): <E, R>(sink: Sink<C, E, R>) => Sink<A, E, R>;
<A, E, R, B, C>(sink: Sink<C, E, R>, seed: B, f: (acc: B, a: A) => readonly [
C,
B
]): Sink<A, E, R>;
};Why
loop implements an ordered consumer-side state machine without exposing mutable state to the
producer.
Ownership and lifetime
Each adapted sink owns its seed. Updates are synchronous and follow callback invocation order; every input produces exactly one downstream success. Failures bypass the state machine. Reusing the same sink for another producer run continues from its retained seed; create a new sink to reset.
Examples
import { Effect } from "effect"
import * as Sink from "@typed/fx/Sink"
const totals = Sink.loop(Sink.make(Effect.logError, Effect.log), 0, (sum, n: number) => [sum + n, sum + n])Other public imports
These import paths expose the same declaration. Each page retains its own public name and signature.