Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed a paragraph order #1570

Merged
merged 1 commit into from
Mar 25, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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