By Alvin Alexander. Last updated: August 15, 2019
I started to write about what a monad is in Scala, but then I realized I’ve already done that in several places, including my tutorial, What do effect and effectful mean in functional programming. Therefore, I encourage you to read that article for more details, but as a brief introduction, here’s part of what I wrote there:
As I wrote in my book, Functional Programming, Simplified, a slight simplification is to say that in Scala, a monad is any class that implements the
map
andflatMap
methods. Because of the way Scala for-expressions work, implementing those two methods lets instances of that class be chained together in for-expressions (for/yield expressions), which people also refer to as a monadic style.