Sink<A, In, L, E, R>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: 42export interface 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<out function (type parameter) A in Sink<out A, in In = unknown, out L = never, out E = never, out R = never>A, in function (type parameter) In in Sink<out A, in In = unknown, out L = never, out E = never, out R = never>In = unknown, out function (type parameter) L in Sink<out A, in In = unknown, out L = never, out E = never, out R = never>L = never, out function (type parameter) E in Sink<out A, in In = unknown, out L = never, out E = never, out R = never>E = never, out function (type parameter) R in Sink<out A, in In = unknown, out L = never, out E = never, out R = never>R = never>
extends Sink.interface Sink<out A, in In = unknown, out L = never, out E = never, out R = never>.Variance<out A, in In, out L, out E, out R>Type-level variance marker for Sink.
Details
The result A, leftovers L, errors E, and services R are
covariant. The input type In is contravariant because values flow into
the sink.
Variance<function (type parameter) A in Sink<out A, in In = unknown, out L = never, out E = never, out R = never>A, function (type parameter) In in Sink<out A, in In = unknown, out L = never, out E = never, out R = never>In, function (type parameter) L in Sink<out A, in In = unknown, out L = never, out E = never, out R = never>L, function (type parameter) E in Sink<out A, in In = unknown, out L = never, out E = never, out R = never>E, function (type parameter) R in Sink<out A, in In = unknown, out L = never, out E = never, out R = never>R>, Pipeable
{
readonly Sink<out A, in In = unknown, out L = never, out E = never, out R = never>.transform: (upstream: Pull.Pull<NonEmptyReadonlyArray<In>, never, void>, scope: Scope.Scope) => Effect.Effect<End<A, L>, E, R>transform: (
upstream: Pull.Pull<
NonEmptyReadonlyArray<In>,
never,
void
>
(parameter) upstream: {
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;
}
upstream: import PullPull.interface Pull<out A, out E = never, out Done = void, out R = never>An effectful pull step that either produces a value, fails with E, or
signals completion with Cause.Done<Done>.
When to use
Use to model one low-level pull step when a consumer repeatedly evaluates an
effect that may emit a value, fail normally, or signal normal completion
through Cause.Done.
Details
Pull represents completion in the error channel so low-level stream
consumers can distinguish ordinary failures from end-of-input and carry a
leftover value when needed.
Pull<type NonEmptyReadonlyArray<A> = readonly [A, ...A[]]A readonly array guaranteed to have at least one element.
When to use
Use when non-emptiness must be tracked at the type level while preventing mutation.
Many Array module functions accept or return this type.
Example (Typing a non-empty array)
import type { Array } from "effect"
const nonEmpty: Array.NonEmptyReadonlyArray<number> = [1, 2, 3]
const head: number = nonEmpty[0] // guaranteed to exist
NonEmptyReadonlyArray<function (type parameter) In in Sink<out A, in In = unknown, out L = never, out E = never, out R = never>In>, never, void>,
scope: Scope.Scope(parameter) scope: {
strategy: "sequential" | "parallel";
state: State.Open | State.Closed | State.Empty;
}
scope: import ScopeScope.Scope
) => import EffectEffect.interface Effect<out A, out E = never, out R = never>The Effect interface defines a value that lazily describes a workflow or
job. The workflow requires some context R, and may fail with an error of
type E, or succeed with a value of type A.
When to use
Use when you need to represent a lazy, composable workflow that can require
services, fail with a typed error, or succeed with a typed value.
Details
Effect values model resourceful interaction with the outside world,
including synchronous, asynchronous, concurrent, and parallel interaction.
They use a fiber-based concurrency model, with built-in support for
scheduling, fine-grained interruption, structured concurrency, and high
scalability.
To run an Effect value, you need a Runtime, which is a type that is
capable of executing Effect values.
Effect<type End<A, L = never> = readonly [
value: A,
leftover?: readonly [L, ...L[]] | undefined
]
Tuple returned when a Sink finishes.
Details
The first element is the sink result. The optional second element contains a
non-empty array of leftover input that was pulled but not consumed.
End<function (type parameter) A in Sink<out A, in In = unknown, out L = never, out E = never, out R = never>A, function (type parameter) L in Sink<out A, in In = unknown, out L = never, out E = never, out R = never>L>, function (type parameter) E in Sink<out A, in In = unknown, out L = never, out E = never, out R = never>E, function (type parameter) R in Sink<out A, in In = unknown, out L = never, out E = never, out R = never>R>
[import UnifyUnify.const typeSymbol: typeof Unify.typeSymbolDefines the unique symbol used to identify the type information for unification.
When to use
Use when you need a type-level protocol key that exposes the source type
read by Unify from a protocol-enabled data type.
Details
This symbol is a type-level protocol key. It stores the source type that
unification reads when widening protocol-enabled values.
The type of the typeSymbol.
When to use
Use to reference the type information property key in type-level protocol
definitions.
Details
This type represents the unique symbol used for storing type information
in types that support unification. It's used in type-level operations
to access and manipulate type information.
typeSymbol]?: unknown
[import UnifyUnify.const unifySymbol: typeof Unify.unifySymbolDefines the unique symbol used to identify unification behavior in Effect types.
When to use
Use to define the widened type produced by the Unify protocol for a custom
protocol-enabled data type.
Details
This symbol is a type-level protocol key. It describes how a protocol-enabled
type widens during unification and has no runtime behavior.
The type of the unifySymbol.
When to use
Use to reference the unification behavior property key in type-level
protocol definitions.
Details
This type represents the unique symbol used for identifying unification
behavior in Effect types. It's typically used in type-level operations
to enable automatic type unification.
unifySymbol]?: interface SinkUnify<A extends { [Unify.typeSymbol]?: any; }>Type-level unification support for Sink values.
Details
This preserves the result, input, leftover, error, and service type
parameters when Effect's Unify machinery normalizes generic values that
include sinks. Users normally do not need to reference this interface
directly.
SinkUnify<this>
[import UnifyUnify.const ignoreSymbol: typeof Unify.ignoreSymbolDefines the unique symbol used to specify types that should be ignored during unification.
When to use
Use to hide helper protocol entries from Unify when they should not
contribute to the widened type.
Details
This symbol is a type-level protocol key. It lists protocol entries that
unification should ignore when computing the widened type.
The type of the ignoreSymbol.
When to use
Use to reference the ignored-property key in type-level protocol
definitions.
Details
This type represents the unique symbol used for marking types that should
be ignored during unification operations. It's used in type-level operations
to exclude specific types from the unification process.
ignoreSymbol]?: SinkUnifyIgnore
}
/**
* Tuple returned when a `Sink` finishes.
*
* **Details**
*
* The first element is the sink result. The optional second element contains a
* non-empty array of leftover input that was pulled but not consumed.
*
* @category models
* @since 4.0.0
*/
export type type End<A, L = never> = readonly [
value: A,
leftover?: readonly [L, ...L[]] | undefined
]
Tuple returned when a Sink finishes.
Details
The first element is the sink result. The optional second element contains a
non-empty array of leftover input that was pulled but not consumed.
End<function (type parameter) A in type End<A, L = never>A, function (type parameter) L in type End<A, L = never>L = never> = readonly [Avalue: function (type parameter) A in type End<A, L = never>A, readonly [L, ...L[]] | undefinedleftover?: type NonEmptyReadonlyArray<A> = readonly [A, ...A[]]A readonly array guaranteed to have at least one element.
When to use
Use when non-emptiness must be tracked at the type level while preventing mutation.
Many Array module functions accept or return this type.
Example (Typing a non-empty array)
import type { Array } from "effect"
const nonEmpty: Array.NonEmptyReadonlyArray<number> = [1, 2, 3]
const head: number = nonEmpty[0] // guaranteed to exist
NonEmptyReadonlyArray<function (type parameter) L in type End<A, L = never>L> | undefined]
const const endVoid: Effect.Effect<
End<void, never>,
never,
never
>
const endVoid: {
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;
}
endVoid = import EffectEffect.const succeed: <A>(value: A) => Effect<A>Creates an Effect that always succeeds with a given value.
When to use
Use when an effect should complete successfully with a specific value without any errors
or external dependencies.
Example (Creating a successful effect)
import { Effect } from "effect"
// Creating an effect that represents a successful scenario
//
// ┌─── Effect<number, never, never>
// ▼
const success = Effect.succeed(42)
succeed([void 0] as type End<A, L = never> = readonly [
value: A,
leftover?: readonly [L, ...L[]] | undefined
]
Tuple returned when a Sink finishes.
Details
The first element is the sink result. The optional second element contains a
non-empty array of leftover input that was pulled but not consumed.
End<void, never>)
/**
* Type-level unification support for `Sink` values.
*
* **Details**
*
* This preserves the result, input, leftover, error, and service type
* parameters when Effect's `Unify` machinery normalizes generic values that
* include sinks. Users normally do not need to reference this interface
* directly.
*
* @category models
* @since 2.0.0
*/
export interface interface SinkUnify<A extends { [Unify.typeSymbol]?: any; }>Type-level unification support for Sink values.
Details
This preserves the result, input, leftover, error, and service type
parameters when Effect's Unify machinery normalizes generic values that
include sinks. Users normally do not need to reference this interface
directly.
SinkUnify<function (type parameter) A in SinkUnify<A extends { [Unify.typeSymbol]?: any; }>A extends { [import UnifyUnify.const typeSymbol: typeof Unify.typeSymbolDefines the unique symbol used to identify the type information for unification.
When to use
Use when you need a type-level protocol key that exposes the source type
read by Unify from a protocol-enabled data type.
Details
This symbol is a type-level protocol key. It stores the source type that
unification reads when widening protocol-enabled values.
The type of the typeSymbol.
When to use
Use to reference the type information property key in type-level protocol
definitions.
Details
This type represents the unique symbol used for storing type information
in types that support unification. It's used in type-level operations
to access and manipulate type information.
typeSymbol]?: any }> extends import EffectEffect.interface EffectUnify<A extends { [Unify.typeSymbol]?: any; }>Type-level unification support for Effect values.
EffectUnify<function (type parameter) A in SinkUnify<A extends { [Unify.typeSymbol]?: any; }>A> {
SinkUnify<A extends { [Unify.typeSymbol]?: any; }>.Sink?: () => A[Unify.typeSymbol] extends Sink<infer A, infer In, infer L, infer E, infer R> | infer _ ? Sink<A, In, L, E, R> : neverSink?: () => function (type parameter) A in SinkUnify<A extends { [Unify.typeSymbol]?: any; }>A[import UnifyUnify.type typeSymbol = typeof Unify.typeSymbolDefines the unique symbol used to identify the type information for unification.
When to use
Use when you need a type-level protocol key that exposes the source type
read by Unify from a protocol-enabled data type.
Details
This symbol is a type-level protocol key. It stores the source type that
unification reads when widening protocol-enabled values.
The type of the typeSymbol.
When to use
Use to reference the type information property key in type-level protocol
definitions.
Details
This type represents the unique symbol used for storing type information
in types that support unification. It's used in type-level operations
to access and manipulate type information.
typeSymbol] extends
| 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<
infer function (type parameter) AA,
infer function (type parameter) InIn,
infer function (type parameter) LL,
infer function (type parameter) EE,
infer function (type parameter) RR
>
| infer function (type parameter) __ ? 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<function (type parameter) AA, function (type parameter) InIn, function (type parameter) LL, function (type parameter) EE, function (type parameter) RR>
: never
}
/**
* Marker used by Effect's `Unify` machinery for `Sink` values.
*
* **Details**
*
* It prevents the inherited `Effect` unifier from being selected when
* sink-specific unification should preserve the `Sink` type parameters. Users
* normally do not need to reference this interface directly.
*
* @category models
* @since 2.0.0
*/
export interface SinkUnifyIgnore {
SinkUnifyIgnore.Effect?: true | undefinedEffect?: true
}
/**
* Namespace containing types and interfaces for Sink variance and type relationships.
*
* @since 2.0.0
*/
export declare namespace Sink {
/**
* Type-level variance marker for `Sink`.
*
* **Details**
*
* The result `A`, leftovers `L`, errors `E`, and services `R` are
* covariant. The input type `In` is contravariant because values flow into
* the sink.
*
* @category models
* @since 2.0.0
*/
export interface interface Sink<out A, in In = unknown, out L = never, out E = never, out R = never>.Variance<out A, in In, out L, out E, out R>Type-level variance marker for Sink.
Details
The result A, leftovers L, errors E, and services R are
covariant. The input type In is contravariant because values flow into
the sink.
Variance<out function (type parameter) A in Variance<out A, in In, out L, out E, out R>A, in function (type parameter) In in Variance<out A, in In, out L, out E, out R>In, out function (type parameter) L in Variance<out A, in In, out L, out E, out R>L, out function (type parameter) E in Variance<out A, in In, out L, out E, out R>E, out function (type parameter) R in Variance<out A, in In, out L, out E, out R>R> {
readonly [const TypeId: "~effect/Sink"TypeId]: interface Sink<out A, in In = unknown, out L = never, out E = never, out R = never>.VarianceStruct<out A, in In, out L, out E, out R>Structural encoding used by Sink.Variance to record each Sink type
parameter's variance.
Details
_A, _L, _E, and _R are covariant markers. _In is a
contravariant marker.
VarianceStruct<function (type parameter) A in Variance<out A, in In, out L, out E, out R>A, function (type parameter) In in Variance<out A, in In, out L, out E, out R>In, function (type parameter) L in Variance<out A, in In, out L, out E, out R>L, function (type parameter) E in Variance<out A, in In, out L, out E, out R>E, function (type parameter) R in Variance<out A, in In, out L, out E, out R>R>
}
/**
* Structural encoding used by `Sink.Variance` to record each `Sink` type
* parameter's variance.
*
* **Details**
*
* `_A`, `_L`, `_E`, and `_R` are covariant markers. `_In` is a
* contravariant marker.
*
* @category models
* @since 2.0.0
*/
export interface interface Sink<out A, in In = unknown, out L = never, out E = never, out R = never>.VarianceStruct<out A, in In, out L, out E, out R>Structural encoding used by Sink.Variance to record each Sink type
parameter's variance.
Details
_A, _L, _E, and _R are covariant markers. _In is a
contravariant marker.
VarianceStruct<out function (type parameter) A in VarianceStruct<out A, in In, out L, out E, out R>A, in function (type parameter) In in VarianceStruct<out A, in In, out L, out E, out R>In, out function (type parameter) L in VarianceStruct<out A, in In, out L, out E, out R>L, out function (type parameter) E in VarianceStruct<out A, in In, out L, out E, out R>E, out function (type parameter) R in VarianceStruct<out A, in In, out L, out E, out R>R> {
Sink<out A, in In = unknown, out L = never, out E = never, out R = never>.VarianceStruct<out A, in In, out L, out E, out R>._A: Types.Covariant<A>_A: import TypesTypes.type Covariant<A> = (_: never) => AFunction-type alias encoding covariant variance for a phantom type
parameter.
When to use
Use as a phantom field type to make a type parameter covariant in output
position.
Details
Covariant<A> is assignable to Covariant<B> when A extends B, following
the subtype direction.
Example (Defining a covariant phantom type)
import type { Types } from "effect"
interface Producer<T> {
readonly _phantom: Types.Covariant<T>
readonly get: () => T
}
Namespace for
Covariant
-related utilities.
When to use
Use when referring to type-level helpers nested under Covariant.
Covariant<function (type parameter) A in VarianceStruct<out A, in In, out L, out E, out R>A>
Sink<out A, in In = unknown, out L = never, out E = never, out R = never>.VarianceStruct<out A, in In, out L, out E, out R>._In: Types.Contravariant<In>_In: import TypesTypes.type Contravariant<A> = (_: A) => voidFunction-type alias encoding contravariant variance for a phantom type
parameter.
When to use
Use as a phantom field type to make a type parameter contravariant in input
position.
Details
Contravariant<A> is assignable to Contravariant<B> when B extends A,
following the supertype direction.
Example (Defining a contravariant phantom type)
import type { Types } from "effect"
interface Consumer<T> {
readonly _phantom: Types.Contravariant<T>
readonly accept: (value: T) => void
}
Namespace for
Contravariant
-related utilities.
When to use
Use when referring to type-level helpers nested under Contravariant.
Contravariant<function (type parameter) In in VarianceStruct<out A, in In, out L, out E, out R>In>
Sink<out A, in In = unknown, out L = never, out E = never, out R = never>.VarianceStruct<out A, in In, out L, out E, out R>._L: Types.Covariant<L>_L: import TypesTypes.type Covariant<A> = (_: never) => AFunction-type alias encoding covariant variance for a phantom type
parameter.
When to use
Use as a phantom field type to make a type parameter covariant in output
position.
Details
Covariant<A> is assignable to Covariant<B> when A extends B, following
the subtype direction.
Example (Defining a covariant phantom type)
import type { Types } from "effect"
interface Producer<T> {
readonly _phantom: Types.Covariant<T>
readonly get: () => T
}
Namespace for
Covariant
-related utilities.
When to use
Use when referring to type-level helpers nested under Covariant.
Covariant<function (type parameter) L in VarianceStruct<out A, in In, out L, out E, out R>L>
Sink<out A, in In = unknown, out L = never, out E = never, out R = never>.VarianceStruct<out A, in In, out L, out E, out R>._E: Types.Covariant<E>_E: import TypesTypes.type Covariant<A> = (_: never) => AFunction-type alias encoding covariant variance for a phantom type
parameter.
When to use
Use as a phantom field type to make a type parameter covariant in output
position.
Details
Covariant<A> is assignable to Covariant<B> when A extends B, following
the subtype direction.
Example (Defining a covariant phantom type)
import type { Types } from "effect"
interface Producer<T> {
readonly _phantom: Types.Covariant<T>
readonly get: () => T
}
Namespace for
Covariant
-related utilities.
When to use
Use when referring to type-level helpers nested under Covariant.
Covariant<function (type parameter) E in VarianceStruct<out A, in In, out L, out E, out R>E>
Sink<out A, in In = unknown, out L = never, out E = never, out R = never>.VarianceStruct<out A, in In, out L, out E, out R>._R: Types.Covariant<R>_R: import TypesTypes.type Covariant<A> = (_: never) => AFunction-type alias encoding covariant variance for a phantom type
parameter.
When to use
Use as a phantom field type to make a type parameter covariant in output
position.
Details
Covariant<A> is assignable to Covariant<B> when A extends B, following
the subtype direction.
Example (Defining a covariant phantom type)
import type { Types } from "effect"
interface Producer<T> {
readonly _phantom: Types.Covariant<T>
readonly get: () => T
}
Namespace for
Covariant
-related utilities.
When to use
Use when referring to type-level helpers nested under Covariant.
Covariant<function (type parameter) R in VarianceStruct<out A, in In, out L, out E, out R>R>
}
}