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

Remove required laziness in Prod, fixes #615 #877

Merged
merged 2 commits into from
May 8, 2016
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: 4 additions & 15 deletions core/src/main/scala/cats/data/Prod.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,10 @@ package data
* [[Prod]] is a product to two independent functor values.
*
* See: [[https://www.cs.ox.ac.uk/jeremy.gibbons/publications/iterator.pdf The Essence of the Iterator Pattern]]
*/
sealed trait Prod[F[_], G[_], A] {
def first: F[A]
def second: G[A]
}
object Prod extends ProdInstances {
def apply[F[_], G[_], A](first0: => F[A], second0: => G[A]): Prod[F, G, A] = new Prod[F, G, A] {
val firstThunk: Eval[F[A]] = Later(first0)
val secondThunk: Eval[G[A]] = Later(second0)
def first: F[A] = firstThunk.value
def second: G[A] = secondThunk.value
}
def unapply[F[_], G[_], A](x: Prod[F, G, A]): Option[(F[A], G[A])] =
Some((x.first, x.second))
}
*/
final case class Prod[F[_], G[_], A](first: F[A], second: G[A])

object Prod extends ProdInstances

private[data] sealed abstract class ProdInstances extends ProdInstances0 {
implicit def prodAlternative[F[_], G[_]](implicit FF: Alternative[F], GG: Alternative[G]): Alternative[Lambda[X => Prod[F, G, X]]] = new ProdAlternative[F, G] {
Expand Down