mapSuccess

infix inline fun <In : Any, Out : Any, Error : Any> Outcome<In, Error>.mapSuccess(transform: (In) -> Out): 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 flatMapSuccess, mapSuccess's transform lambda returns the monad's internal value directly instead of the Outcome wrapper.

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 Out value.

See also