StreamTypeLambdaType lambda for Stream used in higher-kinded type operations.
Example (Using the stream type lambda)
import type { HKT, Stream } from "effect"
// Create a Stream type using the type lambda
type NumberStream = HKT.Kind<Stream.StreamTypeLambda, never, string, never, number>
// Equivalent to: Stream<number, string, never>type lambdas
Source effect/Stream.ts:1693 lines
export interface StreamTypeLambda extends import TypeLambdaTypeLambda {
readonly StreamTypeLambda.type: Stream<this["Target"], this["Out1"], this["Out2"]>(property) StreamTypeLambda.type: {
channel: Channel.Channel<Arr.NonEmptyReadonlyArray<A>, E, void, unknown, unknown, unknown, R>;
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; <…;
}
type: 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<this["Target"], this["Out1"], this["Out2"]>
}