Skip to content

Commit d7d347d

Browse files
committed
Give Functor.fmap a doctest
1 parent 8ac6550 commit d7d347d

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

core/src/main/scala/cats/Functor.scala

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,16 @@ import simulacrum.typeclass
1919
/**
2020
* Alias for [[map]], since [[map]] can't be injected as syntax if
2121
* the implementing type already had a built-in `.map` method.
22+
*
23+
* Example:
24+
* {{{
25+
* scala> import cats.implicits._
26+
*
27+
* scala> val m: Map[Int, String] = Map(1 -> "hi", 2 -> "there", 3 -> "you")
28+
*
29+
* scala> m.fmap(_ ++ "!")
30+
* res0: Map[Int,String] = Map(1 -> hi!, 2 -> there!, 3 -> you!)
31+
* }}}
2232
*/
2333
final def fmap[A, B](fa: F[A])(f: A => B): F[B] = map(fa)(f)
2434

0 commit comments

Comments
 (0)