redeemWith

inline fun <A, B, C, D> Either<A, B>.redeemWith(fa: (A) -> Either<C, D>, fb: (B) -> Either<C, D>): Either<C, D>
inline fun <A, B> Option<A>.redeemWith(fe: (Unit) -> Option<B>, fb: (A) -> Option<B>): Option<B>


inline fun <A, B> <ERROR CLASS><A>.redeemWith(handleErrorWith: (throwable: Throwable) -> <ERROR CLASS><B>, transform: (A) -> <ERROR CLASS><B>): <ERROR CLASS><B>

Compose both:

  • a transform operation on the success value A into B whilst flattening Result.

  • a recovering transform operation on the failure value Throwable whilst flattening Result.

Combining the powers of flatMap and handleErrorWith.