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>, import PipeablePipeable
{
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.type Pull.Pull = /*unresolved*/ anyPull<import NonEmptyReadonlyArrayNonEmptyReadonlyArray<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.type Scope.Scope = /*unresolved*/ anyScope
) => import EffectEffect.type Effect.Effect = /*unresolved*/ anyEffect<type End<A, L = never> = readonly [
value: A,
leftover?: any
]
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?: any
]
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, leftover?: import NonEmptyReadonlyArrayNonEmptyReadonlyArray<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.succeed([void 0] as type End<A, L = never> = readonly [
value: A,
leftover?: any
]
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.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>
}
}