rightIfNotNull

inline fun <A, B> B?.rightIfNotNull(default: () -> A): Either<A, B>

Returns Right if the value of type B is not null, otherwise the specified A value wrapped into an Left.

Example:

import arrow.core.rightIfNotNull

fun main() {
"value".rightIfNotNull { "left" } // Right(b="value")
null.rightIfNotNull { "left" } // Left(a="left")
}