WithRequirement<T, Req>Add Req to the requirement channel of every Effect method in an impl shape — the inverse of
ProvidedContext, and a parameterized cousin of Store.AddStorageReq. Use it to annotate a
pre-provide impl (each worker method still carrying its requirement Req) so every method's
destructured params still get their contextual types from the spec, before provideContext
strips Req back off to yield the ImplOf shape. A method (...a) => Effect<S, E, R> →
(...a) => Effect<S, E, R | Req>; a bare Effect<S, E, R> → Effect<S, E, R | Req>; a
Subscribable / Stream member passes through untouched; a nested group recurses.
export type type WithRequirement<T, Req> = 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, R | Req> : T extends Effect.Effect<infer S, infer E, infer R> ? Effect.Effect<S, E, Req | R> : T extends (...args: ReadonlyArray<never>) => unknown ? T : T extends object ? { readonly [K in keyof T]: WithRequirement<...>; } : TAdd Req to the requirement channel of every Effect method in an impl shape — the inverse of
ProvidedContext
, and a parameterized cousin of Store.AddStorageReq. Use it to annotate a
pre-provide impl (each worker method still carrying its requirement Req) so every method's
destructured params still get their contextual types from the spec, before
provideContext
strips Req back off to yield the
ImplOf
shape. A method (...a) => Effect<S, E, R> →
(...a) => Effect<S, E, R | Req>; a bare Effect<S, E, R> → Effect<S, E, R | Req>; a
Subscribable
/
Stream
member passes through untouched; a nested group recurses.
WithRequirement<function (type parameter) T in type WithRequirement<T, Req>T, function (type parameter) Req in type WithRequirement<T, Req>Req> = function (type parameter) T in type WithRequirement<T, Req>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 WithRequirement<T, Req>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 WithRequirement<T, Req>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, function (type parameter) RR | function (type parameter) Req in type WithRequirement<T, Req>Req>
: function (type parameter) T in type WithRequirement<T, Req>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, function (type parameter) RR | function (type parameter) Req in type WithRequirement<T, Req>Req>
: function (type parameter) T in type WithRequirement<T, Req>T extends (...args: readonly never[]args: interface ReadonlyArray<T>ReadonlyArray<never>) => unknown
? function (type parameter) T in type WithRequirement<T, Req>T
: function (type parameter) T in type WithRequirement<T, Req>T extends object
? { readonly [function (type parameter) KK in keyof function (type parameter) T in type WithRequirement<T, Req>T]: type WithRequirement<T, Req> = 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, R | Req> : T extends Effect.Effect<infer S, infer E, infer R> ? Effect.Effect<S, E, Req | R> : T extends (...args: ReadonlyArray<never>) => unknown ? T : T extends object ? { readonly [K in keyof T]: WithRequirement<...>; } : TAdd Req to the requirement channel of every Effect method in an impl shape — the inverse of
ProvidedContext
, and a parameterized cousin of Store.AddStorageReq. Use it to annotate a
pre-provide impl (each worker method still carrying its requirement Req) so every method's
destructured params still get their contextual types from the spec, before
provideContext
strips Req back off to yield the
ImplOf
shape. A method (...a) => Effect<S, E, R> →
(...a) => Effect<S, E, R | Req>; a bare Effect<S, E, R> → Effect<S, E, R | Req>; a
Subscribable
/
Stream
member passes through untouched; a nested group recurses.
WithRequirement<function (type parameter) T in type WithRequirement<T, Req>T[function (type parameter) KK], function (type parameter) Req in type WithRequirement<T, Req>Req> }
: function (type parameter) T in type WithRequirement<T, Req>T;