Skip to content

Commit

Permalink
Give Functor.fmap a doctest
Browse files Browse the repository at this point in the history
  • Loading branch information
fosskers committed Dec 1, 2017
1 parent 8ac6550 commit d7d347d
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions core/src/main/scala/cats/Functor.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,16 @@ import simulacrum.typeclass
/**
* Alias for [[map]], since [[map]] can't be injected as syntax if
* the implementing type already had a built-in `.map` method.
*
* Example:
* {{{
* scala> import cats.implicits._
*
* scala> val m: Map[Int, String] = Map(1 -> "hi", 2 -> "there", 3 -> "you")
*
* scala> m.fmap(_ ++ "!")
* res0: Map[Int,String] = Map(1 -> hi!, 2 -> there!, 3 -> you!)
* }}}
*/
final def fmap[A, B](fa: F[A])(f: A => B): F[B] = map(fa)(f)

Expand Down

0 comments on commit d7d347d

Please sign in to comment.