Skip to content

Comment on Monads, or Programmable Semicolons (2014)parent

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

    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.
AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.