Skip to content

Commit

Permalink
Merge pull request #1882 from kailuowang/better-bin
Browse files Browse the repository at this point in the history
convert trait into abstract class for better bin compact
  • Loading branch information
ceedubs authored Sep 8, 2017
2 parents 36ee886 + 3dcddf7 commit f966c0a
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 22 deletions.
6 changes: 3 additions & 3 deletions core/src/main/scala/cats/Eval.scala
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ object Eval extends EvalInstances {
}
}

private[cats] trait EvalInstances extends EvalInstances0 {
private[cats] sealed abstract class EvalInstances extends EvalInstances0 {

implicit val catsBimonadForEval: Bimonad[Eval] =
new Bimonad[Eval] with StackSafeMonad[Eval] {
Expand Down Expand Up @@ -371,7 +371,7 @@ private[cats] trait EvalInstances extends EvalInstances0 {
new EvalGroup[A] { val algebra: Group[A] = Group[A] }
}

private[cats] trait EvalInstances0 extends EvalInstances1 {
private[cats] sealed abstract class EvalInstances0 extends EvalInstances1 {
implicit def catsPartialOrderForEval[A: PartialOrder]: PartialOrder[Eval[A]] =
new PartialOrder[Eval[A]] {
def partialCompare(lx: Eval[A], ly: Eval[A]): Double =
Expand All @@ -382,7 +382,7 @@ private[cats] trait EvalInstances0 extends EvalInstances1 {
new EvalMonoid[A] { val algebra = Monoid[A] }
}

private[cats] trait EvalInstances1 {
private[cats] sealed abstract class EvalInstances1 {
implicit def catsEqForEval[A: Eq]: Eq[Eval[A]] =
new Eq[Eval[A]] {
def eqv(lx: Eval[A], ly: Eval[A]): Boolean =
Expand Down
6 changes: 3 additions & 3 deletions core/src/main/scala/cats/data/NonEmptyList.scala
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ object NonEmptyList extends NonEmptyListInstances {
F.toNonEmptyList(fa)
}

private[data] sealed trait NonEmptyListInstances extends NonEmptyListInstances0 {
private[data] sealed abstract class NonEmptyListInstances extends NonEmptyListInstances0 {

implicit val catsDataInstancesForNonEmptyList: SemigroupK[NonEmptyList] with Reducible[NonEmptyList]
with Comonad[NonEmptyList] with NonEmptyTraverse[NonEmptyList] with Monad[NonEmptyList] =
Expand Down Expand Up @@ -498,14 +498,14 @@ private[data] sealed trait NonEmptyListInstances extends NonEmptyListInstances0
}
}

private[data] sealed trait NonEmptyListInstances0 extends NonEmptyListInstances1 {
private[data] sealed abstract class NonEmptyListInstances0 extends NonEmptyListInstances1 {
implicit def catsDataPartialOrderForNonEmptyList[A](implicit A: PartialOrder[A]): PartialOrder[NonEmptyList[A]] =
new NonEmptyListPartialOrder[A] {
val A0 = A
}
}

private[data] sealed trait NonEmptyListInstances1 {
private[data] sealed abstract class NonEmptyListInstances1 {

implicit def catsDataEqForNonEmptyList[A](implicit A: Eq[A]): Eq[NonEmptyList[A]] =
new NonEmptyListEq[A] {
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/cats/data/NonEmptyVector.scala
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ final class NonEmptyVector[+A] private (val toVector: Vector[A]) extends AnyVal
NonEmptyVector.fromVectorUnsafe((toVector, b.toVector).zipped.map(f))
}

private[data] sealed trait NonEmptyVectorInstances {
private[data] sealed abstract class NonEmptyVectorInstances {

implicit val catsDataInstancesForNonEmptyVector: SemigroupK[NonEmptyVector] with Reducible[NonEmptyVector]
with Comonad[NonEmptyVector] with NonEmptyTraverse[NonEmptyVector] with Monad[NonEmptyVector] =
Expand Down
10 changes: 5 additions & 5 deletions core/src/main/scala/cats/data/OneAnd.scala
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ final case class OneAnd[F[_], A](head: A, tail: F[A]) {
s"OneAnd(${A.show(head)}, ${FA.show(tail)})"
}

private[data] sealed trait OneAndInstances extends OneAndLowPriority3 {
private[data] sealed abstract class OneAndInstances extends OneAndLowPriority3 {

implicit def catsDataEqForOneAnd[A, F[_]](implicit A: Eq[A], FA: Eq[F[A]]): Eq[OneAnd[F, A]] =
new Eq[OneAnd[F, A]]{
Expand Down Expand Up @@ -178,7 +178,7 @@ private[data] sealed trait OneAndInstances extends OneAndLowPriority3 {
}
}

private[data] trait OneAndLowPriority0 {
private[data] sealed abstract class OneAndLowPriority0 {
implicit val catsDataComonadForNonEmptyStream: Comonad[OneAnd[Stream, ?]] =
new Comonad[OneAnd[Stream, ?]] {
def coflatMap[A, B](fa: OneAnd[Stream, A])(f: OneAnd[Stream, A] => B): OneAnd[Stream, B] = {
Expand All @@ -199,7 +199,7 @@ private[data] trait OneAndLowPriority0 {
}
}

private[data] trait OneAndLowPriority1 extends OneAndLowPriority0 {
private[data] sealed abstract class OneAndLowPriority1 extends OneAndLowPriority0 {
implicit def catsDataFunctorForOneAnd[F[_]](implicit F: Functor[F]): Functor[OneAnd[F, ?]] =
new Functor[OneAnd[F, ?]] {
def map[A, B](fa: OneAnd[F, A])(f: A => B): OneAnd[F, B] =
Expand All @@ -208,7 +208,7 @@ private[data] trait OneAndLowPriority1 extends OneAndLowPriority0 {

}

private[data] trait OneAndLowPriority2 extends OneAndLowPriority1 {
private[data] sealed abstract class OneAndLowPriority2 extends OneAndLowPriority1 {
implicit def catsDataTraverseForOneAnd[F[_]](implicit F: Traverse[F]): Traverse[OneAnd[F, ?]] =
new Traverse[OneAnd[F, ?]] {
def traverse[G[_], A, B](fa: OneAnd[F, A])(f: (A) => G[B])(implicit G: Applicative[G]): G[OneAnd[F, B]] = {
Expand All @@ -225,7 +225,7 @@ private[data] trait OneAndLowPriority2 extends OneAndLowPriority1 {
}
}

private[data] trait OneAndLowPriority3 extends OneAndLowPriority2 {
private[data] sealed abstract class OneAndLowPriority3 extends OneAndLowPriority2 {
implicit def catsDataNonEmptyTraverseForOneAnd[F[_]](implicit F: Traverse[F], F2: Alternative[F]): NonEmptyTraverse[OneAnd[F, ?]] =
new NonEmptyReducible[OneAnd[F, ?], F] with NonEmptyTraverse[OneAnd[F, ?]] {
def nonEmptyTraverse[G[_], A, B](fa: OneAnd[F, A])(f: (A) => G[B])(implicit G: Apply[G]): G[OneAnd[F, B]] = {
Expand Down
10 changes: 5 additions & 5 deletions core/src/main/scala/cats/data/OptionT.scala
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ object OptionT extends OptionTInstances {
def liftF[F[_], A](fa: F[A])(implicit F: Functor[F]): OptionT[F, A] = OptionT(F.map(fa)(Some(_)))
}

private[data] sealed trait OptionTInstances extends OptionTInstances0 {
private[data] sealed abstract class OptionTInstances extends OptionTInstances0 {
implicit def catsDataMonadForOptionT[F[_]](implicit F0: Monad[F]): Monad[OptionT[F, ?]] =
new OptionTMonad[F] { implicit val F = F0 }

Expand All @@ -212,7 +212,7 @@ private[data] sealed trait OptionTInstances extends OptionTInstances0 {
functor.Contravariant[Show].contramap(F)(_.value)
}

private[data] sealed trait OptionTInstances0 extends OptionTInstances1 {
private[data] sealed abstract class OptionTInstances0 extends OptionTInstances1 {
implicit def catsDataMonadErrorForOptionT[F[_], E](implicit F0: MonadError[F, E]): MonadError[OptionT[F, ?], E] =
new OptionTMonadError[F, E] { implicit val F = F0 }

Expand All @@ -226,7 +226,7 @@ private[data] sealed trait OptionTInstances0 extends OptionTInstances1 {
new OptionTPartialOrder[F, A] { implicit val F = F0 }
}

private[data] sealed trait OptionTInstances1 extends OptionTInstances2 {
private[data] sealed abstract class OptionTInstances1 extends OptionTInstances2 {

implicit def catsDataMonoidKForOptionT[F[_]](implicit F0: Monad[F]): MonoidK[OptionT[F, ?]] =
new OptionTMonoidK[F] { implicit val F = F0 }
Expand All @@ -235,12 +235,12 @@ private[data] sealed trait OptionTInstances1 extends OptionTInstances2 {
new OptionTEq[F, A] { implicit val F = F0 }
}

private[data] sealed trait OptionTInstances2 extends OptionTInstances3 {
private[data] sealed abstract class OptionTInstances2 extends OptionTInstances3 {
implicit def catsDataTraverseForOptionT[F[_]](implicit F0: Traverse[F]): Traverse[OptionT[F, ?]] =
new OptionTTraverse[F] { implicit val F = F0 }
}

private[data] sealed trait OptionTInstances3 {
private[data] sealed abstract class OptionTInstances3 {
implicit def catsDataFunctorForOptionT[F[_]](implicit F0: Functor[F]): Functor[OptionT[F, ?]] =
new OptionTFunctor[F] { implicit val F = F0 }
}
Expand Down
10 changes: 5 additions & 5 deletions free/src/main/scala/cats/free/FreeT.scala
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ object FreeT extends FreeTInstances {
λ[FunctionK[FreeT[S, M, ?], M]](f => f.foldMap(fk))
}

private[free] sealed trait FreeTInstances extends FreeTInstances0 {
private[free] sealed abstract class FreeTInstances extends FreeTInstances0 {
implicit def catsFreeMonadErrorForFreeT[S[_], M[_], E](implicit E: MonadError[M, E]): MonadError[FreeT[S, M, ?], E] =
new MonadError[FreeT[S, M, ?], E] with FreeTMonad[S, M] {
override def M = E
Expand All @@ -193,29 +193,29 @@ private[free] sealed trait FreeTInstances extends FreeTInstances0 {
}
}

private[free] sealed trait FreeTInstances0 extends FreeTInstances1 {
private[free] sealed abstract class FreeTInstances0 extends FreeTInstances1 {
implicit def catsFreeMonadForFreeT[S[_], M[_]](implicit M0: Applicative[M]): Monad[FreeT[S, M, ?]] =
new FreeTMonad[S, M] {
def M = M0
}
}

private[free] sealed trait FreeTInstances1 extends FreeTInstances2 {
private[free] sealed abstract class FreeTInstances1 extends FreeTInstances2 {
implicit def catsFreeFlatMapForFreeT[S[_], M[_]](implicit M0: Applicative[M]): FlatMap[FreeT[S, M, ?]] =
new FreeTFlatMap[S, M] {
implicit def M: Applicative[M] = M0
}
}

private[free] sealed trait FreeTInstances2 extends FreeTInstances3 {
private[free] sealed abstract class FreeTInstances2 extends FreeTInstances3 {
implicit def catsFreeAlternativeForFreeT[S[_], M[_]: Alternative: Monad]: Alternative[FreeT[S, M, ?]] =
new Alternative[FreeT[S, M, ?]] with FreeTMonad[S, M] with FreeTMonoidK[S, M] {
override def M = Alternative[M]
override def M1 = Alternative[M]
}
}

private[free] sealed trait FreeTInstances3 {
private[free] sealed abstract class FreeTInstances3 {
implicit def catsFreeSemigroupKForFreeT[S[_], M[_]: Applicative: SemigroupK]: SemigroupK[FreeT[S, M, ?]] =
new FreeTSemigroupK[S, M] {
override def M = Applicative[M]
Expand Down

0 comments on commit f966c0a

Please sign in to comment.