It's worth pointing out that Kotlin has a very powerful monadic abstraction besides nullable: suspend functions, aka coroutines. Arrow KT builds on those to bring you a quasi he notation. They even abuse Kotlins very limited destructuring support (.componentN functions) to bring monadic variable bindings into their syntax. The following is legal Kotlin code
fx {
val (x) = action() // A<B>, where Monad<A>
val y = x + 5 // "pure" function
y
}
The block evaluates to a value of type A<B>. It's going the get even better when Arrow meta is ready for prime time. Arrow is like a neat functional backdoor language hidden inside what seems to be just Java 2.0.
Comments
It's worth pointing out that Kotlin has a very powerful monadic abstraction besides nullable: suspend functions, aka coroutines. Arrow KT builds on those to bring you a quasi he notation. They even abuse Kotlins very limited destructuring support (.componentN functions) to bring monadic variable bindings into their syntax. The following is legal Kotlin code
The block evaluates to a value of type A<B>. It's going the get even better when Arrow meta is ready for prime time. Arrow is like a neat functional backdoor language hidden inside what seems to be just Java 2.0.