Stream

zio.blocks.streams.Stream
See theStream companion class
object Stream

Companion object for Stream. Provides factory constructors:

Attributes

Companion
class
Source
Stream.scala
Graph
Supertypes
class Object
trait Matchable
class Any
Self type
Stream.type

Members list

Type members

Classlikes

object Zip

Derives Zip instances from tuple-flattening Tuples.Tuples.

Derives Zip instances from tuple-flattening Tuples.Tuples.

Attributes

Companion
trait
Source
Stream.scala
Supertypes
class Object
trait Matchable
class Any
Self type
Zip.type
sealed trait Zip[-A, -B, +C]

Variance-safe adapter for tuple-flattening zip composition. Instances are derived from zio.blocks.combinators.Tuples.Tuples.

Variance-safe adapter for tuple-flattening zip composition. Instances are derived from zio.blocks.combinators.Tuples.Tuples.

Attributes

Companion
object
Source
Stream.scala
Supertypes
class Object
trait Matchable
class Any

Value members

Concrete methods

def apply[A](as: A*)(implicit jt: Infer[A]): Stream[Nothing, A]

Creates a reusable stream from the given elements, preserving argument order.

Creates a reusable stream from the given elements, preserving argument order.

Attributes

Source
Stream.scala
def attempt[A](f: => A)(implicit jtA: Infer[A]): Stream[Throwable, A]

Lazily evaluates f once per materialization and emits its result. Non-fatal exceptions become typed errors; fatal throwables remain defects.

Lazily evaluates f once per materialization and emits its result. Non-fatal exceptions become typed errors; fatal throwables remain defects.

Attributes

Source
Stream.scala
def attemptAsync[A](f: => encoding.Async[A])(implicit jtA: Infer[A]): Stream[Throwable, A]

Lazily evaluates an asynchronous thunk once per materialization and emits its result. Non-fatal synchronous throws and asynchronous failures become typed errors; fatal throwables remain defects.

Lazily evaluates an asynchronous thunk once per materialization and emits its result. Non-fatal synchronous throws and asynchronous failures become typed errors; fatal throwables remain defects.

Attributes

Source
Stream.scala
def attemptEval(f: => Any): Stream[Throwable, Nothing]

Lazily executes f once per materialization and emits nothing. Non-fatal exceptions become typed errors; fatal throwables remain defects.

Lazily executes f once per materialization and emits nothing. Non-fatal exceptions become typed errors; fatal throwables remain defects.

Attributes

Source
Stream.scala
def attemptEvalAsync(f: => encoding.Async[Any]): Stream[Throwable, Nothing]

Lazily executes an asynchronous effect once per materialization and emits nothing. Non-fatal synchronous throws and asynchronous failures become typed errors; fatal throwables remain defects.

Lazily executes an asynchronous effect once per materialization and emits nothing. Non-fatal synchronous throws and asynchronous failures become typed errors; fatal throwables remain defects.

Attributes

Source
Stream.scala
def bufferSize[E, A](n: Int)(body: => Stream[E, A]): Stream[E, A]

Lazily constructs body with n as the materialization buffer size for concurrent operators in that region. Nested regions use the innermost size. n must be a positive power of two.

Lazily constructs body with n as the materialization buffer size for concurrent operators in that region. Nested regions use the innermost size. n must be a positive power of two.

Attributes

Source
Stream.scala
def defer(f: => Unit): Stream[Nothing, Nothing]

Creates an empty stream that lazily registers f as a release action. f runs exactly once when each materialization closes, including after failure, early termination, or cancellation; exceptions are defects.

Creates an empty stream that lazily registers f as a release action. f runs exactly once when each materialization closes, including after failure, early termination, or cancellation; exceptions are defects.

Attributes

Source
Stream.scala
def deferAsync(finalizer: => encoding.Async[Unit]): Stream[Nothing, Nothing]

Creates an empty stream that lazily registers an asynchronous release action. It is awaited exactly once when each materialization closes, including after failure, early termination, or cancellation; failure is a defect.

Creates an empty stream that lazily registers an asynchronous release action. It is awaited exactly once when each materialization closes, including after failure, early termination, or cancellation; failure is a defect.

Attributes

Source
Stream.scala
def die(t: Throwable): Stream[Nothing, Nothing]

Creates a stream that, when pulled, terminates with t as a defect.

Creates a stream that, when pulled, terminates with t as a defect.

Attributes

Source
Stream.scala
def eval(f: => Any): Stream[Nothing, Nothing]

Lazily executes f once per materialization and emits nothing. Any thrown exception is a defect.

Lazily executes f once per materialization and emits nothing. Any thrown exception is a defect.

