From ee45a6979e6112b53fd2334bf881ec03a1185238 Mon Sep 17 00:00:00 2001 From: Ulises Date: Sat, 14 Jan 2023 19:15:18 +0100 Subject: [PATCH 1/4] setting catsTraverseForSeq as a lower priority instance in UnorderedFoldable --- core/src/main/scala/cats/UnorderedFoldable.scala | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/core/src/main/scala/cats/UnorderedFoldable.scala b/core/src/main/scala/cats/UnorderedFoldable.scala index f694b18570..828ea5ead4 100644 --- a/core/src/main/scala/cats/UnorderedFoldable.scala +++ b/core/src/main/scala/cats/UnorderedFoldable.scala @@ -98,9 +98,13 @@ trait UnorderedFoldable[F[_]] extends Serializable { unorderedFoldMap(fa)(a => if (p(a)) 1L else 0L) } +trait LowPriorityImplicits { + implicit def catsTraverseForSeq: Traverse[Seq] = cats.instances.seq.catsStdInstancesForSeq +} + object UnorderedFoldable extends ScalaVersionSpecificTraverseInstances - with cats.instances.NTupleUnorderedFoldableInstances { + with cats.instances.NTupleUnorderedFoldableInstances with LowPriorityImplicits{ private val orEvalMonoid: CommutativeMonoid[Eval[Boolean]] = new CommutativeMonoid[Eval[Boolean]] { val empty: Eval[Boolean] = Eval.False @@ -125,7 +129,6 @@ object UnorderedFoldable implicit def catsNonEmptyTraverseForId: NonEmptyTraverse[Id] = catsInstancesForId implicit def catsTraverseForOption: Traverse[Option] = cats.instances.option.catsStdInstancesForOption implicit def catsTraverseForList: Traverse[List] = cats.instances.list.catsStdInstancesForList - implicit def catsTraverseForSeq: Traverse[Seq] = cats.instances.seq.catsStdInstancesForSeq implicit def catsTraverseForVector: Traverse[Vector] = cats.instances.vector.catsStdInstancesForVector implicit def catsTraverseForQueue: Traverse[Queue] = cats.instances.queue.catsStdInstancesForQueue implicit def catsUnorderedTraverseForSet: UnorderedTraverse[Set] = cats.instances.set.catsStdInstancesForSet From e7419018c2f9dd39836f6a20c3b48bc2f7739bc3 Mon Sep 17 00:00:00 2001 From: Ulises Torrella Date: Sat, 14 Jan 2023 19:37:54 +0100 Subject: [PATCH 2/4] making the lowpriorityimplicits trait private Co-authored-by: Arman Bilge --- core/src/main/scala/cats/UnorderedFoldable.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/main/scala/cats/UnorderedFoldable.scala b/core/src/main/scala/cats/UnorderedFoldable.scala index 828ea5ead4..c72e8e02fb 100644 --- a/core/src/main/scala/cats/UnorderedFoldable.scala +++ b/core/src/main/scala/cats/UnorderedFoldable.scala @@ -98,7 +98,7 @@ trait UnorderedFoldable[F[_]] extends Serializable { unorderedFoldMap(fa)(a => if (p(a)) 1L else 0L) } -trait LowPriorityImplicits { +private trait UnorderedFoldableLowPriority { implicit def catsTraverseForSeq: Traverse[Seq] = cats.instances.seq.catsStdInstancesForSeq } From b33a0a4862746cff93f64b8be8679945a0ed118b Mon Sep 17 00:00:00 2001 From: Ulises Date: Sat, 14 Jan 2023 22:37:57 +0100 Subject: [PATCH 3/4] changing the lowpriority trait from private to protected (it didn't compile as private) --- core/src/main/scala/cats/UnorderedFoldable.scala | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/core/src/main/scala/cats/UnorderedFoldable.scala b/core/src/main/scala/cats/UnorderedFoldable.scala index c72e8e02fb..b94d0d122c 100644 --- a/core/src/main/scala/cats/UnorderedFoldable.scala +++ b/core/src/main/scala/cats/UnorderedFoldable.scala @@ -98,13 +98,14 @@ trait UnorderedFoldable[F[_]] extends Serializable { unorderedFoldMap(fa)(a => if (p(a)) 1L else 0L) } -private trait UnorderedFoldableLowPriority { +protected trait UnorderedFoldableLowPriority { implicit def catsTraverseForSeq: Traverse[Seq] = cats.instances.seq.catsStdInstancesForSeq } object UnorderedFoldable extends ScalaVersionSpecificTraverseInstances - with cats.instances.NTupleUnorderedFoldableInstances with LowPriorityImplicits{ + with cats.instances.NTupleUnorderedFoldableInstances + with UnorderedFoldableLowPriority { private val orEvalMonoid: CommutativeMonoid[Eval[Boolean]] = new CommutativeMonoid[Eval[Boolean]] { val empty: Eval[Boolean] = Eval.False From c70beecbd9c3683618c8c5ce5b7828de8ddc15c2 Mon Sep 17 00:00:00 2001 From: Ulises Date: Sat, 14 Jan 2023 23:42:18 +0100 Subject: [PATCH 4/4] changing the lowpriority trait from protected to private[cats] --- core/src/main/scala/cats/UnorderedFoldable.scala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/src/main/scala/cats/UnorderedFoldable.scala b/core/src/main/scala/cats/UnorderedFoldable.scala index b94d0d122c..1c77840d8d 100644 --- a/core/src/main/scala/cats/UnorderedFoldable.scala +++ b/core/src/main/scala/cats/UnorderedFoldable.scala @@ -98,13 +98,13 @@ trait UnorderedFoldable[F[_]] extends Serializable { unorderedFoldMap(fa)(a => if (p(a)) 1L else 0L) } -protected trait UnorderedFoldableLowPriority { +private[cats] trait UnorderedFoldableLowPriority { implicit def catsTraverseForSeq: Traverse[Seq] = cats.instances.seq.catsStdInstancesForSeq } object UnorderedFoldable extends ScalaVersionSpecificTraverseInstances - with cats.instances.NTupleUnorderedFoldableInstances + with cats.instances.NTupleUnorderedFoldableInstances with UnorderedFoldableLowPriority { private val orEvalMonoid: CommutativeMonoid[Eval[Boolean]] = new CommutativeMonoid[Eval[Boolean]] {