<A2, A3, A4>(options: {
readonly start: A2
readonly middle: A3
readonly end: A4
}): <A, E, R>(self: Stream<A, E, R>) => Stream<A2 | A3 | A4 | A, E, R>
<A, E, R, A2, A3, A4>(
self: Stream<A, E, R>,
options: { readonly start: A2; readonly middle: A3; readonly end: A4 }
): Stream<A | A2 | A3 | A4, E, R>Adds a start value, middle value, and end value around stream elements.
Details
The start and end values are always emitted, even when the stream is empty.
Example (Interspersing stream affixes)
import { Console, Effect, Stream } from "effect"
const stream = Stream.make("a", "b", "c").pipe(
Stream.intersperseAffixes({ start: "[", middle: ",", end: "]" })
)
const program = Effect.gen(function*() {
const result = yield* Stream.runCollect(stream)
yield* Console.log(result)
})
Effect.runPromise(program)
// [ "[", "a", ",", "b", ",", "c", "]" ]export const const intersperseAffixes: {
<A2, A3, A4>(options: {
readonly start: A2
readonly middle: A3
readonly end: A4
}): <A, E, R>(
self: Stream<A, E, R>
) => Stream<A2 | A3 | A4 | A, E, R>
<A, E, R, A2, A3, A4>(
self: Stream<A, E, R>,
options: {
readonly start: A2
readonly middle: A3
readonly end: A4
}
): Stream<A | A2 | A3 | A4, E, R>
}
Adds a start value, middle value, and end value around stream elements.
Details
The start and end values are always emitted, even when the stream is empty.
Example (Interspersing stream affixes)
import { Console, Effect, Stream } from "effect"
const stream = Stream.make("a", "b", "c").pipe(
Stream.intersperseAffixes({ start: "[", middle: ",", end: "]" })
)
const program = Effect.gen(function*() {
const result = yield* Stream.runCollect(stream)
yield* Console.log(result)
})
Effect.runPromise(program)
// [ "[", "a", ",", "b", ",", "c", "]" ]
intersperseAffixes: {
<function (type parameter) A2 in <A2, A3, A4>(options: {
readonly start: A2;
readonly middle: A3;
readonly end: A4;
}): <A, E, R>(self: Stream<A, E, R>) => Stream<A2 | A3 | A4 | A, E, R>
A2, function (type parameter) A3 in <A2, A3, A4>(options: {
readonly start: A2;
readonly middle: A3;
readonly end: A4;
}): <A, E, R>(self: Stream<A, E, R>) => Stream<A2 | A3 | A4 | A, E, R>
A3, function (type parameter) A4 in <A2, A3, A4>(options: {
readonly start: A2;
readonly middle: A3;
readonly end: A4;
}): <A, E, R>(self: Stream<A, E, R>) => Stream<A2 | A3 | A4 | A, E, R>
A4>(
options: {
readonly start: A2
readonly middle: A3
readonly end: A4
}
options: { readonly start: A2start: function (type parameter) A2 in <A2, A3, A4>(options: {
readonly start: A2;
readonly middle: A3;
readonly end: A4;
}): <A, E, R>(self: Stream<A, E, R>) => Stream<A2 | A3 | A4 | A, E, R>
A2; readonly middle: A3middle: function (type parameter) A3 in <A2, A3, A4>(options: {
readonly start: A2;
readonly middle: A3;
readonly end: A4;
}): <A, E, R>(self: Stream<A, E, R>) => Stream<A2 | A3 | A4 | A, E, R>
A3; readonly end: A4end: function (type parameter) A4 in <A2, A3, A4>(options: {
readonly start: A2;
readonly middle: A3;
readonly end: A4;
}): <A, E, R>(self: Stream<A, E, R>) => Stream<A2 | A3 | A4 | A, E, R>
A4 }
): <function (type parameter) A in <A, E, R>(self: Stream<A, E, R>): Stream<A2 | A3 | A4 | A, E, R>A, function (type parameter) E in <A, E, R>(self: Stream<A, E, R>): Stream<A2 | A3 | A4 | A, E, R>E, function (type parameter) R in <A, E, R>(self: Stream<A, E, R>): Stream<A2 | A3 | A4 | A, E, R>R>(self: Stream<A, E, R>(parameter) self: {
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; <…;
}
self: 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) A in <A, E, R>(self: Stream<A, E, R>): Stream<A2 | A3 | A4 | A, E, R>A, function (type parameter) E in <A, E, R>(self: Stream<A, E, R>): Stream<A2 | A3 | A4 | A, E, R>E, function (type parameter) R in <A, E, R>(self: Stream<A, E, R>): Stream<A2 | A3 | A4 | A, E, R>R>) => 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) A2 in <A2, A3, A4>(options: {
readonly start: A2;
readonly middle: A3;
readonly end: A4;
}): <A, E, R>(self: Stream<A, E, R>) => Stream<A2 | A3 | A4 | A, E, R>
A2 | function (type parameter) A3 in <A2, A3, A4>(options: {
readonly start: A2;
readonly middle: A3;
readonly end: A4;
}): <A, E, R>(self: Stream<A, E, R>) => Stream<A2 | A3 | A4 | A, E, R>
A3 | function (type parameter) A4 in <A2, A3, A4>(options: {
readonly start: A2;
readonly middle: A3;
readonly end: A4;
}): <A, E, R>(self: Stream<A, E, R>) => Stream<A2 | A3 | A4 | A, E, R>
A4 | function (type parameter) A in <A, E, R>(self: Stream<A, E, R>): Stream<A2 | A3 | A4 | A, E, R>A, function (type parameter) E in <A, E, R>(self: Stream<A, E, R>): Stream<A2 | A3 | A4 | A, E, R>E, function (type parameter) R in <A, E, R>(self: Stream<A, E, R>): Stream<A2 | A3 | A4 | A, E, R>R>
<function (type parameter) A in <A, E, R, A2, A3, A4>(self: Stream<A, E, R>, options: {
readonly start: A2;
readonly middle: A3;
readonly end: A4;
}): Stream<A | A2 | A3 | A4, E, R>
A, function (type parameter) E in <A, E, R, A2, A3, A4>(self: Stream<A, E, R>, options: {
readonly start: A2;
readonly middle: A3;
readonly end: A4;
}): Stream<A | A2 | A3 | A4, E, R>
E, function (type parameter) R in <A, E, R, A2, A3, A4>(self: Stream<A, E, R>, options: {
readonly start: A2;
readonly middle: A3;
readonly end: A4;
}): Stream<A | A2 | A3 | A4, E, R>
R, function (type parameter) A2 in <A, E, R, A2, A3, A4>(self: Stream<A, E, R>, options: {
readonly start: A2;
readonly middle: A3;
readonly end: A4;
}): Stream<A | A2 | A3 | A4, E, R>
A2, function (type parameter) A3 in <A, E, R, A2, A3, A4>(self: Stream<A, E, R>, options: {
readonly start: A2;
readonly middle: A3;
readonly end: A4;
}): Stream<A | A2 | A3 | A4, E, R>
A3, function (type parameter) A4 in <A, E, R, A2, A3, A4>(self: Stream<A, E, R>, options: {
readonly start: A2;
readonly middle: A3;
readonly end: A4;
}): Stream<A | A2 | A3 | A4, E, R>
A4>(
self: Stream<A, E, R>(parameter) self: {
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; <…;
}
self: 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) A in <A, E, R, A2, A3, A4>(self: Stream<A, E, R>, options: {
readonly start: A2;
readonly middle: A3;
readonly end: A4;
}): Stream<A | A2 | A3 | A4, E, R>
A, function (type parameter) E in <A, E, R, A2, A3, A4>(self: Stream<A, E, R>, options: {
readonly start: A2;
readonly middle: A3;
readonly end: A4;
}): Stream<A | A2 | A3 | A4, E, R>
E, function (type parameter) R in <A, E, R, A2, A3, A4>(self: Stream<A, E, R>, options: {
readonly start: A2;
readonly middle: A3;
readonly end: A4;
}): Stream<A | A2 | A3 | A4, E, R>
R>,
options: {
readonly start: A2
readonly middle: A3
readonly end: A4
}
options: { readonly start: A2start: function (type parameter) A2 in <A, E, R, A2, A3, A4>(self: Stream<A, E, R>, options: {
readonly start: A2;
readonly middle: A3;
readonly end: A4;
}): Stream<A | A2 | A3 | A4, E, R>
A2; readonly middle: A3middle: function (type parameter) A3 in <A, E, R, A2, A3, A4>(self: Stream<A, E, R>, options: {
readonly start: A2;
readonly middle: A3;
readonly end: A4;
}): Stream<A | A2 | A3 | A4, E, R>
A3; readonly end: A4end: function (type parameter) A4 in <A, E, R, A2, A3, A4>(self: Stream<A, E, R>, options: {
readonly start: A2;
readonly middle: A3;
readonly end: A4;
}): Stream<A | A2 | A3 | A4, E, R>
A4 }
): 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) A in <A, E, R, A2, A3, A4>(self: Stream<A, E, R>, options: {
readonly start: A2;
readonly middle: A3;
readonly end: A4;
}): Stream<A | A2 | A3 | A4, E, R>
A | function (type parameter) A2 in <A, E, R, A2, A3, A4>(self: Stream<A, E, R>, options: {
readonly start: A2;
readonly middle: A3;
readonly end: A4;
}): Stream<A | A2 | A3 | A4, E, R>
A2 | function (type parameter) A3 in <A, E, R, A2, A3, A4>(self: Stream<A, E, R>, options: {
readonly start: A2;
readonly middle: A3;
readonly end: A4;
}): Stream<A | A2 | A3 | A4, E, R>
A3 | function (type parameter) A4 in <A, E, R, A2, A3, A4>(self: Stream<A, E, R>, options: {
readonly start: A2;
readonly middle: A3;
readonly end: A4;
}): Stream<A | A2 | A3 | A4, E, R>
A4, function (type parameter) E in <A, E, R, A2, A3, A4>(self: Stream<A, E, R>, options: {
readonly start: A2;
readonly middle: A3;
readonly end: A4;
}): Stream<A | A2 | A3 | A4, E, R>
E, function (type parameter) R in <A, E, R, A2, A3, A4>(self: Stream<A, E, R>, options: {
readonly start: A2;
readonly middle: A3;
readonly end: A4;
}): Stream<A | A2 | A3 | A4, E, R>
R>
} = import dualdual(2, <function (type parameter) A in <A, E, R, A2, A3, A4>(self: Stream<A, E, R>, options: {
readonly start: A2;
readonly middle: A3;
readonly end: A4;
}): Stream<A | A2 | A3 | A4, E, R>
A, function (type parameter) E in <A, E, R, A2, A3, A4>(self: Stream<A, E, R>, options: {
readonly start: A2;
readonly middle: A3;
readonly end: A4;
}): Stream<A | A2 | A3 | A4, E, R>
E, function (type parameter) R in <A, E, R, A2, A3, A4>(self: Stream<A, E, R>, options: {
readonly start: A2;
readonly middle: A3;
readonly end: A4;
}): Stream<A | A2 | A3 | A4, E, R>
R, function (type parameter) A2 in <A, E, R, A2, A3, A4>(self: Stream<A, E, R>, options: {
readonly start: A2;
readonly middle: A3;
readonly end: A4;
}): Stream<A | A2 | A3 | A4, E, R>
A2, function (type parameter) A3 in <A, E, R, A2, A3, A4>(self: Stream<A, E, R>, options: {
readonly start: A2;
readonly middle: A3;
readonly end: A4;
}): Stream<A | A2 | A3 | A4, E, R>
A3, function (type parameter) A4 in <A, E, R, A2, A3, A4>(self: Stream<A, E, R>, options: {
readonly start: A2;
readonly middle: A3;
readonly end: A4;
}): Stream<A | A2 | A3 | A4, E, R>
A4>(
self: Stream<A, E, R>(parameter) self: {
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; <…;
}
self: 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) A in <A, E, R, A2, A3, A4>(self: Stream<A, E, R>, options: {
readonly start: A2;
readonly middle: A3;
readonly end: A4;
}): Stream<A | A2 | A3 | A4, E, R>
A, function (type parameter) E in <A, E, R, A2, A3, A4>(self: Stream<A, E, R>, options: {
readonly start: A2;
readonly middle: A3;
readonly end: A4;
}): Stream<A | A2 | A3 | A4, E, R>
E, function (type parameter) R in <A, E, R, A2, A3, A4>(self: Stream<A, E, R>, options: {
readonly start: A2;
readonly middle: A3;
readonly end: A4;
}): Stream<A | A2 | A3 | A4, E, R>
R>,
options: {
readonly start: A2
readonly middle: A3
readonly end: A4
}
options: { readonly start: A2start: function (type parameter) A2 in <A, E, R, A2, A3, A4>(self: Stream<A, E, R>, options: {
readonly start: A2;
readonly middle: A3;
readonly end: A4;
}): Stream<A | A2 | A3 | A4, E, R>
A2; readonly middle: A3middle: function (type parameter) A3 in <A, E, R, A2, A3, A4>(self: Stream<A, E, R>, options: {
readonly start: A2;
readonly middle: A3;
readonly end: A4;
}): Stream<A | A2 | A3 | A4, E, R>
A3; readonly end: A4end: function (type parameter) A4 in <A, E, R, A2, A3, A4>(self: Stream<A, E, R>, options: {
readonly start: A2;
readonly middle: A3;
readonly end: A4;
}): Stream<A | A2 | A3 | A4, E, R>
A4 }
): 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) A in <A, E, R, A2, A3, A4>(self: Stream<A, E, R>, options: {
readonly start: A2;
readonly middle: A3;
readonly end: A4;
}): Stream<A | A2 | A3 | A4, E, R>
A | function (type parameter) A2 in <A, E, R, A2, A3, A4>(self: Stream<A, E, R>, options: {
readonly start: A2;
readonly middle: A3;
readonly end: A4;
}): Stream<A | A2 | A3 | A4, E, R>
A2 | function (type parameter) A3 in <A, E, R, A2, A3, A4>(self: Stream<A, E, R>, options: {
readonly start: A2;
readonly middle: A3;
readonly end: A4;
}): Stream<A | A2 | A3 | A4, E, R>
A3 | function (type parameter) A4 in <A, E, R, A2, A3, A4>(self: Stream<A, E, R>, options: {
readonly start: A2;
readonly middle: A3;
readonly end: A4;
}): Stream<A | A2 | A3 | A4, E, R>
A4, function (type parameter) E in <A, E, R, A2, A3, A4>(self: Stream<A, E, R>, options: {
readonly start: A2;
readonly middle: A3;
readonly end: A4;
}): Stream<A | A2 | A3 | A4, E, R>
E, function (type parameter) R in <A, E, R, A2, A3, A4>(self: Stream<A, E, R>, options: {
readonly start: A2;
readonly middle: A3;
readonly end: A4;
}): Stream<A | A2 | A3 | A4, E, R>
R> =>
const succeed: <A>(value: A) => Stream<A>Creates a single-valued pure stream.
Example (Creating a single-valued pure stream)
import { Console, Effect, Stream } from "effect"
const program = Effect.gen(function*() {
const values = yield* Stream.succeed(3).pipe(Stream.runCollect)
yield* Console.log(values)
})
Effect.runPromise(program)
// [ 3 ]
succeed(options: {
readonly start: A2
readonly middle: A3
readonly end: A4
}
options.start: A2start).pipe(
const concat: {
<A2, E2, R2>(that: Stream<A2, E2, R2>): <
A,
E,
R
>(
self: Stream<A, E, R>
) => Stream<A | A2, E | E2, R | R2>
<A, E, R, A2, E2, R2>(
self: Stream<A, E, R>,
that: Stream<A2, E2, R2>
): Stream<A | A2, E | E2, R | R2>
}
concat(const intersperse: {
<A2>(element: A2): <A, E, R>(
self: Stream<A, E, R>
) => Stream<A2 | A, E, R>
<A, E, R, A2>(
self: Stream<A, E, R>,
element: A2
): Stream<A | A2, E, R>
}
intersperse(self: Stream<A, E, R>(parameter) self: {
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; <…;
}
self, options: {
readonly start: A2
readonly middle: A3
readonly end: A4
}
options.middle: A3middle)),
const concat: {
<A2, E2, R2>(that: Stream<A2, E2, R2>): <
A,
E,
R
>(
self: Stream<A, E, R>
) => Stream<A | A2, E | E2, R | R2>
<A, E, R, A2, E2, R2>(
self: Stream<A, E, R>,
that: Stream<A2, E2, R2>
): Stream<A | A2, E | E2, R | R2>
}
concat(const succeed: <A>(value: A) => Stream<A>Creates a single-valued pure stream.
Example (Creating a single-valued pure stream)
import { Console, Effect, Stream } from "effect"
const program = Effect.gen(function*() {
const values = yield* Stream.succeed(3).pipe(Stream.runCollect)
yield* Console.log(values)
})
Effect.runPromise(program)
// [ 3 ]
succeed(options: {
readonly start: A2
readonly middle: A3
readonly end: A4
}
options.end: A4end))
))