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

Add scaladoc example for Semigroupal.product #2427

Merged
merged 1 commit into from
Aug 28, 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
26 changes: 26 additions & 0 deletions core/src/main/scala/cats/Semigroupal.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,32 @@ import simulacrum.typeclass
* [[Semigroupal]] and [[Functor]] to illustrate this.
*/
@typeclass trait Semigroupal[F[_]] {

/**
* Combine an `F[A]` and an `F[B]` into an `F[(A, B)]` that maintains the effects of both `fa` and `fb`.
*
* Example:
* {{{
* scala> import cats.implicits._
*
* scala> val noneInt: Option[Int] = None
* scala> val some3: Option[Int] = Some(3)
* scala> val noneString: Option[String] = None
* scala> val someFoo: Option[String] = Some("foo")
*
* scala> Semigroupal[Option].product(noneInt, noneString)
* res0: Option[(Int, String)] = None
*
* scala> Semigroupal[Option].product(noneInt, someFoo)
* res1: Option[(Int, String)] = None
*
* scala> Semigroupal[Option].product(some3, noneString)
* res2: Option[(Int, String)] = None
*
* scala> Semigroupal[Option].product(some3, someFoo)
* res3: Option[(Int, String)] = Some((3,foo))
* }}}
*/
def product[A, B](fa: F[A], fb: F[B]): F[(A, B)]
}

Expand Down