Outcome

cats.effect.kernel.Outcome
See theOutcome companion object
sealed trait Outcome[F[_], E, A] extends Product, Serializable

Represents the result of the execution of a fiber. It may terminate in one of 3 states:

  1. Succeeded(fa) The fiber completed with a value.

A commonly asked question is why this wraps a value of type F[A] rather than one of type A. This is to support monad transformers. Consider

val oc: OutcomeIO[Int] =
 for {
   fiber <- Spawn[OptionT[IO, *]].start(OptionT.none[IO, Int])
   oc <- fiber.join
 } yield oc

If the fiber succeeds then there is no value of type Int to be wrapped in Succeeded, hence Succeeded contains a value of type OptionT[IO, Int] instead.

In general you can assume that binding on the value of type F[A] contained in Succeeded does not perform further effects. In the case of IO that means that the outcome has been constructed as Outcome.Succeeded(IO.pure(result)).

  1. Errored(e) The fiber exited with an error.

  2. Canceled() The fiber was canceled, either externally or self-canceled via MonadCancel[F]#canceled.

Attributes

Companion
object
Source
Outcome.scala
Graph
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
Known subtypes
class Canceled[F, E, A]
class Errored[F, E, A]
class Succeeded[F, E, A]

Members list

Value members

Concrete methods

def embed(onCancel: F[A])(implicit F: MonadCancel[F, E]): F[A]

Attributes

Source
Outcome.scala
def embedError(implicit F: MonadCancel[F, E], ev: Throwable <:< E): F[A]

Allows the restoration to a normal development flow from an Outcome.

Allows the restoration to a normal development flow from an Outcome.

This can be useful for storing the state of a running computation and then waiters for that data can act and continue forward on that shared outcome. Cancelation is encoded as a CancellationException.

Attributes

Source
Outcome.scala
def embedNever(implicit F: GenSpawn[F, E]): F[A]

Attributes

Source
Outcome.scala
def fold[B](canceled: => B, errored: E => B, completed: F[A] => B): B

Attributes

Source
Outcome.scala

Attributes

Source
Outcome.scala

Attributes

Source
Outcome.scala

Attributes

Source
Outcome.scala
def mapK[G[_]](f: FunctionK[F, G]): Outcome[G, E, A]

Attributes

Source
Outcome.scala

Inherited methods

def canEqual(that: Any): Boolean

Attributes

Inherited from:
Equals

Attributes

Inherited from:
Product
def productElement(n: Int): Any

Attributes

Inherited from:
Product

Attributes

Inherited from:
Product

Attributes

Inherited from:
Product

Attributes

Inherited from:
Product

Attributes

Inherited from:
Product