diff --git a/docs/src/main/tut/typeclasses/monad.md b/docs/src/main/tut/typeclasses/monad.md index 6a413a101c..7f49f4ded5 100644 --- a/docs/src/main/tut/typeclasses/monad.md +++ b/docs/src/main/tut/typeclasses/monad.md @@ -60,6 +60,21 @@ implicit def optionMonad(implicit app: Applicative[Option]) = follows this tradition by providing implementations of `flatten` and `map` derived from `flatMap` and `pure`. +Part of the reason for this is that name `flatMap` has special significance in +scala, as for-comprehensions rely on this method to chain together operations +in a monadic context. + +```tut:book +import scala.reflect.runtime.universe + +universe.reify( + for { + x <- Some(1) + y <- Some(2) + } yield x + y +).tree +``` + In addition to requiring `flatMap` and `pure`, Cats has chosen to require `tailRecM` which encodes stack safe monadic recursion, as described in [Stack Safety for Free](http://functorial.com/stack-safety-for-free/index.pdf) by @@ -87,20 +102,7 @@ implicit val optionMonad = new Monad[Option] { } ``` -Part of the reason for this is that name `flatMap` has special significance in -scala, as for-comprehensions rely on this method to chain together operations -in a monadic context. - -```tut:book -import scala.reflect.runtime.universe -universe.reify( - for { - x <- Some(1) - y <- Some(2) - } yield x + y -).tree -``` ### ifM