My Take on Monads in Scala

Page content

Recently I had to explain what a monad is to one of friend. When explaining it I realized that its probably worth writing it as post for my future self or for anyone who asks me about it.

So, what makes a Monad? Bluently put a parameterized trait or a class with 2 functions unit and flatMap.

trait Monade[A] {
    def flatMap[B](f: A => Monade[B]): Monade[B]
}
def unit[A](x: A): Monade[A]

A Monad is an object that wraps another object in scala.