final class ToEffect[F[_], O] extends AnyVal
Projection of a Stream
providing various ways to compile a Stream[F,O]
to an F[...]
.
- Source
- Stream.scala
- Alphabetic
- By Inheritance
- ToEffect
- AnyVal
- Any
- by any2stringadd
- by StringFormat
- by Ensuring
- by ArrowAssoc
- Hide All
- Show All
- Public
- All
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- Any
-
final
def
##(): Int
- Definition Classes
- Any
- def +(other: String): String
- def ->[B](y: B): (ToEffect[F, O], B)
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- Any
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
drain(implicit F: Sync[F]): F[Unit]
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.
- def ensuring(cond: (ToEffect[F, O]) ⇒ Boolean, msg: ⇒ Any): ToEffect[F, O]
- def ensuring(cond: (ToEffect[F, O]) ⇒ Boolean): ToEffect[F, O]
- def ensuring(cond: Boolean, msg: ⇒ Any): ToEffect[F, O]
- def ensuring(cond: Boolean): ToEffect[F, O]
-
def
fold[B](init: B)(f: (B, O) ⇒ B)(implicit F: Sync[F]): F[B]
Compiles this stream in to a value of the target effect type
F
by folding the output values together, starting with the providedinit
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 providedinit
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.
-
def
foldMonoid(implicit F: Sync[F], O: Monoid[O]): F[O]
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
Example: -
def
foldSemigroup(implicit F: Sync[F], O: Semigroup[O]): F[Option[O]]
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
Example: - def formatted(fmtstr: String): String
-
def
getClass(): Class[_ <: AnyVal]
- Definition Classes
- AnyVal → Any
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
def
last(implicit F: Sync[F]): F[Option[O]]
Compiles this stream in to a value of the target effect type
F
, returningNone
if the stream emitted no values and returning the last value emitted wrapped inSome
if values were emitted.Compiles this stream in to a value of the target effect type
F
, returningNone
if the stream emitted no values and returning the last value emitted wrapped inSome
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)
Example: -
def
toList(implicit F: Sync[F]): F[List[O]]
Compiles this stream in to a value of the target effect type
F
by logging the output values to aList
.Compiles this stream in to a value of the target effect type
F
by logging the output values to aList
.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)
Example: -
def
toString(): String
- Definition Classes
- Any
-
def
toVector(implicit F: Sync[F]): F[Vector[O]]
Compiles this stream in to a value of the target effect type
F
by logging the output values to aVector
.Compiles this stream in to a value of the target effect type
F
by logging the output values to aVector
.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)
Example: - def →[B](y: B): (ToEffect[F, O], B)