Compiles this stream in to a value of the target effect type F
and
discards any output values of the stream.
Compiles this stream in to a value of the target effect type F
and
discards any output values of the stream.
To access the output values of the stream, use one of the other compilation methods -- e.g., fold, toVector, etc.
When this method has returned, the stream has not begun execution -- this method simply compiles the stream down to the target effect type.
Compiles this stream in to a value of the target effect type F
by folding
the output values together, starting with the provided init
and combining the
current value with each output value.
Compiles this stream in to a value of the target effect type F
by folding
the output values together, starting with the provided init
and combining the
current value with each output value.
When this method has returned, the stream has not begun execution -- this method simply compiles the stream down to the target effect type.
Like fold but uses the implicitly available Monoid[O]
to combine elements.
Like fold but uses the implicitly available Monoid[O]
to combine elements.
scala> import cats.implicits._, cats.effect.IO scala> Stream(1, 2, 3, 4, 5).covary[IO].compile.foldMonoid.unsafeRunSync res0: Int = 15
Like fold but uses the implicitly available Semigroup[O]
to combine elements.
Like fold but uses the implicitly available Semigroup[O]
to combine elements.
If the stream emits no elements, None
is returned.
scala> import cats.implicits._, cats.effect.IO scala> Stream(1, 2, 3, 4, 5).covary[IO].compile.foldSemigroup.unsafeRunSync res0: Option[Int] = Some(15) scala> Stream.empty.covaryAll[IO,Int].compile.foldSemigroup.unsafeRunSync res1: Option[Int] = None
Compiles this stream in to a value of the target effect type F
,
returning None
if the stream emitted no values and returning the
last value emitted wrapped in Some
if values were emitted.
Compiles this stream in to a value of the target effect type F
,
returning None
if the stream emitted no values and returning the
last value emitted wrapped in Some
if values were emitted.
When this method has returned, the stream has not begun execution -- this method simply compiles the stream down to the target effect type.
scala> import cats.effect.IO scala> Stream.range(0,100).take(5).covary[IO].compile.last.unsafeRunSync res0: Option[Int] = Some(4)
Compiles this stream in to a value of the target effect type F
by logging
the output values to a List
.
Compiles this stream in to a value of the target effect type F
by logging
the output values to a List
.
When this method has returned, the stream has not begun execution -- this method simply compiles the stream down to the target effect type.
scala> import cats.effect.IO scala> Stream.range(0,100).take(5).covary[IO].compile.toList.unsafeRunSync res0: List[Int] = List(0, 1, 2, 3, 4)
Compiles this stream in to a value of the target effect type F
by logging
the output values to a Vector
.
Compiles this stream in to a value of the target effect type F
by logging
the output values to a Vector
.
When this method has returned, the stream has not begun execution -- this method simply compiles the stream down to the target effect type.
scala> import cats.effect.IO scala> Stream.range(0,100).take(5).covary[IO].compile.toVector.unsafeRunSync res0: Vector[Int] = Vector(0, 1, 2, 3, 4)
Projection of a
Stream
providing various ways to compile aStream[F,O]
to anF[...]
.