Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Bitraverse docs #2291

Merged
merged 2 commits into from
Jun 11, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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