diff --git a/docs/src/main/tut/typeclasses/monad.md b/docs/src/main/tut/typeclasses/monad.md index 73f6a520531..f3ba9032b1f 100644 --- a/docs/src/main/tut/typeclasses/monad.md +++ b/docs/src/main/tut/typeclasses/monad.md @@ -137,7 +137,13 @@ implicit def optionTMonad[F[_]](implicit F : Monad[F]) = { } } def tailRecM[A, B](a: A)(f: A => OptionT[F, Either[A, B]]): OptionT[F, B] = - defaultTailRecM(a)(f) + OptionT { + F.flatMap(f(a).value) { + case None => F.pure(None) + case Some(Right(b)) => F.pure(Some(b)) + case Some(Left(a2)) => tailRecM(a2)(f).value + } + } } } ```