Skip to content

Commit

Permalink
fixed a paragraph order (#1570)
Browse files Browse the repository at this point in the history
  • Loading branch information
kailuowang authored Mar 25, 2017
1 parent ec623e4 commit 18c906b
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions docs/src/main/tut/typeclasses/monad.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 18c906b

Please sign in to comment.