Attributes

Source
Stream.scala
def evalAsync(f: => encoding.Async[Any]): Stream[Nothing, Nothing]

Lazily executes an asynchronous effect once per materialization and emits nothing; synchronous throws and asynchronous failures are defects.

Lazily executes an asynchronous effect once per materialization and emits nothing; synchronous throws and asynchronous failures are defects.

Attributes

Source
Stream.scala
def fail[E](error: E): Stream[E, Nothing]

Creates a stream that, when pulled, fails in the typed channel with error.

Creates a stream that, when pulled, fails in the typed channel with error.

Attributes

Source
Stream.scala
def flattenAll[E, A](streams: Stream[E, Stream[E, A]])(implicit jtA: Infer[A]): Stream[E, A]

Consumes the inner streams sequentially in outer-stream order, closing each inner stream before advancing to the next.

Consumes the inner streams sequentially in outer-stream order, closing each inner stream before advancing to the next.

Attributes

Source
Stream.scala
def fromAcquireRelease[R, E, A](acquire: => R, release: R => Unit = ...)(use: R => Stream[E, A]): Stream[E, A]

Lazily acquires one resource per materialization, constructs the stream with use, and releases the resource exactly once after completion, failure, early termination, or cancellation. If omitted, release closes an AutoCloseable and otherwise does nothing. Thrown exceptions are defects; use attempt to model acquisition failures as typed errors.

Lazily acquires one resource per materialization, constructs the stream with use, and releases the resource exactly once after completion, failure, early termination, or cancellation. If omitted, release closes an AutoCloseable and otherwise does nothing. Thrown exceptions are defects; use attempt to model acquisition failures as typed errors.

Attributes

Source
Stream.scala
def fromAcquireReleaseAsync[R, E, A](acquire: => encoding.Async[R], release: R => encoding.Async[Unit])(use: R => Stream[E, A])(implicit jtA: Infer[A]): Stream[E, A]

Lazily acquires one resource per materialization, constructs the stream with use, and awaits release exactly once after completion, failure, early termination, or cancellation (including cancellation during acquisition after the resource is obtained). Acquisition, use, and release failures are defects.

Lazily acquires one resource per materialization, constructs the stream with use, and awaits release exactly once after completion, failure, early termination, or cancellation (including cancellation during acquisition after the resource is obtained). Acquisition, use, and release failures are defects.

Attributes

Source
Stream.scala
def fromArray[A](array: Array[A])(implicit jt: Infer[A]): Stream[Nothing, A]

Creates a stream from an array. The array is wrapped via Chunk.fromArray without copying, so later array mutation may be observable.

Creates a stream from an array. The array is wrapped via Chunk.fromArray without copying, so later array mutation may be observable.

Attributes

Source
Stream.scala
def fromChunk[A](chunk: Chunk[A])(implicit jt: Infer[A]): Stream[Nothing, A]

Creates a reusable, already-materialized stream backed by chunk.

Creates a reusable, already-materialized stream backed by chunk.

Attributes

Source
Stream.scala

Lazily wraps an already-created java.io.InputStream as bytes. Read failures are typed java.io.IOException values; close failures are defects. The stream is closed after completion, failure, early termination, or cancellation; each materialization reuses the same supplied instance.

Lazily wraps an already-created java.io.InputStream as bytes. Read failures are typed java.io.IOException values; close failures are defects. The stream is closed after completion, failure, early termination, or cancellation; each materialization reuses the same supplied instance.

Attributes

Source
Stream.scala

Wraps a java.io.InputStream as a stream of bytes without managing its lifecycle. I/O failures are typed java.io.IOException values. The caller owns closing, and each materialization reuses the supplied instance.

Wraps a java.io.InputStream as a stream of bytes without managing its lifecycle. I/O failures are typed java.io.IOException values. The caller owns closing, and each materialization reuses the supplied instance.

Attributes

Source
Stream.scala
def fromIterable[A](it: Iterable[A])(implicit jtA: Infer[A]): Stream[Nothing, A]

Lazily obtains and consumes an iterator from it for each materialization, preserving iteration order. If the iterable has a known size, knownLength is set. Iterator exceptions are defects.

Lazily obtains and consumes an iterator from it for each materialization, preserving iteration order. If the iterable has a known size, knownLength is set. Iterator exceptions are defects.

Attributes

Source
Stream.scala
def fromIterator[A](it: => Iterator[A])(implicit jtA: Infer[A]): Stream[Nothing, A]

Evaluates it once per materialization and consumes it in order. Supply a fresh iterator for repeatable runs; iterator and thunk exceptions are defects.

