and Then
inline fun <E, A, B> Validated<E, A>.andThen(f: (A) -> Validated<E, B>): Validated<E, B>
Content copied to clipboard
Apply a function to a Valid value, returning a new Validation that may be valid or invalid
Example:
import arrow.core.Validated
import arrow.core.andThen
fun main() {
Validated.Valid(5).andThen { Validated.Valid(10) } // Result: Valid(10)
Validated.Valid(5).andThen { Validated.Invalid(10) } // Result: Invalid(10)
Validated.Invalid(5).andThen { Validated.Valid(10) } // Result: Invalid(5)
}
Content copied to clipboard