diff --git a/core/src/main/scala/cats/Bifoldable.scala b/core/src/main/scala/cats/Bifoldable.scala index 7350c5fe3c..5d7721c06c 100644 --- a/core/src/main/scala/cats/Bifoldable.scala +++ b/core/src/main/scala/cats/Bifoldable.scala @@ -18,7 +18,7 @@ trait Bifoldable[F[_, _]] extends Any with Serializable { self => ) def compose[G[_, _]](implicit ev: Bifoldable[G]): Bifoldable[λ[(α, β) => F[G[α, β], G[α, β]]]] = - new CompositeBifoldable[F, G] { + new ComposedBifoldable[F, G] { val F = self val G = ev } @@ -28,17 +28,17 @@ object Bifoldable { def apply[F[_, _]](implicit F: Bifoldable[F]): Bifoldable[F] = F } -trait CompositeBifoldable[F[_, _], G[_, _]] extends Bifoldable[λ[(α, β) => F[G[α, β], G[α, β]]]] { +private[cats] trait ComposedBifoldable[F[_, _], G[_, _]] extends Bifoldable[λ[(α, β) => F[G[α, β], G[α, β]]]] { implicit def F: Bifoldable[F] implicit def G: Bifoldable[G] - def bifoldLeft[A, B, C](fab: F[G[A, B], G[A, B]], c: C)(f: (C, A) => C, g: (C, B) => C): C = + override def bifoldLeft[A, B, C](fab: F[G[A, B], G[A, B]], c: C)(f: (C, A) => C, g: (C, B) => C): C = F.bifoldLeft(fab, c)( (c: C, gab: G[A, B]) => G.bifoldLeft(gab, c)(f, g), (c: C, gab: G[A, B]) => G.bifoldLeft(gab, c)(f, g) ) - def bifoldRight[A, B, C](fab: F[G[A, B], G[A, B]], c: Eval[C])(f: (A, Eval[C]) => Eval[C], g: (B, Eval[C]) => Eval[C]): Eval[C] = + override def bifoldRight[A, B, C](fab: F[G[A, B], G[A, B]], c: Eval[C])(f: (A, Eval[C]) => Eval[C], g: (B, Eval[C]) => Eval[C]): Eval[C] = F.bifoldRight(fab, c)( (gab: G[A, B], c: Eval[C]) => G.bifoldRight(gab, c)(f, g), (gab: G[A, B], c: Eval[C]) => G.bifoldRight(gab, c)(f, g) diff --git a/core/src/main/scala/cats/Bitraverse.scala b/core/src/main/scala/cats/Bitraverse.scala index 58ceaa7574..61057a6f21 100644 --- a/core/src/main/scala/cats/Bitraverse.scala +++ b/core/src/main/scala/cats/Bitraverse.scala @@ -1,6 +1,6 @@ package cats -import cats.functor.Bifunctor +import cats.functor.{Bifunctor, ComposedBifunctor} /** * A type class abstracting over types that give rise to two independent [[cats.Traverse]]s. @@ -15,7 +15,7 @@ trait Bitraverse[F[_, _]] extends Bifoldable[F] with Bifunctor[F] { self => /** If F and G are both [[cats.Bitraverse]] then so is their composition F[G[_, _], G[_, _]] */ def compose[G[_, _]](implicit ev: Bitraverse[G]): Bitraverse[λ[(α, β) => F[G[α, β], G[α, β]]]] = - new CompositeBitraverse[F, G] { + new ComposedBitraverse[F, G] { val F = self val G = ev } @@ -28,13 +28,14 @@ object Bitraverse { def apply[F[_, _]](implicit F: Bitraverse[F]): Bitraverse[F] = F } -trait CompositeBitraverse[F[_, _], G[_, _]] +private[cats] trait ComposedBitraverse[F[_, _], G[_, _]] extends Bitraverse[λ[(α, β) => F[G[α, β], G[α, β]]]] - with CompositeBifoldable[F, G] { + with ComposedBifoldable[F, G] + with ComposedBifunctor[F,G] { def F: Bitraverse[F] def G: Bitraverse[G] - def bitraverse[H[_]: Applicative, A, B, C, D]( + override def bitraverse[H[_]: Applicative, A, B, C, D]( fab: F[G[A, B], G[A, B]])( f: A => H[C], g: B => H[D] ): H[F[G[C, D], G[C, D]]] = diff --git a/core/src/main/scala/cats/functor/Bifunctor.scala b/core/src/main/scala/cats/functor/Bifunctor.scala index f6072573d5..2b11824677 100644 --- a/core/src/main/scala/cats/functor/Bifunctor.scala +++ b/core/src/main/scala/cats/functor/Bifunctor.scala @@ -26,7 +26,7 @@ trait Bifunctor[F[_, _]] extends Any with Serializable { self => /** The composition of two Bifunctors is itself a Bifunctor */ def compose[G[_, _]](implicit G0: Bifunctor[G]): Bifunctor[λ[(α, β) => F[G[α, β], G[α, β]]]] = - new CompositeBifunctor[F, G] { + new ComposedBifunctor[F, G] { val F = self val G = G0 } @@ -36,12 +36,12 @@ object Bifunctor { def apply[F[_, _]](implicit ev: Bifunctor[F]): Bifunctor[F] = ev } -trait CompositeBifunctor[F[_, _], G[_, _]] +private[cats] trait ComposedBifunctor[F[_, _], G[_, _]] extends Bifunctor[λ[(A, B) => F[G[A, B], G[A, B]]]] { def F: Bifunctor[F] def G: Bifunctor[G] - def bimap[A, B, C, D](fab: F[G[A, B], G[A, B]])(f: A => C, g: B => D): F[G[C, D], G[C, D]] = { + override def bimap[A, B, C, D](fab: F[G[A, B], G[A, B]])(f: A => C, g: B => D): F[G[C, D], G[C, D]] = { val innerBimap: G[A, B] => G[C, D] = gab => G.bimap(gab)(f, g) F.bimap(fab)(innerBimap, innerBimap) }