diff --git a/docs/src/main/tut/datatypes/kleisli.md b/docs/src/main/tut/datatypes/kleisli.md index 7e84123968..ad5108e9c8 100644 --- a/docs/src/main/tut/datatypes/kleisli.md +++ b/docs/src/main/tut/datatypes/kleisli.md @@ -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) ```