trait Stream[-R, +E, +A] extends Serializable
A Stream[E, A] represents an effectful stream that can produce values of
type A, or potentially fail with a value of type E.
Streams have a very similar API to Scala collections, making them immediately familiar to most developers. Unlike Scala collections, streams can be used on effectful streams of data, such as HTTP connections, files, and so forth.
Streams do not leak resources. This guarantee holds in the presence of early termination (not all of a stream is consumed), failure, or even interruption.
Thanks to only first-order types, appropriate variance annotations, and specialized effect type (ZIO), streams feature extremely good type inference and should almost never require specification of any type parameters.
- Self Type
- Stream[R, E, A]
- Alphabetic
- By Inheritance
- Stream
- Serializable
- Serializable
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Abstract Value Members
Concrete Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##(): Int
- Definition Classes
- AnyRef → Any
- final def ++[R1 <: R, E1 >: E, A1 >: A](that: ⇒ Stream[R1, E1, A1]): Stream[R1, E1, A1]
Concatenates the specified stream to this stream.
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clone(): AnyRef
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @native() @throws(classOf[java.lang.CloneNotSupportedException])
- def collect[B](pf: PartialFunction[A, B]): Stream[R, E, B]
Performs a filter and map in a single step.
- final def drain: Stream[R, E, Nothing]
Converts this stream to a stream that executes its effects but emits no elements.
Converts this stream to a stream that executes its effects but emits no elements. Useful for sequencing effects using streams:
(Stream(1, 2, 3).tap(i => ZIO(println(i))) ++ Stream.lift(ZIO(println("Done!"))).drain ++ Stream(4, 5, 6).tap(i => ZIO(println(i)))).run(Sink.drain)
- final def drop(n: Int): Stream[R, E, A]
Drops the specified number of elements from this stream.
- def dropWhile(pred: (A) ⇒ Boolean): Stream[R, E, A]
Drops all elements of the stream for as long as the specified predicate evaluates to
true. - final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- def filter(pred: (A) ⇒ Boolean): Stream[R, E, A]
Filters this stream by the specified predicate, retaining all elements for which the predicate evaluates to true.
- final def filterM[R1 <: R, E1 >: E](pred: (A) ⇒ ZIO[R1, E1, Boolean]): Stream[R1, E1, A]
Filters this stream by the specified effectful predicate, retaining all elements for which the predicate evaluates to true.
- final def filterNot(pred: (A) ⇒ Boolean): Stream[R, E, A]
Filters this stream by the specified predicate, removing all elements for which the predicate evaluates to true.
- def finalize(): Unit
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable])
- final def flatMap[R1 <: R, E1 >: E, B](f: (A) ⇒ Stream[R1, E1, B]): Stream[R1, E1, B]
Maps each element of this stream to another stream, and returns the concatenation of those streams.
- def foldLeft[A1 >: A, S](s: S)(f: (S, A1) ⇒ S): ZIO[R, E, S]
- final def foreach[R1 <: R, E1 >: E](f: (A) ⇒ ZIO[R1, E1, Unit]): ZIO[R1, E1, Unit]
Consumes all elements of the stream, passing them to the specified callback.
- final def foreachWhile[R1 <: R, E1 >: E](f: (A) ⇒ ZIO[R1, E1, Boolean]): ZIO[R1, E1, Unit]
Consumes elements of the stream, passing them to the specified callback, and terminating consumption when the callback returns
false. - def forever: Stream[R, E, A]
Repeats this stream forever.
- final def getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- def map[B](f: (A) ⇒ B): Stream[R, E, B]
Maps over elements of the stream with the specified function.
- def mapAccum[S1, B](s1: S1)(f1: (S1, A) ⇒ (S1, B)): Stream[R, E, B]
Statefully maps over the elements of this stream to produce new elements.
- final def mapAccumM[E1 >: E, S1, B](s1: S1)(f1: (S1, A) ⇒ IO[E1, (S1, B)]): Stream[R, E1, B]
Statefully and effectfully maps over the elements of this stream to produce new elements.
- def mapConcat[B](f: (A) ⇒ Chunk[B]): Stream[R, E, B]
Maps each element to a chunk, and flattens the chunks into the output of this stream.
- final def mapM[R1 <: R, E1 >: E, B](f: (A) ⇒ ZIO[R1, E1, B]): Stream[R1, E1, B]
Maps over elements of the stream with the specified effectful function.
- final def merge[R1 <: R, E1 >: E, A1 >: A](that: Stream[R1, E1, A1], capacity: Int = 1): Stream[R1, E1, A1]
Merges this stream and the specified stream together.
- final def mergeEither[R1 <: R, E1 >: E, B](that: Stream[R1, E1, B], capacity: Int = 1): Stream[R1, E1, Either[A, B]]
Merges this stream and the specified stream together to produce a stream of eithers.
- final def mergeWith[R1 <: R, E1 >: E, B, C](that: Stream[R1, E1, B], capacity: Int = 1)(l: (A) ⇒ C, r: (B) ⇒ C): Stream[R1, E1, C]
Merges this stream and the specified stream together to a common element type with the specified mapping functions.
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def peel[R1 <: R, E1 >: E, A1 >: A, B](sink: Sink[R1, E1, A1, A1, B]): Managed[R1, E1, (B, Stream[R1, E1, A1])]
Peels off enough material from the stream to construct an
Rusing the providedSink, and then returns both theRand the remainder of theStreamin a managed resource.Peels off enough material from the stream to construct an
Rusing the providedSink, and then returns both theRand the remainder of theStreamin a managed resource. Like allManagedresources, the provided remainder is valid only within the scope ofManaged. - def repeat[R1 <: R](schedule: Schedule[R1, Unit, _]): Stream[R1 with Clock, E, A]
Repeats the entire stream using the specified schedule.
Repeats the entire stream using the specified schedule. The stream will execute normally, and then repeat again according to the provided schedule.
- def repeatElems[R1 <: R, B](schedule: Schedule[R1, A, B]): Stream[R1 with Clock, E, A]
Repeats elements of the stream using the provided schedule.
- def run[R1 <: R, E1 >: E, A0, A1 >: A, B](sink: Sink[R1, E1, A0, A1, B]): ZIO[R1, E1, B]
Runs the sink on the stream to produce either the sink's result or an error.
- final def synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
- final def take(n: Int): Stream[R, E, A]
Takes the specified number of elements from this stream.
- def takeWhile(pred: (A) ⇒ Boolean): Stream[R, E, A]
Takes all elements of the stream for as long as the specified predicate evaluates to
true. - final def tap[R1 <: R, E1 >: E](f: (A) ⇒ ZIO[R1, E1, _]): Stream[R1, E1, A]
Adds an effect to consumption of every element of the stream.
- final def toQueue[E1 >: E, A1 >: A](capacity: Int = 1): Managed[R, Nothing, Queue[Take[E1, A1]]]
Converts the stream to a managed queue.
Converts the stream to a managed queue. After managed queue is used, the queue will never again produce values and should be discarded.
- def toString(): String
- Definition Classes
- AnyRef → Any
- final def transduce[R1 <: R, E1 >: E, A1 >: A, C](sink: Sink[R1, E1, A1, A1, C]): Stream[R1, E1, C]
Applies a transducer to the stream, which converts one or more elements of type
Ainto elements of typeC. - final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @throws(classOf[java.lang.InterruptedException])
- final def zip[R1 <: R, E1 >: E, B](that: Stream[R1, E1, B], lc: Int = 1, rc: Int = 1): Stream[R1, E1, (A, B)]
Zips this stream together with the specified stream.
- final def zipWith[R1 <: R, E1 >: E, B, C](that: Stream[R1, E1, B], lc: Int = 1, rc: Int = 1)(f: (Option[A], Option[B]) ⇒ Option[C]): Stream[R1, E1, C]
Zips two streams together with a specified function.
- def zipWithIndex[R1 <: R]: Stream[R1, E, (A, Int)]
Zips this stream together with the index of elements of the stream.