Evaluates it once per materialization and consumes it in order. Supply a fresh iterator for repeatable runs; iterator and thunk exceptions are defects.

Attributes

Source
Stream.scala
def fromIteratorAsync[A](it: => encoding.Async[Iterator[A]])(implicit jtA: Infer[A]): Stream[Nothing, A]

Asynchronously obtains one iterator per materialization and consumes it in order. Acquisition and iterator failures are defects.

Asynchronously obtains one iterator per materialization and consumes it in order. Acquisition and iterator failures are defects.

Attributes

Source
Stream.scala

Lazily wraps an already-created java.io.Reader as characters. Read failures are typed java.io.IOException values; close failures are defects. The reader is closed after completion, failure, early termination, or cancellation; each materialization reuses the same supplied instance.

Lazily wraps an already-created java.io.Reader as characters. Read failures are typed java.io.IOException values; close failures are defects. The reader is closed after completion, failure, early termination, or cancellation; each materialization reuses the same supplied instance.

Attributes

Source
Stream.scala

Wraps a java.io.Reader as a stream of Chars without managing its lifecycle. I/O failures are typed java.io.IOException values. The caller owns closing, and each materialization reuses the supplied instance.

Wraps a java.io.Reader as a stream of Chars without managing its lifecycle. I/O failures are typed java.io.IOException values. The caller owns closing, and each materialization reuses the supplied instance.

Attributes

Source
Stream.scala
def fromRange(range: Range): Stream[Nothing, Int]

Creates a stream of integers from a Scala Range. The knownLength is set from the range size.

Creates a stream of integers from a Scala Range. The knownLength is set from the range size.

Attributes

Source
Stream.scala
def fromReader[E, A](mkReader: => Reader[A]): Stream[E, A]

Lazily obtains one Reader per materialization and closes it when the stream closes. Reader-thunk failures are defects. This advanced overload preserves whether the returned reader is synchronous or asynchronous.

Lazily obtains one Reader per materialization and closes it when the stream closes. Reader-thunk failures are defects. This advanced overload preserves whether the returned reader is synchronous or asynchronous.

Attributes

Source
Stream.scala
def fromReader[E, A](mkReader: => SyncReader[A])(implicit dummy1: DummyImplicit, dummy2: DummyImplicit): Stream[E, A]

Lazily obtains one synchronous reader per materialization and closes it when the stream closes. Reader-thunk failures are defects.

Lazily obtains one synchronous reader per materialization and closes it when the stream closes. Reader-thunk failures are defects.

Attributes

Source
Stream.scala
def fromReader[E, A](mkReader: => Nothing)(implicit dummy1: DummyImplicit, dummy2: DummyImplicit, dummy3: DummyImplicit): Stream[E, A]

Preserves overload resolution for a reader thunk that never returns. Evaluation remains lazy and a thrown exception is a defect.

Preserves overload resolution for a reader thunk that never returns. Evaluation remains lazy and a thrown exception is a defect.

Attributes

Source
Stream.scala
def fromReader[E, A](mkReader: => AsyncReader[A])(implicit dummy: DummyImplicit): Stream[E, A]

Lazily obtains one asynchronous reader per materialization and awaits its close when the stream closes. Reader-thunk failures are defects.

Lazily obtains one asynchronous reader per materialization and awaits its close when the stream closes. Reader-thunk failures are defects.

Attributes

Source
Stream.scala
def fromReaderAsync[E, A](mkReader: => encoding.Async[Reader[A]])(implicit jtA: Infer[A]): Stream[E, A]

Lazily runs mkReader once per materialization and closes the resulting reader when the stream closes. Effect and thunk failures are defects.

Lazily runs mkReader once per materialization and closes the resulting reader when the stream closes. Effect and thunk failures are defects.

Attributes

Source
Stream.scala
def fromResource[R, E, A](resource: Resource[R])(use: R => Stream[E, A]): Stream[E, A]

Lazily creates a Scope per materialization, acquires resource in it, and closes the scope after completion, failure, early termination, or cancellation. Acquisition and scope-finalization failures are defects.

Lazily creates a Scope per materialization, acquires resource in it, and closes the scope after completion, failure, early termination, or cancellation. Acquisition and scope-finalization failures are defects.

Attributes

Source
Stream.scala
def mergeAll[E, A](maxOpen: Int)(streams: Stream[E, Stream[E, A]])(implicit jtA: Infer[A]): Stream[E, A]

Merges up to maxOpen inner streams concurrently into a single output stream. Elements arrive in completion order (unordered with respect to input position). On JVM, each inner stream runs on a virtual thread. On JS, degrades to sequential flatMap. maxOpen must be at least one. Failure or cancellation closes the outer stream and all active inner streams.

