fold

inline fun <R> fold(onSuccess: (T) -> R, onError: (E) -> R): R