Skip to content

Commit

Permalink
Merge pull request #1588 from RawToast/patch-1
Browse files Browse the repository at this point in the history
Docs/Tutorial -- Simplify Kleisli example
  • Loading branch information
adelbertc committed Apr 4, 2017
2 parents 43d205f + 16149ed commit dbe4407
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions docs/src/main/tut/datatypes/kleisli.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ Returning to our earlier example:
// Bring in cats.FlatMap[Option] instance
import cats.implicits._
val parse = Kleisli((s: String) => try { Some(s.toInt) } catch { case _: NumberFormatException => None })
val parse = Kleisli((s: String) => if (s.matches("-?[0-9]+")) Some(s.toInt) else None)
val reciprocal = Kleisli((i: Int) => if (i == 0) None else Some(1.0 / i))
val reciprocal = Kleisli((i: Int) => if (i != 0) Some(1.0 / i) else None)
val parseAndReciprocal = reciprocal.compose(parse)
```
Expand Down

0 comments on commit dbe4407

Please sign in to comment.