Import
import { Sink } from "@typed/fx";Access Sink.loopEffect 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 loopEffect: {
<B, A, E2, R2, C>(seed: B, f: (acc: B, a: A) => Effect.Effect<readonly [
C,
B
], E2, R2>): <E, R>(sink: Sink<C, E | E2, R>) => Sink<A, E | E2, R | R2>;
<A, E, R, B, C>(sink: Sink<C, E, R>, seed: B, f: (acc: B, a: A) => Effect.Effect<readonly [
C,
B
], E, R>): Sink<A, E, R>;
};Why
Stateful consumer transitions can consult Effect services or fail without moving the state machine into the producer.
Ownership and lifetime
Callback invocation constructs a transition Effect from the seed visible at that moment. The adapter does not serialize those Effects: overlapping callbacks can read the same seed, and successful transitions commit in completion order. A failure is sent to the wrapped sink and does not commit. The sink instance retains its last committed seed when reused by another producer run; construct a new adapted sink to reset it. Transition services and interruption remain typed.
Examples
import { Effect } from "effect"
import * as Sink from "@typed/fx/Sink"
const target = Sink.make(Effect.logError, Effect.log)
const totals = Sink.loopEffect(target, 0, (sum, n: number) => Effect.succeed([sum + n, sum + n] as const))Other public imports
These import paths expose the same declaration. Each page retains its own public name and signature.