Skip to content

Commit 402cf9b

Browse files
committed
Fixed Cats monad example
Signed-off-by: Konstantin Läufer <laufer@cs.luc.edu>
1 parent 53114e5 commit 402cf9b

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

source/40-functional.rst

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1175,10 +1175,9 @@ The Scala standard library does not define a unified ``Monad`` abstraction — i
11751175
b <- fb
11761176
yield a + b
11771177
1178-
addIfPresent(Some(3), Some(4)) // Some(7)
1179-
addIfPresent(Some(3), None) // None
1180-
addIfPresent(List(1, 2), List(10, 20))
1181-
// List(11, 21, 12, 22) — all combinations (nondeterminism)
1178+
addIfPresent(Option(3), Option(4)) // Some(7)
1179+
addIfPresent(Option(3), None) // None
1180+
addIfPresent(List(1, 2), List(10, 20)) // List(11, 21, 12, 22) — all combinations (nondeterminism)
11821181
11831182
The ``[F[_]: Monad]`` context bound makes ``addIfPresent`` work for *any* monad — ``Option``, ``List``, ``Either``, ``Future``, or a custom type — without changing the implementation.
11841183

0 commit comments

Comments
 (0)