object Coeval extends CoevalInstancesLevel0 with Serializable
- Alphabetic
- By Inheritance
- Coeval
- Serializable
- CoevalInstancesLevel0
- CoevalDeprecatedCompanion
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Type Members
- final case class Always[+A](f: () => A) extends Coeval[A] with Product with Serializable
Constructs a lazy Coeval instance.
Constructs a lazy Coeval instance.
This type can be used for "lazy" values. In some sense it is equivalent to using a Function0 value.
- implicit final class DeprecatedExtensions[+A] extends AnyVal with CoevalDeprecatedExtensions[A]
Deprecated operations, described as extension methods.
- sealed abstract class Eager[+A] extends Coeval[A] with Product
The
Eagertype represents a strict, already evaluated result of a Coeval that either resulted in success, wrapped in a Now, or in an error, wrapped in an Error.The
Eagertype represents a strict, already evaluated result of a Coeval that either resulted in success, wrapped in a Now, or in an error, wrapped in an Error.It's the moral equivalent of
scala.util.Try, except that application of functions such asmapandflatMapproduces Coeval references that are still lazily evaluated. - final case class Error(error: Throwable) extends Eager[Nothing] with Product with Serializable
Constructs an eager Coeval instance for a result that represents an error.
- final case class Now[+A](a: A) extends Eager[A] with Product with Serializable
Constructs an eager Coeval instance from a strict value that's already known.
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- def apply[A](f: => A): Coeval[A]
Promotes a non-strict value to a Coeval.
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- implicit def catsMonoid[A](implicit A: Monoid[A]): Monoid[Coeval[A]]
Given an
Atype that has acats.Monoid[A]implementation, then this provides the evidence thatCoeval[A]also has aMonoid[Coeval[A]]implementation. - implicit def catsSemigroup[A](implicit A: Semigroup[A]): Semigroup[Coeval[A]]
Given an
Atype that has acats.Semigroup[A]implementation, then this provides the evidence thatCoeval[A]also has aSemigroup[Coeval[A]]implementation.Given an
Atype that has acats.Semigroup[A]implementation, then this provides the evidence thatCoeval[A]also has aSemigroup[Coeval[A]]implementation.This has a lower-level priority than Coeval.catsMonoid in order to avoid conflicts.
- Definition Classes
- CoevalInstancesLevel0
- implicit def catsSync: CatsSyncForCoeval
Instance of Cats type classes for Coeval, implementing
cats.effect.SyncEffect(which impliesApplicative,Monad,MonadError,Sync) andcats.CoflatMap. - def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native() @HotSpotIntrinsicCandidate()
- def defer[A](fa: => Coeval[A]): Coeval[A]
Promote a non-strict value representing a
Coevalto aCoevalof the same type. - def delay[A](a: => A): Coeval[A]
Alias for eval.
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- def eval[A](a: => A): Coeval[A]
Promote a non-strict value to a
Coeval, catching exceptions in the process.Promote a non-strict value to a
Coeval, catching exceptions in the process.Note that since
Coevalis not memoized, this will recompute the value each time theCoevalis executed. - def evalOnce[A](a: => A): Coeval[A]
Promote a non-strict value to a
Coevalthat is memoized on the first evaluation, the result being then available on subsequent evaluations.Promote a non-strict value to a
Coevalthat is memoized on the first evaluation, the result being then available on subsequent evaluations.Guarantees thread-safe idempotency.
UNSAFE — this operation allocates a shared, mutable reference, which can break in certain cases referential transparency, even if this operation guarantees idempotency (i.e. referential transparency implies idempotency, but idempotency does not imply referential transparency).
The allocation of a mutable reference is known to be a side effect, thus breaking referential transparency, even if calling this method does not trigger the evaluation of side effects suspended by the source.
Use with care. Sometimes it's easier to just keep a shared, memoized reference to some connection, but keep in mind it might be better to pass such a reference around as a parameter.
- def from[F[_], A](fa: F[A])(implicit F: CoevalLike[F]): Coeval[A]
Converts any value that has a CoevalLike instance into a
Coeval. - def fromEither[E, A](f: (E) => Throwable)(a: Either[E, A]): Coeval[A]
Converts a Scala
Eitherinto a Coeval.Converts a Scala
Eitherinto a Coeval.- f
is a function that knows how to convert into a
Throwablein order to throw that error in theMonadErrorcontext.
- def fromEither[E <: Throwable, A](a: Either[E, A]): Coeval[A]
Converts a Scala
Eitherinto a Coeval. - def fromTry[A](a: Try[A]): Coeval[A]
Converts a Scala
Tryinto a Coeval. - final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- def left[A, B](a: A): Coeval[Either[A, B]]
Builds a Coeval of Left
- def liftFrom[F[_]](implicit F: CoevalLike[F]): ~>[F, Coeval]
Returns a
F ~> Coeval(FunctionK) for transforming any supported data-type into Coeval.Returns a
F ~> Coeval(FunctionK) for transforming any supported data-type into Coeval.Useful for
mapKtransformations, for example when working withResourceorIterant:import cats.effect._ import monix.eval._ import java.io._ def open(file: File) = Resource[SyncIO, InputStream](SyncIO { val in = new FileInputStream(file) (in, SyncIO(in.close())) }) // Lifting to a Resource of Coeval val res: Resource[Coeval, InputStream] = open(new File("sample")).mapK(Coeval.liftFrom[SyncIO])
See cats.arrow.FunctionK.
- def liftTo[F[_]](implicit F: CoevalLift[F]): ~>[Coeval, F]
Generates
Coeval ~> F(FunctionK) values for converting fromCoevalto supporting types (for which we have a CoevalLift instance).Generates
Coeval ~> F(FunctionK) values for converting fromCoevalto supporting types (for which we have a CoevalLift instance).See the documentation.
import cats.effect._ import monix.eval._ import java.io._ def open(file: File) = Resource[Coeval, InputStream](Coeval { val in = new FileInputStream(file) (in, Coeval(in.close())) }) // Lifting to a Resource of Task val res: Resource[Task, InputStream] = open(new File("sample")).mapK(Coeval.liftTo[Task]) // This was needed in order to process the resource // with a Task, instead of a Coeval res.use { in => Task { in.read() } }
- def liftToSync[F[_]](implicit F: Sync[F]): ~>[Coeval, F]
Generates
Coeval ~> Ffunction values (FunctionK) for converting fromCoevalto types for which we have acats.effect.Syncinstance.Generates
Coeval ~> Ffunction values (FunctionK) for converting fromCoevalto types for which we have acats.effect.Syncinstance.- See also
cats.effect.Sync Prefer to use liftTo, this alternative is provided in order to force the usage of
cats.effect.Sync, since CoevalLift is lawless.
- def map2[A1, A2, R](fa1: Coeval[A1], fa2: Coeval[A2])(f: (A1, A2) => R): Coeval[R]
Pairs 2
Coevalvalues, applying the given mapping function.Pairs 2
Coevalvalues, applying the given mapping function.Returns a new
Coevalreference that completes with the result of mapping that function to their successful results, or in failure in case either of them fails.val fa1 = Coeval(1) val fa2 = Coeval(2) // Yields Success(3) Coeval.map2(fa1, fa2) { (a, b) => a + b } // Yields Failure(e), because the second arg is a failure Coeval.map2(fa1, Coeval.raiseError[Int](new RuntimeException("boo"))) { (a, b) => a + b }
- def map3[A1, A2, A3, R](fa1: Coeval[A1], fa2: Coeval[A2], fa3: Coeval[A3])(f: (A1, A2, A3) => R): Coeval[R]
Pairs 3
Coevalvalues, applying the given mapping function.Pairs 3
Coevalvalues, applying the given mapping function.Returns a new
Coevalreference that completes with the result of mapping that function to their successful results, or in failure in case either of them fails.val fa1 = Coeval(1) val fa2 = Coeval(2) val fa3 = Coeval(3) // Yields Success(6) Coeval.map3(fa1, fa2, fa3) { (a, b, c) => a + b + c } // Yields Failure(e), because the second arg is a failure Coeval.map3(fa1, Coeval.raiseError[Int](new RuntimeException("boo")), fa3) { (a, b, c) => a + b + c }
- def map4[A1, A2, A3, A4, R](fa1: Coeval[A1], fa2: Coeval[A2], fa3: Coeval[A3], fa4: Coeval[A4])(f: (A1, A2, A3, A4) => R): Coeval[R]
Pairs 4
Coevalvalues, applying the given mapping function.Pairs 4
Coevalvalues, applying the given mapping function.Returns a new
Coevalreference that completes with the result of mapping that function to their successful results, or in failure in case either of them fails.val fa1 = Coeval(1) val fa2 = Coeval(2) val fa3 = Coeval(3) val fa4 = Coeval(4) // Yields Success(10) Coeval.map4(fa1, fa2, fa3, fa4) { (a, b, c, d) => a + b + c + d } // Yields Failure(e), because the second arg is a failure Coeval.map4(fa1, Coeval.raiseError[Int](new RuntimeException("boo")), fa3, fa4) { (a, b, c, d) => a + b + c + d }
- def map5[A1, A2, A3, A4, A5, R](fa1: Coeval[A1], fa2: Coeval[A2], fa3: Coeval[A3], fa4: Coeval[A4], fa5: Coeval[A5])(f: (A1, A2, A3, A4, A5) => R): Coeval[R]
Pairs 5
Coevalvalues, applying the given mapping function.Pairs 5
Coevalvalues, applying the given mapping function.Returns a new
Coevalreference that completes with the result of mapping that function to their successful results, or in failure in case either of them fails.val fa1 = Coeval(1) val fa2 = Coeval(2) val fa3 = Coeval(3) val fa4 = Coeval(4) val fa5 = Coeval(5) // Yields Success(15) Coeval.map5(fa1, fa2, fa3, fa4, fa5) { (a, b, c, d, e) => a + b + c + d + e } // Yields Failure(e), because the second arg is a failure Coeval.map5(fa1, Coeval.raiseError[Int](new RuntimeException("boo")), fa3, fa4, fa5) { (a, b, c, d, e) => a + b + c + d + e }
- def map6[A1, A2, A3, A4, A5, A6, R](fa1: Coeval[A1], fa2: Coeval[A2], fa3: Coeval[A3], fa4: Coeval[A4], fa5: Coeval[A5], fa6: Coeval[A6])(f: (A1, A2, A3, A4, A5, A6) => R): Coeval[R]
Pairs 6
Coevalvalues, applying the given mapping function.Pairs 6
Coevalvalues, applying the given mapping function.Returns a new
Coevalreference that completes with the result of mapping that function to their successful results, or in failure in case either of them fails.val fa1 = Coeval(1) val fa2 = Coeval(2) val fa3 = Coeval(3) val fa4 = Coeval(4) val fa5 = Coeval(5) val fa6 = Coeval(6) // Yields Success(21) Coeval.map6(fa1, fa2, fa3, fa4, fa5, fa6) { (a, b, c, d, e, f) => a + b + c + d + e + f } // Yields Failure(e), because the second arg is a failure Coeval.map6(fa1, Coeval.raiseError[Int](new RuntimeException("boo")), fa3, fa4, fa5, fa6) { (a, b, c, d, e, f) => a + b + c + d + e + f }
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def none[A]: Coeval[Option[A]]
A Coeval of None
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- def now[A](a: A): Coeval[A]
Returns a
Coevalthat on execution is always successful, emitting the given strict value. - def pure[A](a: A): Coeval[A]
Lifts a value into the coeval context.
Lifts a value into the coeval context. Alias for now.
- def raiseError[A](ex: Throwable): Coeval[A]
Returns a
Coevalthat on execution is always finishing in error emitting the specified exception. - def raiseUnless(cond: Boolean)(e: => Throwable): Coeval[Unit]
Returns
raiseErrorwhencondis false, otherwise Coeval.unitReturns
raiseErrorwhencondis false, otherwise Coeval.unitval tooMany = 5 val x: Int = ??? Coeval.raiseUnless(x < tooMany)(new IllegalArgumentException("Too many"))
Example: - def raiseWhen(cond: Boolean)(e: => Throwable): Coeval[Unit]
Returns
raiseErrorwhen thecondis true, otherwiseCoeval.unitReturns
raiseErrorwhen thecondis true, otherwiseCoeval.unitval tooMany = 5 val x: Int = ??? Coeval.raiseWhen(x >= tooMany)(new IllegalArgumentException("Too many"))
Example: - def right[A, B](a: B): Coeval[Either[A, B]]
Builds a Coeval of Right
- def sequence[A, M[X] <: Iterable[X]](sources: M[Coeval[A]])(implicit bf: BuildFrom[M[Coeval[A]], A, M[A]]): Coeval[M[A]]
Transforms a
Iterableof coevals into a coeval producing the same collection of gathered results.Transforms a
Iterableof coevals into a coeval producing the same collection of gathered results.It's a simple version of traverse.
- def some[A](a: A): Coeval[Option[A]]
Builds a Coeval of Some
- def suspend[A](fa: => Coeval[A]): Coeval[A]
Alias for defer.
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def tailRecM[A, B](a: A)(f: (A) => Coeval[Either[A, B]]): Coeval[B]
Keeps calling
funtil it returns aRightresult.Keeps calling
funtil it returns aRightresult.Based on Phil Freeman's Stack Safety for Free.
- def toString(): String
- Definition Classes
- AnyRef → Any
- def traverse[A, B, M[X] <: Iterable[X]](sources: M[A])(f: (A) => Coeval[B])(implicit bf: BuildFrom[M[A], B, M[B]]): Coeval[M[B]]
Transforms a
Iterable[A]into a coeval of the same collection using the provided functionA => Coeval[B].Transforms a
Iterable[A]into a coeval of the same collection using the provided functionA => Coeval[B].It's a generalized version of sequence.
- val unit: Coeval[Unit]
A
Coeval[Unit]provided for convenience. - def unless(cond: Boolean)(action: => Coeval[Unit]): Coeval[Unit]
Returns the given argument if
condis false, otherwiseCoeval.UnitReturns the given argument if
condis false, otherwiseCoeval.Unit- See also
Coeval.when for the inverse
Coeval.raiseWhen for conditionally raising an error
- 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
- @throws(classOf[java.lang.InterruptedException]) @native()
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- def when(cond: Boolean)(action: => Coeval[Unit]): Coeval[Unit]
Returns the given argument if
condis true, otherwiseCoeval.UnitReturns the given argument if
condis true, otherwiseCoeval.Unit- See also
Coeval.unless for the inverse
Coeval.raiseWhen for conditionally raising an error
- def zip2[A1, A2, R](fa1: Coeval[A1], fa2: Coeval[A2]): Coeval[(A1, A2)]
Pairs two Coeval instances.
- def zip3[A1, A2, A3](fa1: Coeval[A1], fa2: Coeval[A2], fa3: Coeval[A3]): Coeval[(A1, A2, A3)]
Pairs three Coeval instances.
- def zip4[A1, A2, A3, A4](fa1: Coeval[A1], fa2: Coeval[A2], fa3: Coeval[A3], fa4: Coeval[A4]): Coeval[(A1, A2, A3, A4)]
Pairs four Coeval instances.
- def zip5[A1, A2, A3, A4, A5](fa1: Coeval[A1], fa2: Coeval[A2], fa3: Coeval[A3], fa4: Coeval[A4], fa5: Coeval[A5]): Coeval[(A1, A2, A3, A4, A5)]
Pairs five Coeval instances.
- def zip6[A1, A2, A3, A4, A5, A6](fa1: Coeval[A1], fa2: Coeval[A2], fa3: Coeval[A3], fa4: Coeval[A4], fa5: Coeval[A5], fa6: Coeval[A6]): Coeval[(A1, A2, A3, A4, A5, A6)]
Pairs six Coeval instances.
- def zipList[A](sources: Coeval[A]*): Coeval[List[A]]
Zips together multiple Coeval instances.
- object Eager extends Serializable
Deprecated Value Members
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable]) @Deprecated
- Deprecated
- def fromEval[A](a: Eval[A]): Coeval[A]
DEPRECATED — please switch to Coeval.from.
DEPRECATED — please switch to Coeval.from.
- Definition Classes
- CoevalDeprecatedCompanion
- Annotations
- @deprecated
- Deprecated
(Since version 3.0.0-RC3) Switch to Coeval.from
- def fromSyncIO[A](a: SyncIO[A]): Coeval[A]
DEPRECATED — please switch to Coeval.from.
DEPRECATED — please switch to Coeval.from.
- Definition Classes
- CoevalDeprecatedCompanion
- Annotations
- @deprecated
- Deprecated
(Since version 3.0.0-RC3) Switch to Coeval.from

This is the API documentation for the Monix library.
Package Overview
monix.execution exposes lower level primitives for dealing with asynchronous execution:
Atomictypes, as alternative tojava.util.concurrent.atomicmonix.catnap exposes pure abstractions built on top of the Cats-Effect type classes:
monix.eval is for dealing with evaluation of results, thus exposing Task and Coeval.
monix.reactive exposes the
Observablepattern:Observableimplementationsmonix.tail exposes Iterant for purely functional pull based streaming:
BatchandBatchCursor, the alternatives to Scala'sIterableandIteratorrespectively that we are using within Iterant's encodingYou can control evaluation with type you choose - be it Task, Coeval, cats.effect.IO or your own as long as you provide correct cats-effect or cats typeclass instance.