outcome
0.3.2indexedAlternative to the Result type, enabling typed error handling. Supports operations like `getOrElse`, `map`, and `flatMap` for enhanced error management and control flow.
0
Stars
—
Used by
dependents
—
Health
/ 100
Alternative to the Result type, enabling typed error handling. Supports operations like `getOrElse`, `map`, and `flatMap` for enhanced error management and control flow.
Outcome is an alternative to Kotlin's Result type that lets you add types to your errors.
fun main() {
val coinFace = flipCoin().getOrElse {
when (error) {
FlipCoinError.CoinBroke -> changeGame()
FlipCoinError.CoinExploded -> cleanup()
}
return
}
println("Flipped ${coinFace.name}")
}
fun flipCoin(): Outcome<CoinFace, FlipCoinError>
enum class FlipCoinError {
CoinBroke,
CoinExploded,
}
See Sample.kt for a more concrete example.
Please refer to Map.kt and FlatMap.kt to see the available functions.
Surfaced from shared tags and platforms — no rankings paid for.