What happens if we mix together Kotlin and Arrow?
The answer is simple: Alchemy.
In this talk, I will deepen the alchemy between Kotlin and Arrow, by taking a procedural program and incrementally refactor to a purely functional one.
or in an exception if something has gone wrong. Two possible implementations: • operation has been successful → Success<A> • computation has failed with a Throwable → Failure https://arrow-kt.io/docs/apidocs/arrow-core-data/arrow.core/-try/
in some order and build a return value. inline fun <B> fold(ifFailure: (Throwable) -> B, ifSuccess: (A) -> B): B = when (this) { is Failure -> ifFailure(exception) is Success -> ifSuccess(value) } https://arrow-kt.io/docs/apidocs/arrow-core-data/arrow.core/-try/fold.html Fold
when (this) { is None -> this is Some -> f(t).fix() } Returns the result of applying f to this option’s value if this option is nonempty. Returns none if this option is empty