The Either monad: we can finally get rid of exceptions

Jessica Kerr recently wrote on the very interesting topic: what the best way to get rid of exceptions and of the mess they introduce into the program flow.
Simply put, she's gently introduced the Either monad in Scala language.
Although I find Scala to be a very advanced OO language with reasonably good FP support, I don't think the code Jessica used in her post can force anybody to change the habitual exception handling flow in favor of the Data Flow. This's why: Scala is too verbose.
But this is not the case in a more advanced functional language like OCaml, Haskell or F#. Let's take a look what the latter can offer:

The code is much more clear because of using the monadic function composition (>=>) and the amazing type inference.
Conclusion: if you do use monands, use their full power.


Popular posts from this blog

Upcoming F# struct tuples: are they always faster?

Computing cryptography hashes: Rust, F#, D and Scala

Composing custom error types in F#