//arrow-core/arrow.core/andThen

andThen

common inline fun <E, A, B> Validated<E, A>.andThen(f: (A) -> Validated<E, B>): Validated<E, B>

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)
}

commonjsjvmnative common expect infix fun <P1, P2, IP, R> (P1, P2) -> IP.andThen(f: (IP) -> R): (P1, P2) -> R

jsjvmnative actual infix fun <P1, P2, IP, R> (P1, P2) -> IP.andThen(f: (IP) -> R): (P1, P2) -> R

common expect infix fun <IP, R> () -> IP.andThen(f: (IP) -> R): () -> R

jsjvmnative actual infix fun <IP, R> () -> IP.andThen(f: (IP) -> R): () -> R

common expect infix fun <P1, IP, R> (P1) -> IP.andThen(f: (IP) -> R): (P1) -> R

jsjvmnative actual infix fun <P1, IP, R> (P1) -> IP.andThen(f: (IP) -> R): (P1) -> R

Do you like Arrow?

Arrow Org
<