Object/Class

monix.eval

Coeval

Related Docs: class Coeval | package eval

Permalink

object Coeval extends CoevalInstancesLevel0 with Serializable

Coeval builders.

Linear Supertypes
Serializable, Serializable, CoevalInstancesLevel0, Companion, AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Coeval
  2. Serializable
  3. Serializable
  4. CoevalInstancesLevel0
  5. Companion
  6. AnyRef
  7. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Type Members

  1. final case class Always[+A](f: () ⇒ A) extends Coeval[A] with Product with Serializable

    Permalink

    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.

  2. implicit final class DeprecatedExtensions[+A] extends AnyVal with Extensions[A]

    Permalink

    Deprecated operations, described as extension methods.

  3. sealed abstract class Eager[+A] extends Coeval[A] with Product

    Permalink

    The Eager type 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 Eager type 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 as map and flatMap produces Coeval references that are still lazily evaluated.

  4. final case class Error(error: Throwable) extends Eager[Nothing] with Product with Serializable

    Permalink

    Constructs an eager Coeval instance for a result that represents an error.

  5. final case class Now[+A](a: A) extends Eager[A] with Product with Serializable

    Permalink

    Constructs an eager Coeval instance from a strict value that's already known.

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. object Eager extends Serializable

    Permalink
  5. def apply[A](f: ⇒ A): Coeval[A]

    Permalink

    Promotes a non-strict value to a Coeval.

    Promotes a non-strict value to a Coeval.

    Alias of eval.

  6. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  7. implicit def catsMonoid[A](implicit A: Monoid[A]): Monoid[Coeval[A]]

    Permalink

    Given an A type that has a cats.Monoid[A] implementation, then this provides the evidence that Coeval[A] also has a Monoid[Coeval[A]] implementation.

  8. implicit def catsSemigroup[A](implicit A: Semigroup[A]): Semigroup[Coeval[A]]

    Permalink

    Given an A type that has a cats.Semigroup[A] implementation, then this provides the evidence that Coeval[A] also has a Semigroup[Coeval[A]] implementation.

    Given an A type that has a cats.Semigroup[A] implementation, then this provides the evidence that Coeval[A] also has a Semigroup[Coeval[A]] implementation.

    This has a lower-level priority than Coeval.catsMonoid in order to avoid conflicts.

    Definition Classes
    CoevalInstancesLevel0
  9. implicit def catsSync: CatsSyncForCoeval

    Permalink

    Instance of Cats type classes for Coeval, implementing cats.effect.SyncEffect (which implies Applicative, Monad, MonadError, Sync) and cats.CoflatMap.

  10. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  11. def defer[A](fa: ⇒ Coeval[A]): Coeval[A]

    Permalink

    Promote a non-strict value representing a Coeval to a Coeval of the same type.

  12. def delay[A](a: ⇒ A): Coeval[A]

    Permalink

    Alias for eval.

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

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

    Permalink
    Definition Classes
    AnyRef → Any
  15. def eval[A](a: ⇒ A): Coeval[A]

    Permalink

    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 Coeval is not memoized, this will recompute the value each time the Coeval is executed.

  16. def evalOnce[A](a: ⇒ A): Coeval[A]

    Permalink

    Promote a non-strict value to a Coeval that is memoized on the first evaluation, the result being then available on subsequent evaluations.

    Promote a non-strict value to a Coeval that 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.

  17. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  18. def from[F[_], A](fa: F[A])(implicit F: CoevalLike[F]): Coeval[A]

    Permalink

    Converts any value that has a CoevalLike instance into a Coeval.

  19. def fromEither[E, A](f: (E) ⇒ Throwable)(a: Either[E, A]): Coeval[A]

    Permalink

    Converts a Scala Either into a Coeval.

    Converts a Scala Either into a Coeval.

    f

    is a function that knows how to convert into a Throwable in order to throw that error in the MonadError context.

  20. def fromEither[E <: Throwable, A](a: Either[E, A]): Coeval[A]

    Permalink

    Converts a Scala Either into a Coeval.

  21. def fromTry[A](a: Try[A]): Coeval[A]

    Permalink

    Converts a Scala Try into a Coeval.

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

    Permalink
    Definition Classes
    AnyRef → Any
  23. def hashCode(): Int

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

    Permalink
    Definition Classes
    Any
  25. def liftFrom[F[_]](implicit F: CoevalLike[F]): ~>[F, Coeval]

    Permalink

    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 mapK transformations, for example when working with Resource or Iterant:

    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.

  26. def liftTo[F[_]](implicit F: CoevalLift[F]): ~>[Coeval, F]

    Permalink

    Generates Coeval ~> F (FunctionK) values for converting from Coeval to supporting types (for which we have a CoevalLift instance).

    Generates Coeval ~> F (FunctionK) values for converting from Coeval to 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()
      }
    }
  27. def liftToSync[F[_]](implicit F: Sync[F]): ~>[Coeval, F]

    Permalink

    Generates Coeval ~> F function values (FunctionK) for converting from Coeval to types for which we have a cats.effect.Sync instance.

    Generates Coeval ~> F function values (FunctionK) for converting from Coeval to types for which we have a cats.effect.Sync instance.

    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.

    cats.arrow.FunctionK

  28. def map2[A1, A2, R](fa1: Coeval[A1], fa2: Coeval[A2])(f: (A1, A2) ⇒ R): Coeval[R]

    Permalink

    Pairs 2 Coeval values, applying the given mapping function.

    Pairs 2 Coeval values, applying the given mapping function.

    Returns a new Coeval reference 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
    }
  29. def map3[A1, A2, A3, R](fa1: Coeval[A1], fa2: Coeval[A2], fa3: Coeval[A3])(f: (A1, A2, A3) ⇒ R): Coeval[R]

    Permalink

    Pairs 3 Coeval values, applying the given mapping function.

    Pairs 3 Coeval values, applying the given mapping function.

    Returns a new Coeval reference 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
    }
  30. 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]

    Permalink

    Pairs 4 Coeval values, applying the given mapping function.

    Pairs 4 Coeval values, applying the given mapping function.

    Returns a new Coeval reference 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
    }
  31. 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]

    Permalink

    Pairs 5 Coeval values, applying the given mapping function.

    Pairs 5 Coeval values, applying the given mapping function.

    Returns a new Coeval reference 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
    }
  32. 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]

    Permalink

    Pairs 6 Coeval values, applying the given mapping function.

    Pairs 6 Coeval values, applying the given mapping function.

    Returns a new Coeval reference 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
    }
  33. final def ne(arg0: AnyRef): Boolean

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

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

    Permalink
    Definition Classes
    AnyRef
  36. def now[A](a: A): Coeval[A]

    Permalink

    Returns a Coeval that on execution is always successful, emitting the given strict value.

  37. def pure[A](a: A): Coeval[A]

    Permalink

    Lifts a value into the coeval context.

    Lifts a value into the coeval context. Alias for now.

  38. def raiseError[A](ex: Throwable): Coeval[A]

    Permalink

    Returns a Coeval that on execution is always finishing in error emitting the specified exception.

  39. def sequence[A, M[X] <: Iterable[X]](sources: M[Coeval[A]])(implicit bf: BuildFrom[M[Coeval[A]], A, M[A]]): Coeval[M[A]]

    Permalink

    Transforms a Iterable of coevals into a coeval producing the same collection of gathered results.

    Transforms a Iterable of coevals into a coeval producing the same collection of gathered results.

    It's a simple version of traverse.

  40. def suspend[A](fa: ⇒ Coeval[A]): Coeval[A]

    Permalink

    Alias for defer.

  41. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  42. def tailRecM[A, B](a: A)(f: (A) ⇒ Coeval[Either[A, B]]): Coeval[B]

    Permalink

    Keeps calling f until it returns a Right result.

    Keeps calling f until it returns a Right result.

    Based on Phil Freeman's Stack Safety for Free.

  43. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  44. 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]]

    Permalink

    Transforms a Iterable[A] into a coeval of the same collection using the provided function A => Coeval[B].

    Transforms a Iterable[A] into a coeval of the same collection using the provided function A => Coeval[B].

    It's a generalized version of sequence.

  45. val unit: Coeval[Unit]

    Permalink

    A Coeval[Unit] provided for convenience.

  46. final def wait(): Unit

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

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

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  49. def zip2[A1, A2, R](fa1: Coeval[A1], fa2: Coeval[A2]): Coeval[(A1, A2)]

    Permalink

    Pairs two Coeval instances.

  50. def zip3[A1, A2, A3](fa1: Coeval[A1], fa2: Coeval[A2], fa3: Coeval[A3]): Coeval[(A1, A2, A3)]

    Permalink

    Pairs three Coeval instances.

  51. def zip4[A1, A2, A3, A4](fa1: Coeval[A1], fa2: Coeval[A2], fa3: Coeval[A3], fa4: Coeval[A4]): Coeval[(A1, A2, A3, A4)]

    Permalink

    Pairs four Coeval instances.

  52. 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)]

    Permalink

    Pairs five Coeval instances.

  53. 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)]

    Permalink

    Pairs six Coeval instances.

  54. def zipList[A](sources: Coeval[A]*): Coeval[List[A]]

    Permalink

    Zips together multiple Coeval instances.

Deprecated Value Members

  1. def fromEval[A](a: Eval[A]): Coeval[A]

    Permalink

    DEPRECATED — please switch to Coeval.from.

    DEPRECATED — please switch to Coeval.from.

    Definition Classes
    Companion
    Annotations
    @deprecated
    Deprecated

    (Since version 3.0.0-RC3) Switch to Coeval.from

  2. def fromSyncIO[A](a: SyncIO[A]): Coeval[A]

    Permalink

    DEPRECATED — please switch to Coeval.from.

    DEPRECATED — please switch to Coeval.from.

    Definition Classes
    Companion
    Annotations
    @deprecated
    Deprecated

    (Since version 3.0.0-RC3) Switch to Coeval.from

Inherited from Serializable

Inherited from Serializable

Inherited from CoevalInstancesLevel0

Inherited from Companion

Inherited from AnyRef

Inherited from Any

Ungrouped