Skip to content

Commit

Permalink
Merge pull request #2291 from Zelenya/bitraverse-update-docs
Browse files Browse the repository at this point in the history
Update Bitraverse docs
  • Loading branch information
ceedubs committed Jun 11, 2018
2 parents 4aafba2 + 339b1f7 commit f439fe0
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions core/src/main/scala/cats/Bitraverse.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,26 @@ import simulacrum.typeclass
*/
@typeclass trait Bitraverse[F[_, _]] extends Bifoldable[F] with Bifunctor[F] { self =>

/** Traverse each side of the structure with the given functions */
/**
* Traverse each side of the structure with the given functions.
*
* Example:
* {{{
* scala> import cats.implicits._
*
* scala> def parseInt(s: String): Option[Int] = Either.catchOnly[NumberFormatException](s.toInt).toOption
*
* scala> ("1", "2").bitraverse(parseInt, parseInt)
* res0: Option[(Int, Int)] = Some((1,2))
*
* scala> ("1", "two").bitraverse(parseInt, parseInt)
* res1: Option[(Int, Int)] = None
* }}}
*/
def bitraverse[G[_]: Applicative, A, B, C, D](fab: F[A, B])(f: A => G[C], g: B => G[D]): G[F[C, D]]

/**
* Sequence each side of the structure with the given functions.
* Invert the structure from F[G[A], G[B]] to G[F[A, B]].
*
* Example:
* {{{
Expand Down

0 comments on commit f439fe0

Please sign in to comment.