com.github.rs3vans.monadik / Try

Try

sealed class Try<out T : Any>

Types

Failure class Failure : Try<Nothing>
Success class Success<out T : Any> : Try<T>

Properties

exception abstract val exception: Exception
isFailure val isFailure: Boolean
isSuccess val isSuccess: Boolean
value abstract val value: T

Functions

component1 operator fun component1(): T?
component2 operator fun component2(): Exception?
flatMap fun <U : Any> flatMap(transformer: (T) -> Try<U>): Try<U>
fold fun fold(left: (T) -> Unit, right: (Exception) -> Unit): Try<T>
ifFailure fun ifFailure(right: (Exception) -> Unit): Try<T>
ifSuccess fun ifSuccess(left: (T) -> Unit): Try<T>
map fun <U : Any> map(transformer: (T) -> U): Try<U>
not operator fun not(): Boolean
throwIfFailure fun throwIfFailure(): Try<T>
toEither fun toEither(): Either<T, Exception>
toOption fun toOption(): Option<T>

Companion Object Functions

invoke operator fun <T : Any> invoke(t: () -> T): Try<T>

Extension Functions

orElse fun <T : Any> Try<T>.orElse(t: T): T
orElseGet fun <T : Any> Try<T>.orElseGet(t: () -> T): T
recover fun <T : Any> Try<T>.recover(transformer: (Exception) -> T): Try<T>
recoverWith fun <T : Any> Try<T>.recoverWith(transformer: (Exception) -> Try<T>): Try<T>

Inheritors

Failure class Failure : Try<Nothing>
Success class Success<out T : Any> : Try<T>