flatMapSuccess

infix inline fun <In : Any, Out : Any, Error : Any> Outcome<In, Error>.flatMapSuccess(transform: (In) -> Outcome<Out, Error>): Outcome<Out, Error>

Returns a new Outcome, after applying transform to the Outcome.Success value.

  • Transforms Outcome<In, Error> into Outcome<Out, Error>.

  • If the receiver Outcome is an Outcome.Failure, the Error is simply re-wrapped to update the Ok type.

  • This function does not provide a RaiseScope, and makes no guarantees about catching, handling, or rethrowing errors! Use andThen or outcomeOf within the transformation lambda for that.

  • Unlike mapSuccess, flatMapSuccess's transform lambda returns the Outcome wrapper directly instead of the monad's internal value.

Receiver

The Outcome<In, Error> to transform.

Return

A new Outcome<Out, Error> with the transformed value.

Parameters

In

The Ok type of the receiver Outcome.

Out

The Ok type of the returned Outcome.

Error

The Error type of Outcome.Failure.

transform

The transform function to convert an In value into an Outcome.

See also