# withEarlyExit

Runs a producer-style callback with a sink that can complete the surrounding Effect early.

## Signatures

```ts
export declare function withEarlyExit<A, E, R, R2>(sink: Sink<A, E, R>, f: (sink: Sink.WithEarlyExit<A, E, R>, params: {
    signal: AbortSignal;
    scheduler: Scheduler;
}) => Effect.Effect<unknown, never, R2>): Effect.Effect<void, never, R | R2>;
```

## Why

Consumer combinators can stop upstream work after a bound or predicate without representing
normal completion as failure.

## Ownership and lifetime

The returned Effect owns the callback fiber. Completion, `earlyExit`, or interruption aborts that
fiber through the supplied signal; deliveries after exit are ignored. The callback's services are
combined with the wrapped sink's services.

## Examples

```ts
import { Effect } from "effect"
import * as Sink from "@typed/fx/Sink"
const base = Sink.make(Effect.logError, Effect.log)
const program = Sink.withEarlyExit(base, (sink) => sink.onSuccess("done").pipe(Effect.andThen(sink.earlyExit)))
```
