Failure

data class Failure<A>(val error: Throwable) : Try<A> (source)

A failed result holding the thrown error.

Constructors

Link copied to clipboard
constructor(error: Throwable)

Properties

Link copied to clipboard

Functions

Link copied to clipboard
infix fun <B> ap(f: K1<Try.T, (A) -> B>): Try<B>

Applies a wrapped function to the success value.

Link copied to clipboard

Exposes the outcome as an Either inside a Success.

Link copied to clipboard
infix fun <B> bind(f: (A) -> K1<Try.T, B>): Try<B>

Chains a Try-returning function; an exception thrown by f becomes Failure.

Link copied to clipboard
infix fun <B> fmap(f: (A) -> B): Try<B>

Maps the success value; an exception thrown by f becomes Failure.

Link copied to clipboard
fun <B> foldl(initial: B, f: (B, A) -> B): B

Left fold over the success value (zero or one element).

Link copied to clipboard
fun <M : Monoid<*, M>> foldMap(type: Class<M>, f: (A) -> M): M

Maps the success value to a monoid, or returns mzero on failure.

Link copied to clipboard
fun <B> foldr(initial: B, f: (A, B) -> B): B

Right fold over the success value (zero or one element).

Link copied to clipboard
fun getOrElse(v: A): A

Returns the success value, or v on failure.

Link copied to clipboard
infix fun handleError(f: (Throwable) -> A): Try<A>
Link copied to clipboard
infix fun handleErrorWith(f: (Throwable) -> Try<A>): Try<A>

Recovers from Failure with a plain value.

Link copied to clipboard
fun <G, B> traverse(applicative: Applicative<G>, f: (A) -> K1<G, B>): K1<G, K1<Try.T, B>>

Applies an effectful function to the success value and collects the result.