Sink<unknown, unknown, never, never, never>A sink that never completes.
export const const never: Sink<unknown>const never: {
transform: (upstream: Pull.Pull<NonEmptyReadonlyArray<In>, never, void>, scope: Scope.Scope) => Effect.Effect<End<A, L>, E, R>;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
}
A sink that never completes.
never: interface Sink<out A, in In = unknown, out L = never, out E = never, out R = never>A Sink<A, In, L, E, R> is used to consume elements produced by a Stream.
You can think of a sink as a function that will consume a variable amount of
In elements (could be 0, 1, or many), might fail with an error of type E,
and will eventually yield a value of type A together with a remainder of
type L (i.e. any leftovers).
Example (Running a sink with a stream)
import { Effect, Sink, Stream } from "effect"
// Create a simple sink that always succeeds with a value
const sink: Sink.Sink<number> = Sink.succeed(42)
// Use the sink to consume a stream
const stream = Stream.make(1, 2, 3)
const program = Stream.run(stream, sink)
Effect.runPromise(program).then(console.log)
// Output: 42
Namespace containing types and interfaces for Sink variance and type relationships.
Sink<unknown> = const fromEffectEnd: <A, E, R, L = never>(
effect: Effect.Effect<End<A, L>, E, R>
) => Sink<A, unknown, L, E, R>
Creates a sink that ignores upstream input and completes from an effect that
already returns an End.
When to use
Use when you need to create a sink from an effect that returns both the sink
result value and optional leftovers.
fromEffectEnd(import EffectEffect.const never: Effect<never>const never: {
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
Returns an effect that will never produce anything. The moral equivalent of
while(true) {}, only without the wasted CPU cycles.
Example (Creating a never-ending effect)
import { Effect } from "effect"
// This effect will never complete
const program = Effect.never
// This will run forever (or until interrupted)
// Effect.runPromise(program) // Never resolves
// Use with timeout for practical applications
const timedProgram = Effect.timeout(program, "1 second")
never)