Merges up to maxOpen inner streams concurrently into a single output stream. Elements arrive in completion order (unordered with respect to input position). On JVM, each inner stream runs on a virtual thread. On JS, degrades to sequential flatMap. maxOpen must be at least one. Failure or cancellation closes the outer stream and all active inner streams.

Value parameters

maxOpen

maximum number of concurrently active inner streams

streams

a stream of inner streams to merge

Attributes

Source
Stream.scala
def range(from: Int, until: Int): Stream[Nothing, Int]

Creates a stream of integers from from (inclusive) to until (exclusive).

Creates a stream of integers from from (inclusive) to until (exclusive).

Attributes

Source
Stream.scala
def repeat[A](a: A)(implicit jt: Infer[A]): Stream[Nothing, A]

Creates a lazy infinite stream that repeatedly emits a.

Creates a lazy infinite stream that repeatedly emits a.

Attributes

Source
Stream.scala
def succeed(a: Boolean): Stream[Nothing, Boolean]

Creates a stream that emits a single Boolean.

Creates a stream that emits a single Boolean.

Attributes

Source
Stream.scala
def succeed(a: Byte): Stream[Nothing, Byte]

Creates a stream that emits a single Byte.

Creates a stream that emits a single Byte.

Attributes

Source
Stream.scala
def succeed(a: Char): Stream[Nothing, Char]

Creates a stream that emits a single Char.

Creates a stream that emits a single Char.

Attributes

Source
Stream.scala
def succeed(a: Double): Stream[Nothing, Double]

Creates a stream that emits a single Double.

Creates a stream that emits a single Double.

Attributes

Source
Stream.scala
def succeed(a: Float): Stream[Nothing, Float]

Creates a stream that emits a single Float.

Creates a stream that emits a single Float.

Attributes

Source
Stream.scala
def succeed(a: Int): Stream[Nothing, Int]

Creates a stream that emits a single Int.

Creates a stream that emits a single Int.

Attributes

Source
Stream.scala
def succeed(a: Long): Stream[Nothing, Long]

Creates a stream that emits a single Long.

Creates a stream that emits a single Long.

Attributes

Source
Stream.scala
def succeed(a: Short): Stream[Nothing, Short]

Creates a stream that emits a single Short.

Creates a stream that emits a single Short.

Attributes

Source
Stream.scala
def succeed[A](a: A): Stream[Nothing, A]

Creates a stream that emits a single element a, then closes.

Creates a stream that emits a single element a, then closes.

Attributes

Source
Stream.scala
def suspend[E, A](stream: => Stream[E, A]): Stream[E, A]

Defers stream construction until run-time. Useful for recursive streams.

Defers stream construction until run-time. Useful for recursive streams.

Attributes

Source
Stream.scala
def unfold[S, A](s: S)(f: S => Option[(A, S)])(implicit jtA: Infer[A]): Stream[Nothing, A]

Lazily unfolds state sequentially, emitting each A and continuing with the paired state until f returns None. Callback exceptions are defects.

Lazily unfolds state sequentially, emitting each A and continuing with the paired state until f returns None. Callback exceptions are defects.

Attributes

Source
Stream.scala
def unfoldAsync[S, A](s: S)(f: S => encoding.Async[Option[(A, S)]])(implicit jtA: Infer[A]): Stream[Nothing, A]

Lazily unfolds state sequentially, emitting each A and continuing with the paired state until f returns None. At most one callback is active; callback failure is a defect.

Lazily unfolds state sequentially, emitting each A and continuing with the paired state until f returns None. At most one callback is active; callback failure is a defect.

Attributes

Source
Stream.scala
def unwrap[E](stream: => encoding.Async[Stream[E, Nothing]])(implicit dummy: DummyImplicit): Stream[E, Nothing]

Flattens an asynchronously produced stream. The effect is evaluated lazily for each materialization, and failures in the effect are stream defects.

Flattens an asynchronously produced stream. The effect is evaluated lazily for each materialization, and failures in the effect are stream defects.

Attributes

Source
Stream.scala
def unwrap[E, A](stream: => encoding.Async[Stream[E, A]])(implicit jtA: Infer[A]): Stream[E, A]

Flattens an asynchronously produced stream. The effect is evaluated lazily once per materialization; effect failures are defects, while the produced stream retains its typed error channel.

Flattens an asynchronously produced stream. The effect is evaluated lazily once per materialization; effect failures are defects, while the produced stream retains its typed error channel.

Attributes

Source
Stream.scala

Concrete fields

val empty: Stream[Nothing, Nothing]

The empty stream that emits no elements.

The empty stream that emits no elements.

Attributes

Source
Stream.scala