Skip to content

Commit

Permalink
Add bifold to Bifoldable close typelevel#2947.
Browse files Browse the repository at this point in the history
  • Loading branch information
takayahilton committed Jul 25, 2019
1 parent 3f3c979 commit 1c335d4
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions core/src/main/scala/cats/Bifoldable.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cats

import simulacrum.typeclass
import cats.instances.tuple.catsKernelStdMonoidForTuple2

/**
* A type class abstracting over types that give rise to two independent [[cats.Foldable]]s.
Expand All @@ -20,6 +21,9 @@ import simulacrum.typeclass
(c: C, b: B) => C.combine(c, g(b))
)

def bifold[A: Monoid, B: Monoid](fab: F[A, B]): (A, B) =
bifoldMap(fab)((_, Monoid[B].empty), (Monoid[A].empty, _))

def compose[G[_, _]](implicit ev: Bifoldable[G]): Bifoldable[λ[(α, β) => F[G[α, β], G[α, β]]]] =
new ComposedBifoldable[F, G] {
val F = self
Expand Down

0 comments on commit 1c335d4

Please sign in to comment.