Represents the result of the execution of a fiber. It may terminate in one of 3 states:
- 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))
.
-
Errored(e) The fiber exited with an error.
-
Canceled() The fiber was canceled, either externally or self-canceled via
MonadCancel[F]#canceled
.
- Companion:
- object
- Source:
- Outcome.scala
Value members
Concrete methods
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
.
- Source:
- Outcome.scala