Advertisement
Guest User

Untitled

a guest
Jul 14th, 2014
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scala 0.58 KB | None | 0 0
  1.   /** The coproduct of two functors annihilates their product. */
  2.   implicit def coproductProductZap[F[_], FF[_], G[_], GG[_]](implicit d1: Zap[FF, F], d2: Zap[GG, G]):
  3.     Zap[({ type λ[α] = (FF[α], GG[α]) })#λ, ({ type λ[α] = (F[α] \/ G[α]) })#λ] =
  4.       new Zap[({ type λ[α] = (FF[α], GG[α]) })#λ, ({ type λ[α] = (F[α] \/ G[α]) })#λ] {
  5.         def zapWith[A, B, C](a: (FF[A], GG[A]), b: (F[B] \/ G[B]))(f: (A, B) => C) =
  6.           b match {
  7.             case -\/(fb) => d1.zapWith(a._1, fb)(f)
  8.             case \/-(gb) => d2.zapWith(a._2, gb)(f)
  9.           }
  10.       }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement