Skip to content

Commit

Permalink
Add Documentation for Applicative coflatMap usage
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristopherDavenport committed Dec 15, 2017
1 parent 7d42367 commit 36b428a
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions core/src/main/scala/cats/Applicative.scala
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,20 @@ object Applicative {
new ArrowApplicative[F, A](F)


/**
* Creates a CoflatMap for an Applicative `F`.
* Cannot be implicit in 1.0 for Binary Compatibility Reasons
*
* Example:
* {{{
* scala> import cats._
* scala> import cats.implicits._
* scala> val fa = Some(3)
* fa: Option[Int] = Some(3)
* scala> Applicative.coflatMap[Option].coflatten(fa)
* res0: Option[Option[Int]] = Some(Some(3))
* }}}
*/
def coflatMap[F[_]](implicit F: Applicative[F]): CoflatMap[F] =
new CoflatMap[F] {
def coflatMap[A, B](fa: F[A])(f: F[A] => B): F[B] = F.pure(f(fa))
Expand Down

0 comments on commit 36b428a

Please sign in to comment.