Skip to content

Commit

Permalink
Merge pull request #877 from adelbertc/prod-lazy
Browse files Browse the repository at this point in the history
Remove required laziness in Prod, fixes #615
  • Loading branch information
adelbertc committed May 8, 2016
2 parents 185d0d8 + b194bed commit 1837862
Showing 1 changed file with 4 additions and 15 deletions.
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

0 comments on commit 1837862

Please sign in to comment.