Skip to content

Commit

Permalink
Minimizing typeclass surface in cats-kernel (#1997)
Browse files Browse the repository at this point in the history
* Moved Eq/PartialOrder/Order.on implementation to companion object.

* Moved Eq.and/or, Order.whenEqual, Order/PartialOrder.reverse implementations to companion

* Added missing Scaladoc.

* Removed extra methods on the kernel typeclasses.

* Corrected usage of Eq.on

* Removed outdated comment on the implementation of Hash.on

* Removed whitespace at the end of line.

* More missed replacements.

* Registering binary compatibility changes.

* Fixes to laws.

* Migrated SortedSetSuite.
  • Loading branch information
denisrosset authored and kailuowang committed Oct 31, 2017
1 parent 4687568 commit af7354c
Show file tree
Hide file tree
Showing 18 changed files with 240 additions and 125 deletions.
141 changes: 140 additions & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,146 @@ val binaryCompatibleExceptions = {
exclude[InheritedNewAbstractMethodProblem]("cats.kernel.instances.QueueInstances.*"),
exclude[InheritedNewAbstractMethodProblem]("cats.kernel.instances.QueueInstances1.*"),
exclude[InheritedNewAbstractMethodProblem]("cats.kernel.instances.QueueInstances2.*"),
exclude[InheritedNewAbstractMethodProblem]("cats.kernel.instances.DurationInstances.*")
exclude[InheritedNewAbstractMethodProblem]("cats.kernel.instances.DurationInstances.*"),
exclude[DirectMissingMethodProblem]("cats.kernel.Eq*.or"),
exclude[DirectMissingMethodProblem]("cats.kernel.Eq*.and"),
exclude[DirectMissingMethodProblem]("cats.kernel.Eq*.on"),
exclude[DirectMissingMethodProblem]("cats.kernel.PartialOrder*.or"),
exclude[DirectMissingMethodProblem]("cats.kernel.PartialOrder*.and"),
exclude[DirectMissingMethodProblem]("cats.kernel.PartialOrder*.on"),
exclude[DirectMissingMethodProblem]("cats.kernel.PartialOrder*.reverse"),
exclude[DirectMissingMethodProblem]("cats.kernel.Order*.or"),
exclude[DirectMissingMethodProblem]("cats.kernel.Order*.and"),
exclude[DirectMissingMethodProblem]("cats.kernel.Order*.on"),
exclude[DirectMissingMethodProblem]("cats.kernel.Order*.reverse"),
exclude[DirectMissingMethodProblem]("cats.kernel.Order*.whenEqual"),
exclude[DirectMissingMethodProblem]("cats.kernel.Hash*.or"),
exclude[DirectMissingMethodProblem]("cats.kernel.Hash*.and"),
exclude[DirectMissingMethodProblem]("cats.kernel.Hash*.on"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.BooleanOrder.or"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.BooleanOrder.and"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.BooleanOrder.on"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.BooleanOrder.reverse"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.BooleanOrder.whenEqual"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.SymbolOrder.or"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.SymbolOrder.and"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.SymbolOrder.on"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.SymbolOrder.reverse"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.SymbolOrder.whenEqual"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.StreamOrder.or"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.StreamOrder.and"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.StreamOrder.on"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.StreamOrder.reverse"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.StreamOrder.whenEqual"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.OptionEq.or"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.OptionEq.and"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.OptionEq.on"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.BigDecimalOrder.or"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.BigDecimalOrder.and"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.BigDecimalOrder.on"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.BigDecimalOrder.reverse"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.BigDecimalOrder.whenEqual"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.CharOrder.or"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.CharOrder.and"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.CharOrder.on"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.CharOrder.reverse"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.CharOrder.whenEqual"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.ListOrder.or"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.ListOrder.and"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.ListOrder.on"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.ListOrder.reverse"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.ListOrder.whenEqual"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.LongOrder.or"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.LongOrder.and"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.LongOrder.on"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.LongOrder.reverse"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.LongOrder.whenEqual"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.VectorEq.or"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.VectorEq.and"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.VectorEq.on"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.StreamPartialOrder*.or"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.StreamPartialOrder*.and"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.StreamPartialOrder*.on"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.StreamPartialOrder*.reverse"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.BigIntOrder.or"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.BigIntOrder.and"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.BigIntOrder.on"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.BigIntOrder.reverse"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.BigIntOrder.whenEqual"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.DoubleOrder.or"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.DoubleOrder.and"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.DoubleOrder.on"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.DoubleOrder.reverse"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.DoubleOrder.whenEqual"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.BitSetPartialOrder*.or"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.BitSetPartialOrder*.and"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.BitSetPartialOrder*.on"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.BitSetPartialOrder*.reverse"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.UnitOrder.or"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.UnitOrder.and"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.UnitOrder.on"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.UnitOrder.reverse"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.UnitOrder.whenEqual"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.OptionPartialOrder*.or"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.OptionPartialOrder*.and"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.OptionPartialOrder*.on"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.OptionPartialOrder*.reverse"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.VectorPartialOrder*.or"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.VectorPartialOrder*.and"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.VectorPartialOrder*.on"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.VectorPartialOrder*.reverse"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.ListPartialOrder*.or"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.ListPartialOrder*.and"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.ListPartialOrder*.on"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.ListPartialOrder*.reverse"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.SetPartialOrder*.or"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.SetPartialOrder*.and"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.SetPartialOrder*.on"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.SetPartialOrder*.reverse"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.MapEq.or"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.MapEq.and"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.MapEq.on"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.VectorOrder.or"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.VectorOrder.and"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.VectorOrder.on"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.VectorOrder.reverse"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.VectorOrder.whenEqual"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.FloatOrder.or"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.FloatOrder.and"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.FloatOrder.on"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.FloatOrder.reverse"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.FloatOrder.whenEqual"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.StreamEq.or"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.StreamEq.and"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.StreamEq.on"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.IntOrder.or"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.IntOrder.and"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.IntOrder.on"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.IntOrder.reverse"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.IntOrder.whenEqual"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.ListEq.or"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.ListEq.and"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.ListEq.on"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.ByteOrder.or"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.ByteOrder.and"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.ByteOrder.on"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.ByteOrder.reverse"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.ByteOrder.whenEqual"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.ShortOrder.or"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.ShortOrder.and"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.ShortOrder.on"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.ShortOrder.reverse"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.ShortOrder.whenEqual"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.StringOrder.or"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.StringOrder.and"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.StringOrder.on"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.StringOrder.reverse"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.StringOrder.whenEqual"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.OptionOrder.or"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.OptionOrder.and"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.OptionOrder.on"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.OptionOrder.reverse"),
exclude[DirectMissingMethodProblem]("cats.kernel.instances.OptionOrder.whenEqual")
)
}

Expand Down
4 changes: 2 additions & 2 deletions core/src/main/scala/cats/data/IdT.scala
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ private[data] sealed abstract class IdTInstances0 extends IdTInstances1 {
new IdTTraverse[F] { implicit val F0: Traverse[F] = F }

implicit def catsDataEqForIdT[F[_], A](implicit F: Eq[F[A]]): Eq[IdT[F, A]] =
F.on(_.value)
Eq.by[IdT[F, A], F[A]](_.value)
}

private[data] sealed abstract class IdTInstances extends IdTInstances0 {
Expand All @@ -160,7 +160,7 @@ private[data] sealed abstract class IdTInstances extends IdTInstances0 {
new IdTNonEmptyTraverse[F] { implicit val F0: NonEmptyTraverse[F] = F }

implicit def catsDataOrderForIdT[F[_], A](implicit F: Order[F[A]]): Order[IdT[F, A]] =
F.on(_.value)
Order.by[IdT[F, A], F[A]](_.value)

implicit def catsDataShowForIdT[F[_], A](implicit F: Show[F[A]]): Show[IdT[F, A]] =
Contravariant[Show].contramap(F)(_.value)
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/cats/data/Nested.scala
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ object Nested extends NestedInstances

private[data] sealed abstract class NestedInstances extends NestedInstances0 {
implicit def catsDataEqForNested[F[_], G[_], A](implicit FGA: Eq[F[G[A]]]): Eq[Nested[F, G, A]] =
FGA.on(_.value)
Eq.by[Nested[F, G, A], F[G[A]]](_.value)

implicit def catsDataNonEmptyTraverseForNested[F[_]: NonEmptyTraverse, G[_]: NonEmptyTraverse]: NonEmptyTraverse[Nested[F, G, ?]] =
new NestedNonEmptyTraverse[F, G] {
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/cats/data/WriterT.scala
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ private[data] sealed abstract class WriterTInstances1 extends WriterTInstances2
catsDataMonadForWriterT[Id, L]

implicit def catsDataEqForWriterT[F[_], L, V](implicit F: Eq[F[(L, V)]]): Eq[WriterT[F, L, V]] =
F.on(_.run)
Eq.by[WriterT[F, L, V], F[(L, V)]](_.run)

implicit def catsDataSemigroupForWriterTId[L:Semigroup, V:Semigroup]: Semigroup[WriterT[Id, L, V]] =
catsDataSemigroupForWriterT[Id, L, V]
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/scala/cats/instances/eq.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ package instances
trait EqInstances {
implicit val catsContravariantSemigroupalForEq: ContravariantSemigroupal[Eq] =
new ContravariantSemigroupal[Eq] {
def contramap[A, B](fa: Eq[A])(fn: B => A): Eq[B] =
fa.on(fn)
def contramap[A, B](fa: Eq[A])(fn: B => A): Eq[B] = Eq.by[B, A](fn)(fa)

def product[A, B](fa: Eq[A], fb: Eq[B]): Eq[(A, B)] =
Eq.instance { (left, right) => fa.eqv(left._1, right._1) && fb.eqv(left._2, right._2) }
}
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/cats/instances/order.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ trait OrderInstances extends cats.kernel.OrderToOrderingConversion {
*
* Note: resulting instances are law-abiding only when the functions used are injective (represent a one-to-one mapping)
*/
def contramap[A, B](fa: Order[A])(f: B => A): Order[B] = fa.on(f)
def contramap[A, B](fa: Order[A])(f: B => A): Order[B] = Order.by[B, A](f)(fa)

def product[A, B](fa: Order[A], fb: Order[B]): Order[(A, B)] =
new Order[(A, B)] {
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/cats/instances/partialOrder.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ trait PartialOrderInstances {
*
* Note: resulting instances are law-abiding only when the functions used are injective (represent a one-to-one mapping)
*/
def contramap[A, B](fa: PartialOrder[A])(f: B => A): PartialOrder[B] = fa.on(f)
def contramap[A, B](fa: PartialOrder[A])(f: B => A): PartialOrder[B] = PartialOrder.by[B, A](f)(fa)

def product[A, B](fa: PartialOrder[A], fb: PartialOrder[B]): PartialOrder[(A, B)] =
new PartialOrder[(A, B)] {
Expand Down
2 changes: 1 addition & 1 deletion js/src/test/scala/cats/tests/FutureTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class FutureTests extends CatsSuite {
}

implicit val throwableEq: Eq[Throwable] =
Eq[String].on(_.toString)
Eq.by[Throwable, String](_.toString)

implicit val comonad: Comonad[Future] = futureComonad(timeout)

Expand Down
2 changes: 1 addition & 1 deletion jvm/src/test/scala/cats/tests/FutureSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class FutureSuite extends CatsSuite {
Cogen[Future[A]] { (seed: Seed, t: Future[A]) => Cogen[A].perturb(seed, Await.result(t, timeout)) }

implicit val throwableEq: Eq[Throwable] =
Eq[String].on(_.toString)
Eq.by[Throwable, String](_.toString)

// Need non-fatal Throwables for Future recoverWith/handleError
implicit val nonFatalArbitrary: Arbitrary[Throwable] =
Expand Down
16 changes: 8 additions & 8 deletions kernel-laws/src/test/scala/cats/kernel/laws/LawTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class Tests extends FunSuite with Discipline {

{
// needed for Cogen[Map[...]]
implicit val ohe: Ordering[HasEq[Int]] = Ordering[Int].on(_.a)
implicit val ohe: Ordering[HasEq[Int]] = Ordering.by[HasEq[Int], Int](_.a)
checkAll("Eq[Map[String, HasEq[Int]]]", EqTests[Map[String, HasEq[Int]]].eqv)
}

Expand All @@ -106,8 +106,8 @@ class Tests extends FunSuite with Discipline {
checkAll("Eq[Queue[HasEq[Int]]]", EqTests[Queue[HasEq[Int]]].eqv)

checkAll("PartialOrder[Set[Int]]", PartialOrderTests[Set[Int]].partialOrder)
checkAll("PartialOrder[Set[Int]].reverse", PartialOrderTests(PartialOrder[Set[Int]].reverse).partialOrder)
checkAll("PartialOrder[Set[Int]].reverse.reverse", PartialOrderTests(PartialOrder[Set[Int]].reverse.reverse).partialOrder)
checkAll("PartialOrder.reverse(PartialOrder[Set[Int]])", PartialOrderTests(PartialOrder.reverse(PartialOrder[Set[Int]])).partialOrder)
checkAll("PartialOrder.reverse(PartialOrder.reverse(PartialOrder[Set[Int]]))", PartialOrderTests(PartialOrder.reverse(PartialOrder.reverse(PartialOrder[Set[Int]]))).partialOrder)
checkAll("PartialOrder[Option[HasPartialOrder[Int]]]", PartialOrderTests[Option[HasPartialOrder[Int]]].partialOrder)
checkAll("PartialOrder[List[HasPartialOrder[Int]]]", PartialOrderTests[List[HasPartialOrder[Int]]].partialOrder)
checkAll("PartialOrder[Vector[HasPartialOrder[Int]]]", PartialOrderTests[Vector[HasPartialOrder[Int]]].partialOrder)
Expand Down Expand Up @@ -136,8 +136,8 @@ class Tests extends FunSuite with Discipline {
checkAll("Order[Stream[Int]]", OrderTests[Stream[Int]].order)
checkAll("Order[Queue[Int]]", OrderTests[Queue[Int]].order)
checkAll("fromOrdering[Int]", OrderTests(Order.fromOrdering[Int]).order)
checkAll("Order[Int].reverse", OrderTests(Order[Int].reverse).order)
checkAll("Order[Int].reverse.reverse", OrderTests(Order[Int].reverse.reverse).order)
checkAll("Order.reverse(Order[Int])", OrderTests(Order.reverse(Order[Int])).order)
checkAll("Order.reverse(Order.reverse(Order[Int]))", OrderTests(Order.reverse(Order.reverse(Order[Int]))).order)

checkAll("Monoid[String]", MonoidTests[String].monoid)
checkAll("Monoid[String]", SerializableTests.serializable(Monoid[String]))
Expand Down Expand Up @@ -343,7 +343,7 @@ class Tests extends FunSuite with Discipline {

object HasEq {
implicit def hasEq[A: Eq]: Eq[HasEq[A]] =
Eq[A].on(_.a)
Eq.by(_.a)
implicit def hasEqArbitrary[A: Arbitrary]: Arbitrary[HasEq[A]] =
Arbitrary(arbitrary[A].map(HasEq(_)))
implicit def hasCogen[A: Cogen]: Cogen[HasEq[A]] =
Expand All @@ -354,7 +354,7 @@ class Tests extends FunSuite with Discipline {

object HasPartialOrder {
implicit def hasPartialOrder[A: PartialOrder]: PartialOrder[HasPartialOrder[A]] =
PartialOrder[A].on(_.a)
PartialOrder.by(_.a)
implicit def hasPartialOrderArbitrary[A: Arbitrary]: Arbitrary[HasPartialOrder[A]] =
Arbitrary(arbitrary[A].map(HasPartialOrder(_)))
implicit def hasCogen[A: Cogen]: Cogen[HasPartialOrder[A]] =
Expand All @@ -365,7 +365,7 @@ class Tests extends FunSuite with Discipline {

object HasHash {
implicit def hasHash[A: Hash]: Hash[HasHash[A]] =
Hash.by(_.a) // not Hash[A].on(_.a) because of diamond inheritance problems with Eq
Hash.by(_.a)
implicit def hasHashArbitrary[A: Arbitrary]: Arbitrary[HasHash[A]] =
Arbitrary(arbitrary[A].map(HasHash(_)))
implicit def hasCogen[A: Cogen]: Cogen[HasHash[A]] =
Expand Down
Loading

0 comments on commit af7354c

Please sign in to comment.