Outcome is a type that represents three possible states a result can be in: Present, Absent or Failure. Under the hood it wraps the type
Either<E, Option<A>> and supports the common functions that Eithers and Options support such as
There are three primary constructors:
data class Present<A>(val value: A) : Outcome<Nothing, A>
data class Failure<E>(val error: E) : Outcome<E, Nothing>
object Absent : Outcome<Nothing, Nothing>
or you can use the extension methods thusly:
You can also easily convert an
Either<Option<A>> to an Outcome using
val outcome = "hi".some().right().toOutcome()
There is also a type alias
OutcomeOf<A> which specialises the error side to a
Throwable for your convenience.
Zip allows you to combine two or more
Outcomes easily with a supplied function.