PromiseOf<S>A Hyperlink service handle adapted to Promise / async — what promise returns. Every
Effect becomes a Promise (failures reject), every Stream an AsyncIterable, ref
fields become PromiseSubscribable, nested groups recurse, plain values pass through.
export type type PromiseOf<S> = { readonly [K in keyof S]: S[K] extends Subscribable<infer A> ? PromiseSubscribable<A> : S[K] extends Stream.Stream<infer A, infer _E, infer _R> ? AsyncIterable<A> : S[K] extends Effect.Effect<infer A, infer _E, infer _R> ? Promise<A> : S[K] extends (...args: infer Args) => Effect.Effect<infer A, infer _E, infer _R> ? (...args: Args) => Promise<A> : S[K] extends (...args: infer Args) => Stream.Stream<infer A, infer _E, infer _R> ? (...args: Args) => AsyncIterable<A> : S[K] extends object ? PromiseOf<...> : S[K]; }A Hyperlink service handle adapted to Promise / async — what
promise
returns. Every
Effect becomes a Promise (failures reject), every Stream an AsyncIterable,
ref
fields become
PromiseSubscribable
, nested groups recurse, plain
value
s pass through.
PromiseOf<function (type parameter) S in type PromiseOf<S>S> = {
readonly [function (type parameter) KK in keyof function (type parameter) S in type PromiseOf<S>S]: function (type parameter) S in type PromiseOf<S>S[function (type parameter) KK] 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 PromiseSubscribable<A>Promise-shaped view of a
Subscribable
: lazy get (fresh Promise each access) plus
changes as an AsyncIterable.
PromiseSubscribable<function (type parameter) AA>
: function (type parameter) S in type PromiseOf<S>S[function (type parameter) KK] 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) _E_E, infer function (type parameter) _R_R>
? interface AsyncIterable<T, TReturn = any, TNext = any>AsyncIterable<function (type parameter) AA>
: function (type parameter) S in type PromiseOf<S>S[function (type parameter) KK] 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) AA, infer function (type parameter) _E_E, infer function (type parameter) _R_R>
? interface Promise<T>Represents the completion of an asynchronous operation
Promise<function (type parameter) AA>
: function (type parameter) S in type PromiseOf<S>S[function (type parameter) KK] 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) AA, infer function (type parameter) _E_E, infer function (type parameter) _R_R>
? (...args: Args extends unknown[]args: function (type parameter) ArgsArgs) => interface Promise<T>Represents the completion of an asynchronous operation
Promise<function (type parameter) AA>
: function (type parameter) S in type PromiseOf<S>S[function (type parameter) KK] extends (...args: Args extends unknown[]args: infer function (type parameter) ArgsArgs) => 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) _E_E, infer function (type parameter) _R_R>
? (...args: Args extends unknown[]args: function (type parameter) ArgsArgs) => interface AsyncIterable<T, TReturn = any, TNext = any>AsyncIterable<function (type parameter) AA>
: function (type parameter) S in type PromiseOf<S>S[function (type parameter) KK] extends object
? type PromiseOf<S> = { readonly [K in keyof S]: S[K] extends Subscribable<infer A> ? PromiseSubscribable<A> : S[K] extends Stream.Stream<infer A, infer _E, infer _R> ? AsyncIterable<A> : S[K] extends Effect.Effect<infer A, infer _E, infer _R> ? Promise<A> : S[K] extends (...args: infer Args) => Effect.Effect<infer A, infer _E, infer _R> ? (...args: Args) => Promise<A> : S[K] extends (...args: infer Args) => Stream.Stream<infer A, infer _E, infer _R> ? (...args: Args) => AsyncIterable<A> : S[K] extends object ? PromiseOf<...> : S[K]; }A Hyperlink service handle adapted to Promise / async — what
promise
returns. Every
Effect becomes a Promise (failures reject), every Stream an AsyncIterable,
ref
fields become
PromiseSubscribable
, nested groups recurse, plain
value
s pass through.
PromiseOf<function (type parameter) S in type PromiseOf<S>S[function (type parameter) KK]>
: function (type parameter) S in type PromiseOf<S>S[function (type parameter) KK];
};