Object/Class

fs2

Stream

Related Docs: class Stream | package fs2

Permalink

object Stream

Source
Stream.scala
Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Stream
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Type Members

  1. final class EmptyOps extends AnyVal

    Permalink

    Provides syntax for pure empty pipes.

  2. final class InvariantOps[F[_], O] extends AnyVal

    Permalink

    Provides syntax for streams that are invariant in F and O.

  3. implicit final class PipeOps[F[_], I, O] extends AnyVal

    Permalink

    Provides operations on effectful pipes for syntactic convenience.

  4. final class PureOps[O] extends AnyVal

    Permalink

    Provides syntax for pure pipes.

  5. implicit final class PurePipe2Ops[I, I2, O] extends AnyVal

    Permalink

    Provides operations on pure pipes for syntactic convenience.

  6. implicit final class PurePipeOps[I, O] extends AnyVal

    Permalink

    Provides operations on pure pipes for syntactic convenience.

  7. final class ToEffect[F[_], O] extends AnyVal

    Permalink

    Projection of a Stream providing various ways to compile a Stream[F,O] to an F[...].

  8. final class ToPull[F[_], O] extends AnyVal

    Permalink

    Projection of a Stream providing various ways to get a Pull from the Stream.

Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  4. implicit def EmptyOps(s: Stream[Pure, Nothing]): EmptyOps

    Permalink

    Provides syntax for pure empty pipes.

  5. implicit def InvariantOps[F[_], O](s: Stream[F, O]): InvariantOps[F, O]

    Permalink

    Provides syntax for streams that are invariant in F and O.

  6. implicit def PureOps[O](s: Stream[Pure, O]): PureOps[O]

    Permalink

    Provides syntax for pure pipes.

  7. def apply[O](os: O*): Stream[Pure, O]

    Permalink

    Creates a pure stream that emits the supplied values.

    Creates a pure stream that emits the supplied values. To convert to an effectful stream, use covary.

  8. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  9. def attemptEval[F[_], O](fo: F[O]): Stream[F, Either[Throwable, O]]

    Permalink

    Creates a single element stream that gets its value by evaluating the supplied effect.

    Creates a single element stream that gets its value by evaluating the supplied effect. If the effect fails, a Left is emitted. Otherwise, a Right is emitted.

    Use eval instead if a failure while evaluating the effect should fail the stream.

    Example:
    1. scala> import cats.effect.IO
      scala> Stream.attemptEval(IO(10)).compile.toVector.unsafeRunSync
      res0: Vector[Either[Throwable,Int]] = Vector(Right(10))
      scala> Stream.attemptEval(IO(throw new RuntimeException)).compile.toVector.unsafeRunSync
      res1: Vector[Either[Throwable,Nothing]] = Vector(Left(java.lang.RuntimeException))
  10. def bracket[F[_], R, O](r: F[R])(use: (R) ⇒ Stream[F, O], release: (R) ⇒ F[Unit]): Stream[F, O]

    Permalink

    Creates a stream that depends on a resource allocated by an effect, ensuring the resource is released regardless of how the stream is used.

    Creates a stream that depends on a resource allocated by an effect, ensuring the resource is released regardless of how the stream is used.

    r

    resource to acquire at start of stream

    use

    function which uses the acquired resource to generate a stream of effectful outputs

    release

    function which returns an effect that releases the resource A typical use case for bracket is working with files or network sockets. The resource effect opens a file and returns a reference to it. The use function reads bytes and transforms them in to some stream of elements (e.g., bytes, strings, lines, etc.). The release action closes the file.

  11. def chunk[O](os: Chunk[O]): Stream[Pure, O]

    Permalink

    Creates a pure stream that emits the elements of the supplied chunk.

    Creates a pure stream that emits the elements of the supplied chunk.

    Example:
    1. scala> Stream.chunk(Chunk(1,2,3)).toList
      res0: List[Int] = List(1, 2, 3)
  12. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  13. def constant[O](o: O, segmentSize: Int = 256): Stream[Pure, O]

    Permalink

    Creates an infinite pure stream that always returns the supplied value.

    Creates an infinite pure stream that always returns the supplied value.

    Elements are emitted in finite segments with segmentSize number of elements.

    Example:
    1. scala> Stream.constant(0).take(5).toList
      res0: List[Int] = List(0, 0, 0, 0, 0)
  14. implicit def covaryPure[F[_], O, O2 >: O](s: Stream[Pure, O]): Stream[F, O2]

    Permalink

    Implicitly covaries a stream.

  15. implicit def covaryPurePipe[F[_], I, O](p: Pipe[Pure, I, O]): Pipe[F, I, O]

    Permalink

    Implicitly covaries a pipe.

  16. implicit def covaryPurePipe2[F[_], I, I2, O](p: Pipe2[Pure, I, I2, O]): Pipe2[F, I, I2, O]

    Permalink

    Implicitly covaries a Pipe2.

  17. def duration[F[_]](implicit F: Sync[F]): Stream[F, FiniteDuration]

    Permalink

    A continuous stream of the elapsed time, computed using System.nanoTime.

    A continuous stream of the elapsed time, computed using System.nanoTime. Note that the actual granularity of these elapsed times depends on the OS, for instance the OS may only update the current time every ten milliseconds or so.

  18. def emit[O](o: O): Stream[Pure, O]

    Permalink

    Creates a singleton pure stream that emits the supplied value.

    Creates a singleton pure stream that emits the supplied value.

    Example:
    1. scala> Stream.emit(0).toList
      res0: List[Int] = List(0)
  19. def emits[O](os: Seq[O]): Stream[Pure, O]

    Permalink

    Creates a pure stream that emits the supplied values.

    Creates a pure stream that emits the supplied values.

    Example:
    1. scala> Stream.emits(List(1, 2, 3)).toList
      res0: List[Int] = List(1, 2, 3)
  20. def empty: Stream[Pure, Nothing]

    Permalink

    Empty pure stream.

  21. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  22. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  23. def eval[F[_], O](fo: F[O]): Stream[F, O]

    Permalink

    Creates a single element stream that gets its value by evaluating the supplied effect.

    Creates a single element stream that gets its value by evaluating the supplied effect. If the effect fails, the returned stream fails.

    Use attemptEval instead if a failure while evaluating the effect should be emitted as a value.

    Example:
    1. scala> import cats.effect.IO
      scala> Stream.eval(IO(10)).compile.toVector.unsafeRunSync
      res0: Vector[Int] = Vector(10)
      scala> Stream.eval(IO(throw new RuntimeException)).compile.toVector.attempt.unsafeRunSync
      res1: Either[Throwable,Vector[Nothing]] = Left(java.lang.RuntimeException)
  24. def eval_[F[_], A](fa: F[A]): Stream[F, Nothing]

    Permalink

    Creates a stream that evaluates the supplied fa for its effect, discarding the output value.

    Creates a stream that evaluates the supplied fa for its effect, discarding the output value. As a result, the returned stream emits no elements and hence has output type Nothing.

    Alias for eval(fa).drain.

    Example:
    1. scala> import cats.effect.IO
      scala> Stream.eval_(IO(println("Ran"))).compile.toVector.unsafeRunSync
      res0: Vector[Nothing] = Vector()
  25. def every[F[_]](d: FiniteDuration): Stream[F, Boolean]

    Permalink

    A continuous stream which is true after d, 2d, 3d... elapsed duration, and false otherwise.

    A continuous stream which is true after d, 2d, 3d... elapsed duration, and false otherwise. If you'd like a 'discrete' stream that will actually block until d has elapsed, use awakeEvery on Scheduler instead.

  26. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  27. def force[F[_], A](f: F[Stream[F, A]]): Stream[F, A]

    Permalink

    Lifts an effect that generates a stream in to a stream.

    Lifts an effect that generates a stream in to a stream. Alias for eval(f).flatMap(_).

    Example:
    1. scala> import cats.effect.IO
      scala> Stream.force(IO(Stream(1,2,3).covary[IO])).compile.toVector.unsafeRunSync
      res0: Vector[Int] = Vector(1, 2, 3)
  28. def fromIterator[F[_], A](iterator: Iterator[A])(implicit F: Sync[F]): Stream[F, A]

    Permalink

    Lifts an iterator into a Stream

  29. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  30. def getScope[F[_]]: Stream[F, Scope[F]]

    Permalink

    Gets the current scope, allowing manual leasing or interruption.

    Gets the current scope, allowing manual leasing or interruption. This is a low-level method and generally should not be used by user code.

  31. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  32. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  33. def iterate[A](start: A)(f: (A) ⇒ A): Stream[Pure, A]

    Permalink

    An infinite Stream that repeatedly applies a given function to a start value.

    An infinite Stream that repeatedly applies a given function to a start value. start is the first value emitted, followed by f(start), then f(f(start)), and so on.

    Example:
    1. scala> Stream.iterate(0)(_ + 1).take(10).toList
      res0: List[Int] = List(0, 1, 2, 3, 4, 5, 6, 7, 8, 9)
  34. def iterateEval[F[_], A](start: A)(f: (A) ⇒ F[A]): Stream[F, A]

    Permalink

    Like iterate, but takes an effectful function for producing the next state.

    Like iterate, but takes an effectful function for producing the next state. start is the first value emitted.

    Example:
    1. scala> import cats.effect.IO
      scala> Stream.iterateEval(0)(i => IO(i + 1)).take(10).compile.toVector.unsafeRunSync
      res0: Vector[Int] = Vector(0, 1, 2, 3, 4, 5, 6, 7, 8, 9)
  35. implicit def monoidInstance[F[_], O]: Monoid[Stream[F, O]]

    Permalink

    Monoid instance for Stream.

  36. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  37. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  38. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  39. def raiseError[O](e: Throwable): Stream[Pure, O]

    Permalink

    Creates a stream that, when run, fails with the supplied exception.

    Creates a stream that, when run, fails with the supplied exception.

    Example:
    1. scala> import scala.util.Try
      scala> Try(Stream.raiseError(new RuntimeException).toList)
      res0: Try[List[Nothing]] = Failure(java.lang.RuntimeException)
      scala> import cats.effect.IO
      scala> Stream.raiseError(new RuntimeException).covary[IO].compile.drain.attempt.unsafeRunSync
      res0: Either[Throwable,Unit] = Left(java.lang.RuntimeException)
  40. def range(start: Int, stopExclusive: Int, by: Int = 1): Stream[Pure, Int]

    Permalink

    Lazily produce the range [start, stopExclusive).

    Lazily produce the range [start, stopExclusive). If you want to produce the sequence in one chunk, instead of lazily, use emits(start until stopExclusive).

    Example:
    1. scala> Stream.range(10, 20, 2).toList
      res0: List[Int] = List(10, 12, 14, 16, 18)
  41. def ranges(start: Int, stopExclusive: Int, size: Int): Stream[Pure, (Int, Int)]

    Permalink

    Lazily produce a sequence of nonoverlapping ranges, where each range contains size integers, assuming the upper bound is exclusive.

    Lazily produce a sequence of nonoverlapping ranges, where each range contains size integers, assuming the upper bound is exclusive. Example: ranges(0, 1000, 10) results in the pairs (0, 10), (10, 20), (20, 30) ... (990, 1000)

    Note: The last emitted range may be truncated at stopExclusive. For instance, ranges(0,5,4) results in (0,4), (4,5).

    Example:
    1. scala> Stream.ranges(0, 20, 5).toList
      res0: List[(Int,Int)] = List((0,5), (5,10), (10,15), (15,20))
    Exceptions thrown

    IllegalArgumentException if size <= 0

  42. def repeatEval[F[_], O](fo: F[O]): Stream[F, O]

    Permalink

    Alias for eval(fo).repeat.

  43. def segment[O](s: Segment[O, Unit]): Stream[Pure, O]

    Permalink

    Creates a pure stream that emits the values of the supplied segment.

    Creates a pure stream that emits the values of the supplied segment.

    Example:
    1. scala> Stream.segment(Segment.from(0)).take(5).toList
      res0: List[Long] = List(0, 1, 2, 3, 4)
  44. def suspend[F[_], O](s: ⇒ Stream[F, O]): Stream[F, O]

    Permalink

    Returns a stream that evaluates the supplied by-name each time the stream is used, allowing use of a mutable value in stream computations.

    Returns a stream that evaluates the supplied by-name each time the stream is used, allowing use of a mutable value in stream computations.

    Note: it's generally easier to reason about such computations using effectful values. That is, allocate the mutable value in an effect and then use Stream.eval(fa).flatMap { a => ??? }.

    Example:
    1. scala> Stream.suspend {
           |   val digest = java.security.MessageDigest.getInstance("SHA-256")
           |   val bytes: Stream[Pure,Byte] = ???
           |   bytes.chunks.fold(digest) { (d,c) => d.update(c.toBytes.values); d }
           | }
  45. implicit def syncInstance[F[_]]: Sync[[β$18$]Stream[F, β$18$]]

    Permalink

    Sync instance for Stream.

    Sync instance for Stream.

    Example:
    1. scala> import cats.implicits._
      scala> import cats.effect.Sync
      scala> implicit def si: Sync[Stream[Pure, ?]] = Stream.syncInstance[Pure]
      scala> Stream(1, -2, 3).fproduct(_.abs).toList
      res0: List[(Int, Int)] = List((1,1), (-2,2), (3,3))
  46. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  47. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  48. def unfold[S, O](s: S)(f: (S) ⇒ Option[(O, S)]): Stream[Pure, O]

    Permalink

    Creates a stream by successively applying f until a None is returned, emitting each output O and using each output S as input to the next invocation of f.

    Creates a stream by successively applying f until a None is returned, emitting each output O and using each output S as input to the next invocation of f.

    Example:
    1. scala> Stream.unfold(0)(i => if (i < 5) Some(i -> (i+1)) else None).toList
      res0: List[Int] = List(0, 1, 2, 3, 4)
  49. def unfoldChunkEval[F[_], S, O](s: S)(f: (S) ⇒ F[Option[(Chunk[O], S)]])(implicit F: Functor[F]): Stream[F, O]

    Permalink

    Alias for unfoldSegmentEval with slightly better type inference when f returns a Chunk.

  50. def unfoldEval[F[_], S, O](s: S)(f: (S) ⇒ F[Option[(O, S)]]): Stream[F, O]

    Permalink

    Like unfold, but takes an effectful function.

  51. def unfoldSegment[S, O](s: S)(f: (S) ⇒ Option[(Segment[O, Unit], S)]): Stream[Pure, O]

    Permalink

    Like unfold but each invocation of f provides a chunk of output.

    Like unfold but each invocation of f provides a chunk of output.

    Example:
    1. scala> Stream.unfoldSegment(0)(i => if (i < 5) Some(Segment.seq(List.fill(i)(i)) -> (i+1)) else None).toList
      res0: List[Int] = List(1, 2, 2, 3, 3, 3, 4, 4, 4, 4)
  52. def unfoldSegmentEval[F[_], S, O](s: S)(f: (S) ⇒ F[Option[(Segment[O, Unit], S)]]): Stream[F, O]

    Permalink

    Like unfoldSegment, but takes an effectful function.

  53. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  54. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  55. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from AnyRef

Inherited from Any

Ungrouped