ProvidedContext<T, Ctx>Remove the requirement channel R from every Effect method in an impl shape — the per-method-precise
result of provideContext. Mirrors Store.CatchWriteError, but subtracts the provided context
Ctx from each method's requirement rather than catching an error — sound like Effect.provideContext
(R → Exclude<R, Ctx>), so a requirement the context does not cover survives as a residual (and a
later ImplOf assignment catches it) instead of being silently claimed never. A method
(...a) => Effect<S, E, R> → (...a) => Effect<S, E, Exclude<R, Ctx>>; a bare Effect<S, E, R> →
Effect<S, E, Exclude<R, Ctx>>; a Subscribable (a ref field's impl) and a Stream
(a stream field's impl, or a group's live) pass through untouched; a nested method group recurses.
export type type ProvidedContext<T, Ctx> = T extends Subscribable<infer A> ? Subscribable<A> : T extends Stream.Stream<infer A, infer E, infer R> ? Stream.Stream<A, E, R> : T extends (...args: infer Args) => Effect.Effect<infer S, infer E, infer R> ? (...args: Args) => Effect.Effect<S, E, Exclude<R, Ctx>> : T extends Effect.Effect<infer S, infer E, infer R> ? Effect.Effect<S, E, Exclude<R, Ctx>> : T extends (...args: ReadonlyArray<never>) => unknown ? T : T extends object ? { readonly [K in keyof T]: ProvidedContext<...>; } : TRemove the requirement channel R from every Effect method in an impl shape — the per-method-precise
result of
provideContext
. Mirrors Store.CatchWriteError, but subtracts the provided context
Ctx from each method's requirement rather than catching an error — sound like Effect.provideContext
(R → Exclude<R, Ctx>), so a requirement the context does not cover survives as a residual (and a
later ImplOf assignment catches it) instead of being silently claimed never. A method
(...a) => Effect<S, E, R> → (...a) => Effect<S, E, Exclude<R, Ctx>>; a bare Effect<S, E, R> →
Effect<S, E, Exclude<R, Ctx>>; a
Subscribable
(a
ref
field's impl) and a
Stream
(a stream field's impl, or a group's live) pass through untouched; a nested method group recurses.
ProvidedContext<function (type parameter) T in type ProvidedContext<T, Ctx>T, function (type parameter) Ctx in type ProvidedContext<T, Ctx>Ctx> = function (type parameter) T in type ProvidedContext<T, Ctx>T extends interface Subscribable<A>A read-only reactive value: its current value (
Subscribable.get
, an Effect) plus a stream
of every change (
Subscribable.changes
). This is what a
ref
field surfaces — uniform local
and remote — and it's exactly the read side of a SubscriptionRef (Effect ships no Subscribable type in
this beta, so we name it here).
Subscribable<infer function (type parameter) AA>
? interface Subscribable<A>A read-only reactive value: its current value (
Subscribable.get
, an Effect) plus a stream
of every change (
Subscribable.changes
). This is what a
ref
field surfaces — uniform local
and remote — and it's exactly the read side of a SubscriptionRef (Effect ships no Subscribable type in
this beta, so we name it here).
Subscribable<function (type parameter) AA>
: function (type parameter) T in type ProvidedContext<T, Ctx>T extends import StreamStream.interface Stream<out A, out E = never, out R = never>A Stream<A, E, R> describes a program that can emit many A values, fail
with E, and require R.
Details
Streams are pull-based with backpressure and emit chunks to amortize effect
evaluation. They support monadic composition and error handling similar to
Effect, adapted for multiple values.
Example (Creating and consuming streams)
import { Console, Effect, Stream } from "effect"
const program = Effect.gen(function*() {
yield* Stream.make(1, 2, 3).pipe(
Stream.map((n) => n * 2),
Stream.runForEach((n) => Console.log(n))
)
})
Effect.runPromise(program)
// Output:
// 2
// 4
// 6
Stream<infer function (type parameter) AA, infer function (type parameter) EE, infer function (type parameter) RR>
? import StreamStream.interface Stream<out A, out E = never, out R = never>A Stream<A, E, R> describes a program that can emit many A values, fail
with E, and require R.
Details
Streams are pull-based with backpressure and emit chunks to amortize effect
evaluation. They support monadic composition and error handling similar to
Effect, adapted for multiple values.
Example (Creating and consuming streams)
import { Console, Effect, Stream } from "effect"
const program = Effect.gen(function*() {
yield* Stream.make(1, 2, 3).pipe(
Stream.map((n) => n * 2),
Stream.runForEach((n) => Console.log(n))
)
})
Effect.runPromise(program)
// Output:
// 2
// 4
// 6
Stream<function (type parameter) AA, function (type parameter) EE, function (type parameter) RR>
: function (type parameter) T in type ProvidedContext<T, Ctx>T extends (...args: Args extends unknown[]args: infer function (type parameter) ArgsArgs) => 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<infer function (type parameter) SS, infer function (type parameter) EE, infer function (type parameter) RR>
? (...args: Args extends unknown[]args: function (type parameter) ArgsArgs) => 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<function (type parameter) SS, function (type parameter) EE, type Exclude<T, U> = T extends U
? never
: T
Exclude from T those types that are assignable to U
Exclude<function (type parameter) RR, function (type parameter) Ctx in type ProvidedContext<T, Ctx>Ctx>>
: function (type parameter) T in type ProvidedContext<T, Ctx>T extends 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<infer function (type parameter) SS, infer function (type parameter) EE, infer function (type parameter) RR>
? 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<function (type parameter) SS, function (type parameter) EE, type Exclude<T, U> = T extends U
? never
: T
Exclude from T those types that are assignable to U
Exclude<function (type parameter) RR, function (type parameter) Ctx in type ProvidedContext<T, Ctx>Ctx>>
: function (type parameter) T in type ProvidedContext<T, Ctx>T extends (...args: readonly never[]args: interface ReadonlyArray<T>ReadonlyArray<never>) => unknown
? function (type parameter) T in type ProvidedContext<T, Ctx>T
: function (type parameter) T in type ProvidedContext<T, Ctx>T extends object
? { readonly [function (type parameter) KK in keyof function (type parameter) T in type ProvidedContext<T, Ctx>T]: type ProvidedContext<T, Ctx> = T extends Subscribable<infer A> ? Subscribable<A> : T extends Stream.Stream<infer A, infer E, infer R> ? Stream.Stream<A, E, R> : T extends (...args: infer Args) => Effect.Effect<infer S, infer E, infer R> ? (...args: Args) => Effect.Effect<S, E, Exclude<R, Ctx>> : T extends Effect.Effect<infer S, infer E, infer R> ? Effect.Effect<S, E, Exclude<R, Ctx>> : T extends (...args: ReadonlyArray<never>) => unknown ? T : T extends object ? { readonly [K in keyof T]: ProvidedContext<...>; } : TRemove the requirement channel R from every Effect method in an impl shape — the per-method-precise
result of
provideContext
. Mirrors Store.CatchWriteError, but subtracts the provided context
Ctx from each method's requirement rather than catching an error — sound like Effect.provideContext
(R → Exclude<R, Ctx>), so a requirement the context does not cover survives as a residual (and a
later ImplOf assignment catches it) instead of being silently claimed never. A method
(...a) => Effect<S, E, R> → (...a) => Effect<S, E, Exclude<R, Ctx>>; a bare Effect<S, E, R> →
Effect<S, E, Exclude<R, Ctx>>; a
Subscribable
(a
ref
field's impl) and a
Stream
(a stream field's impl, or a group's live) pass through untouched; a nested method group recurses.
ProvidedContext<function (type parameter) T in type ProvidedContext<T, Ctx>T[function (type parameter) KK], function (type parameter) Ctx in type ProvidedContext<T, Ctx>Ctx> }
: function (type parameter) T in type ProvidedContext<T, Ctx>T;