Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Order constraints from SortedMap and NonEmptyMap instances #3397

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion core/src/main/scala/cats/Align.scala
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ object Align extends ScalaVersionSpecificAlignInstances {
implicit def catsAlignForOption: Align[Option] = cats.instances.option.catsStdInstancesForOption
implicit def catsAlignForVector: Align[Vector] = cats.instances.vector.catsStdInstancesForVector
implicit def catsAlignForMap[K]: Align[Map[K, *]] = cats.instances.map.catsStdInstancesForMap[K]
implicit def catsAlignForSortedMap[K: Order]: Align[SortedMap[K, *]] =
implicit def catsAlignForSortedMap[K]: Align[SortedMap[K, *]] =
cats.instances.sortedMap.catsStdInstancesForSortedMap[K]
implicit def catsAlignForEither[A]: Align[Either[A, *]] = cats.instances.either.catsStdInstancesForEither[A]

Expand Down
4 changes: 2 additions & 2 deletions core/src/main/scala/cats/FunctorFilter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ object FunctorFilter extends ScalaVersionSpecificTraverseFilterInstances {
implicit def catsTraverseFilterForList: TraverseFilter[List] = cats.instances.list.catsStdTraverseFilterForList
implicit def catsTraverseFilterForVector: TraverseFilter[Vector] =
cats.instances.vector.catsStdTraverseFilterForVector
implicit def catsFunctorFilterForMap[K: Order]: FunctorFilter[Map[K, *]] =
implicit def catsFunctorFilterForMap[K]: FunctorFilter[Map[K, *]] =
cats.instances.map.catsStdFunctorFilterForMap[K]
implicit def catsTraverseFilterForSortedMap[K: Order]: TraverseFilter[SortedMap[K, *]] =
implicit def catsTraverseFilterForSortedMap[K]: TraverseFilter[SortedMap[K, *]] =
cats.instances.sortedMap.catsStdTraverseFilterForSortedMap[K]
implicit def catsTraverseFilterForQueue: TraverseFilter[Queue] =
cats.instances.queue.catsStdTraverseFilterForQueue
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/cats/Invariant.scala
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ object Invariant extends ScalaVersionSpecificInvariantInstances with InvariantIn
implicit def catsMonadForTailRec: Monad[TailRec] = cats.instances.tailRec.catsInstancesForTailRec

implicit def catsFlatMapForMap[K]: FlatMap[Map[K, *]] = cats.instances.map.catsStdInstancesForMap[K]
implicit def catsFlatMapForSortedMap[K: Order]: FlatMap[SortedMap[K, *]] =
implicit def catsFlatMapForSortedMap[K]: FlatMap[SortedMap[K, *]] =
cats.instances.sortedMap.catsStdInstancesForSortedMap[K]
implicit def catsBimonadForFunction0[I]: Bimonad[Function0] = cats.instances.function.catsStdBimonadForFunction0
implicit def catsMonadForFunction1[I]: Monad[I => *] = cats.instances.function.catsStdMonadForFunction1[I]
Expand Down
2 changes: 2 additions & 0 deletions core/src/main/scala/cats/SemigroupK.scala
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ object SemigroupK extends ScalaVersionSpecificMonoidKInstances {
implicit def catsSemigroupKForEither[A]: SemigroupK[Either[A, *]] =
cats.instances.either.catsStdSemigroupKForEither[A]
implicit def catsSemigroupKForSortedSet: SemigroupK[SortedSet] = cats.instances.sortedSet.catsStdInstancesForSortedSet
implicit def catsSemigroupKForSortedMap[K]: SemigroupK[SortedMap[K, *]] =
cats.instances.sortedMap.catsStdSemigroupKForSortedMap[K]
implicit def catsMonoidKForSortedMap[K: Order]: MonoidK[SortedMap[K, *]] =
cats.instances.sortedMap.catsStdMonoidKForSortedMap[K]
implicit def catsMonoidKForEndo: MonoidK[Endo] = cats.instances.function.catsStdMonoidKForFunction1
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/cats/Semigroupal.scala
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ object Semigroupal extends ScalaVersionSpecificSemigroupalInstances with Semigro
cats.instances.either.catsStdInstancesForEither[A]
implicit def catsSemigroupalForSortedSet: Semigroupal[SortedSet] =
cats.instances.sortedSet.catsStdSemigroupalForSortedSet
implicit def catsSemigroupalForSortedMap[K: Order]: Semigroupal[SortedMap[K, *]] =
implicit def catsSemigroupalForSortedMap[K]: Semigroupal[SortedMap[K, *]] =
cats.instances.sortedMap.catsStdInstancesForSortedMap[K]
implicit def catsSemigroupalForFunction1[A]: Semigroupal[A => *] =
cats.instances.function.catsStdMonadForFunction1[A]
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/cats/Show.scala
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ object Show extends ScalaVersionSpecificShowInstances with ShowInstances {
implicit def catsShowForSet[A: Show]: Show[Set[A]] = cats.instances.set.catsStdShowForSet[A]
implicit def catsShowForMap[K: Show, V: Show]: Show[Map[K, V]] = cats.instances.map.catsStdShowForMap[K, V]
implicit def catsShowForSortedSet[A: Show]: Show[SortedSet[A]] = cats.instances.sortedSet.catsStdShowForSortedSet[A]
implicit def catsShowForSortedMap[K: Order: Show, V: Show]: Show[SortedMap[K, V]] =
implicit def catsShowForSortedMap[K: Show, V: Show]: Show[SortedMap[K, V]] =
cats.instances.sortedMap.catsStdShowForSortedMap[K, V]
}

Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/cats/UnorderedFoldable.scala
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ object UnorderedFoldable extends ScalaVersionSpecificTraverseInstances {
implicit def catsTraverseForQueue: Traverse[Queue] = cats.instances.queue.catsStdInstancesForQueue
implicit def catsUnorderedTraverseForSet: UnorderedTraverse[Set] = cats.instances.set.catsStdInstancesForSet
implicit def catsFoldableForSortedSet: Foldable[SortedSet] = cats.instances.sortedSet.catsStdInstancesForSortedSet
implicit def catsTraverseForSortedMap[K: Order]: Traverse[SortedMap[K, *]] =
implicit def catsTraverseForSortedMap[K]: Traverse[SortedMap[K, *]] =
cats.instances.sortedMap.catsStdInstancesForSortedMap[K]

implicit def catsUnorderedTraverseForMap[K]: UnorderedTraverse[Map[K, *]] =
Expand Down
36 changes: 27 additions & 9 deletions core/src/main/scala/cats/data/NonEmptyMapImpl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package cats
package data

import cats.kernel._
import cats.{Always, Apply, Eval, Foldable, Functor, Later, NonEmptyTraverse, Now, SemigroupK, Show}

import scala.collection.immutable._

Expand All @@ -14,13 +13,21 @@ private[data] object NonEmptyMapImpl extends NonEmptyMapInstances with Newtype2
private[data] def unwrap[K, A](m: Type[K, A]): SortedMap[K, A] =
m.asInstanceOf[SortedMap[K, A]]

def fromMap[K: Order, A](as: SortedMap[K, A]): Option[NonEmptyMap[K, A]] =
def fromMap[K, A](as: SortedMap[K, A]): Option[NonEmptyMap[K, A]] =
if (as.nonEmpty) Option(create(as)) else None

def fromMapUnsafe[K: Order, A](m: SortedMap[K, A]): NonEmptyMap[K, A] =
@deprecated("Use fromMap override without Order", "2.2.0-M2")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

super nitpick 😄 , now that M2 is out

Suggested change
@deprecated("Use fromMap override without Order", "2.2.0-M2")
@deprecated("Use fromMap override without Order", "2.2.0-M3")

or if it doesn't make it for the M3 RC1 may be. Here and the others

def fromMap[K, A](as: SortedMap[K, A], orderK: Order[K]): Option[NonEmptyMap[K, A]] =
fromMap(as)

def fromMapUnsafe[K, A](m: SortedMap[K, A]): NonEmptyMap[K, A] =
if (m.nonEmpty) create(m)
else throw new IllegalArgumentException("Cannot create NonEmptyMap from empty map")

@deprecated("Use fromMapUnsafe override without Order", "2.2.0-M2")
def fromMapUnsafe[K, A](m: SortedMap[K, A], orderK: Order[K]): NonEmptyMap[K, A] =
fromMapUnsafe(m)

def apply[K, A](head: (K, A), tail: SortedMap[K, A])(implicit K: Order[K]): NonEmptyMap[K, A] =
create(SortedMap(head)(K.toOrdering) ++ tail)

Expand Down Expand Up @@ -250,7 +257,7 @@ sealed class NonEmptyMapOps[K, A](val value: NonEmptyMap[K, A]) {

sealed abstract private[data] class NonEmptyMapInstances extends NonEmptyMapInstances0 {

implicit def catsDataInstancesForNonEmptyMap[K: Order]
implicit def catsDataInstancesForNonEmptyMap[K]
: SemigroupK[NonEmptyMap[K, *]] with NonEmptyTraverse[NonEmptyMap[K, *]] with Align[NonEmptyMap[K, *]] =
new SemigroupK[NonEmptyMap[K, *]] with NonEmptyTraverse[NonEmptyMap[K, *]] with Align[NonEmptyMap[K, *]] {

Expand Down Expand Up @@ -306,9 +313,19 @@ sealed abstract private[data] class NonEmptyMapInstances extends NonEmptyMapInst
NonEmptyMap.fromMapUnsafe(Align[SortedMap[K, *]].align(fa.toSortedMap, fb.toSortedMap))
}

implicit def catsDataHashForNonEmptyMap[K: Hash: Order, A: Hash]: Hash[NonEmptyMap[K, A]] =
@deprecated("Use catsDataInstancesForNonEmptyMap override without Order", "2.2.0-M2")
implicit def catsDataInstancesForNonEmptyMap[K](
orderK: Order[K]
): SemigroupK[NonEmptyMap[K, *]] with NonEmptyTraverse[NonEmptyMap[K, *]] with Align[NonEmptyMap[K, *]] =
catsDataInstancesForNonEmptyMap[K]

implicit def catsDataHashForNonEmptyMap[K: Hash, A: Hash]: Hash[NonEmptyMap[K, A]] =
Hash[SortedMap[K, A]].asInstanceOf[Hash[NonEmptyMap[K, A]]]

@deprecated("Use catsDataHashForNonEmptyMap override without Order", "2.2.0-M2")
def catsDataHashForNonEmptyMap[K, A](hashK: Hash[K], orderK: Order[K], hashA: Hash[A]): Hash[NonEmptyMap[K, A]] =
catsDataHashForNonEmptyMap(hashK, hashA)

implicit def catsDataShowForNonEmptyMap[K: Show, A: Show]: Show[NonEmptyMap[K, A]] =
Show.show[NonEmptyMap[K, A]](_.show)

Expand All @@ -318,8 +335,9 @@ sealed abstract private[data] class NonEmptyMapInstances extends NonEmptyMapInst
}

sealed abstract private[data] class NonEmptyMapInstances0 {
implicit def catsDataEqForNonEmptyMap[K: Order, A: Eq]: Eq[NonEmptyMap[K, A]] =
new Eq[NonEmptyMap[K, A]] {
def eqv(x: NonEmptyMap[K, A], y: NonEmptyMap[K, A]): Boolean = x === y
}
implicit def catsDataEqForNonEmptyMap[K, A: Eq]: Eq[NonEmptyMap[K, A]] = _ === _

@deprecated("Use catsDataEqForNonEmptyMap override without Order", "2.2.0-M2")
def catsDataEqForNonEmptyMap[K, A](orderK: Order[K], eqA: Eq[A]): Eq[NonEmptyMap[K, A]] =
catsDataEqForNonEmptyMap(eqA)
}
103 changes: 63 additions & 40 deletions core/src/main/scala/cats/instances/sortedMap.scala
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
package cats.instances

import cats.{Always, Applicative, Eval, FlatMap, Foldable, Monoid, MonoidK, Order, Show, Traverse, TraverseFilter}
import cats.kernel._
import cats._
import cats.data.Ior
import cats.kernel.{CommutativeMonoid, CommutativeSemigroup}

import scala.annotation.tailrec
import scala.collection.immutable.SortedMap
import cats.Align
import cats.Functor
import cats.data.Ior

trait SortedMapInstances extends SortedMapInstances2 {

Expand All @@ -19,23 +17,22 @@ trait SortedMapInstances extends SortedMapInstances2 {
def catsStdCommutativeMonoidForSortedMap[K: Order, V: CommutativeSemigroup] =
cats.kernel.instances.sortedMap.catsKernelStdCommutativeMonoidForSortedMap[K, V]

implicit def catsStdShowForSortedMap[A: Order, B](implicit showA: Show[A], showB: Show[B]): Show[SortedMap[A, B]] =
new Show[SortedMap[A, B]] {
def show(m: SortedMap[A, B]): String =
m.iterator
.map { case (a, b) => showA.show(a) + " -> " + showB.show(b) }
.mkString("SortedMap(", ", ", ")")
}
implicit def catsStdShowForSortedMap[A, B](implicit showA: Show[A], showB: Show[B]): Show[SortedMap[A, B]] =
_.iterator
.map { case (a, b) => showA.show(a) + " -> " + showB.show(b) }
.mkString("SortedMap(", ", ", ")")

@deprecated("Use catsStdShowForSortedMap override without Order", "2.2.0-M2")
implicit def catsStdShowForSortedMap[A, B](orderA: Order[A], showA: Show[A], showB: Show[B]): Show[SortedMap[A, B]] =
catsStdShowForSortedMap(showA, showB)

// scalastyle:off method.length
implicit def catsStdInstancesForSortedMap[K: Order]
implicit def catsStdInstancesForSortedMap[K]
: Traverse[SortedMap[K, *]] with FlatMap[SortedMap[K, *]] with Align[SortedMap[K, *]] =
new Traverse[SortedMap[K, *]] with FlatMap[SortedMap[K, *]] with Align[SortedMap[K, *]] {

implicit val orderingK: Ordering[K] = Order[K].toOrdering

def traverse[G[_], A, B](fa: SortedMap[K, A])(f: A => G[B])(implicit G: Applicative[G]): G[SortedMap[K, B]] = {
val gba: Eval[G[SortedMap[K, B]]] = Always(G.pure(SortedMap.empty(Order[K].toOrdering)))
val gba: Eval[G[SortedMap[K, B]]] = Always(G.pure(SortedMap.empty(fa.ordering)))
Foldable
.iterateRight(fa, gba) { (kv, lbuf) =>
G.map2Eval(f(kv._2), lbuf) { (b, buf) =>
Expand All @@ -45,32 +42,43 @@ trait SortedMapInstances extends SortedMapInstances2 {
.value
}

def flatMap[A, B](fa: SortedMap[K, A])(f: A => SortedMap[K, B]): SortedMap[K, B] =
def flatMap[A, B](fa: SortedMap[K, A])(f: A => SortedMap[K, B]): SortedMap[K, B] = {
implicit val ordering: Ordering[K] = fa.ordering
fa.flatMap { case (k, a) => f(a).get(k).map((k, _)) }
}

override def map[A, B](fa: SortedMap[K, A])(f: A => B): SortedMap[K, B] =
override def map[A, B](fa: SortedMap[K, A])(f: A => B): SortedMap[K, B] = {
implicit val ordering: Ordering[K] = fa.ordering
fa.map { case (k, a) => (k, f(a)) }
}

override def map2Eval[A, B, Z](fa: SortedMap[K, A],
fb: Eval[SortedMap[K, B]])(f: (A, B) => Z): Eval[SortedMap[K, Z]] =
if (fa.isEmpty) Eval.now(SortedMap.empty(Order[K].toOrdering)) // no need to evaluate fb
override def map2Eval[A, B, Z](
fa: SortedMap[K, A],
fb: Eval[SortedMap[K, B]]
)(f: (A, B) => Z): Eval[SortedMap[K, Z]] =
if (fa.isEmpty) Eval.now(SortedMap.empty(fa.ordering)) // no need to evaluate fb
else fb.map(fb => map2(fa, fb)(f))

override def ap2[A, B, Z](f: SortedMap[K, (A, B) => Z])(fa: SortedMap[K, A],
fb: SortedMap[K, B]): SortedMap[K, Z] =
override def ap2[A, B, Z](f: SortedMap[K, (A, B) => Z])(
fa: SortedMap[K, A],
fb: SortedMap[K, B]
): SortedMap[K, Z] = {
implicit val ordering: Ordering[K] = f.ordering
f.flatMap {
case (k, f) =>
for { a <- fa.get(k); b <- fb.get(k) } yield (k, f(a, b))
}
}

def foldLeft[A, B](fa: SortedMap[K, A], b: B)(f: (B, A) => B): B =
fa.foldLeft(b) { case (x, (k, a)) => f(x, a) }
fa.valuesIterator.foldLeft(b)(f)

def foldRight[A, B](fa: SortedMap[K, A], lb: Eval[B])(f: (A, Eval[B]) => Eval[B]): Eval[B] =
Foldable.iterateRight(fa.values, lb)(f)

def tailRecM[A, B](a: A)(f: A => SortedMap[K, Either[A, B]]): SortedMap[K, B] = {
val bldr = SortedMap.newBuilder[K, B](Order[K].toOrdering)
val fa = f(a)
var bldr = SortedMap.newBuilder[K, B](fa.ordering)

@tailrec def descend(k: K, either: Either[A, B]): Unit =
either match {
Expand All @@ -84,7 +92,7 @@ trait SortedMapInstances extends SortedMapInstances2 {
()
}

f(a).foreach { case (k, a) => descend(k, a) }
fa.foreach { case (k, a) => descend(k, a) }
bldr.result
}

Expand All @@ -107,8 +115,8 @@ trait SortedMapInstances extends SortedMapInstances2 {

override def collectFirst[A, B](fa: SortedMap[K, A])(pf: PartialFunction[A, B]): Option[B] =
fa.collectFirst(new PartialFunction[(K, A), B] {
override def isDefinedAt(x: (K, A)) = pf.isDefinedAt(x._2)
override def apply(v1: (K, A)) = pf(v1._2)
override def isDefinedAt(x: (K, A)): Boolean = pf.isDefinedAt(x._2)
override def apply(v1: (K, A)): B = pf(v1._2)
})

override def collectFirstSome[A, B](fa: SortedMap[K, A])(f: A => Option[B]): Option[B] =
Expand All @@ -121,7 +129,7 @@ trait SortedMapInstances extends SortedMapInstances2 {

override def alignWith[A, B, C](fa: SortedMap[K, A], fb: SortedMap[K, B])(f: Ior[A, B] => C): SortedMap[K, C] = {
val keys = fa.keySet ++ fb.keySet
val builder = SortedMap.newBuilder[K, C]
val builder = SortedMap.newBuilder[K, C](fa.ordering)
builder.sizeHint(keys.size)
keys
.foldLeft(builder) { (builder, k) =>
Expand All @@ -136,6 +144,11 @@ trait SortedMapInstances extends SortedMapInstances2 {
}
}

@deprecated("Use catsStdInstancesForSortedMap override without Order", "2.2.0-M2")
def catsStdInstancesForSortedMap[K](
orderK: Order[K]
): Traverse[SortedMap[K, *]] with FlatMap[SortedMap[K, *]] with Align[SortedMap[K, *]] =
catsStdInstancesForSortedMap[K]
}

private[instances] trait SortedMapInstances1 {
Expand Down Expand Up @@ -173,17 +186,14 @@ class SortedMapCommutativeMonoid[K, V](implicit V: CommutativeSemigroup[V], O: O
class SortedMapMonoid[K, V](implicit V: Semigroup[V], O: Order[K]) extends cats.kernel.instances.SortedMapMonoid[K, V]

private[instances] trait SortedMapInstancesBinCompat0 {
implicit def catsStdTraverseFilterForSortedMap[K: Order]: TraverseFilter[SortedMap[K, *]] =
implicit def catsStdTraverseFilterForSortedMap[K]: TraverseFilter[SortedMap[K, *]] =
new TraverseFilter[SortedMap[K, *]] {

implicit val ordering: Ordering[K] = Order[K].toOrdering

val traverse: Traverse[SortedMap[K, *]] = cats.instances.sortedMap.catsStdInstancesForSortedMap[K]

override def traverseFilter[G[_], A, B](
fa: SortedMap[K, A]
)(f: A => G[Option[B]])(implicit G: Applicative[G]): G[SortedMap[K, B]] = {
val gba: Eval[G[SortedMap[K, B]]] = Always(G.pure(SortedMap.empty))
val gba: Eval[G[SortedMap[K, B]]] = Always(G.pure(SortedMap.empty(fa.ordering)))
Foldable
.iterateRight(fa, gba) { (kv, lbuf) =>
G.map2Eval(f(kv._2), lbuf) { (ob, buf) =>
Expand All @@ -193,32 +203,45 @@ private[instances] trait SortedMapInstancesBinCompat0 {
.value
}

override def mapFilter[A, B](fa: SortedMap[K, A])(f: (A) => Option[B]): SortedMap[K, B] =
override def mapFilter[A, B](fa: SortedMap[K, A])(f: A => Option[B]): SortedMap[K, B] = {
implicit val ordering: Ordering[K] = fa.ordering
fa.collect(scala.Function.unlift((t: (K, A)) => f(t._2).map(t._1 -> _)))
}

override def collect[A, B](fa: SortedMap[K, A])(f: PartialFunction[A, B]): SortedMap[K, B] =
override def collect[A, B](fa: SortedMap[K, A])(f: PartialFunction[A, B]): SortedMap[K, B] = {
implicit val ordering: Ordering[K] = fa.ordering
fa.collect(scala.Function.unlift((t: (K, A)) => f.lift(t._2).map(t._1 -> _)))
}

override def flattenOption[A](fa: SortedMap[K, Option[A]]): SortedMap[K, A] =
override def flattenOption[A](fa: SortedMap[K, Option[A]]): SortedMap[K, A] = {
implicit val ordering: Ordering[K] = fa.ordering
fa.collect(scala.Function.unlift((t: (K, Option[A])) => t._2.map(t._1 -> _)))
}

override def filter[A](fa: SortedMap[K, A])(f: (A) => Boolean): SortedMap[K, A] =
override def filter[A](fa: SortedMap[K, A])(f: A => Boolean): SortedMap[K, A] =
fa.filter { case (_, v) => f(v) }

override def filterNot[A](fa: SortedMap[K, A])(f: A => Boolean): SortedMap[K, A] =
fa.filterNot { case (_, v) => f(v) }

override def filterA[G[_], A](
fa: SortedMap[K, A]
)(f: (A) => G[Boolean])(implicit G: Applicative[G]): G[SortedMap[K, A]] =
)(f: A => G[Boolean])(implicit G: Applicative[G]): G[SortedMap[K, A]] =
traverseFilter(fa)(a => G.map(f(a))(if (_) Some(a) else None))
}

@deprecated("Use catsStdTraverseFilterForSortedMap override without Order", "2.2.0-M2")
def catsStdTraverseFilterForSortedMap[K](orderK: Order[K]): TraverseFilter[SortedMap[K, *]] =
catsStdTraverseFilterForSortedMap[K]
}

private[instances] trait SortedMapInstancesBinCompat1 {
implicit def catsStdSemigroupKForSortedMap[K]: SemigroupK[SortedMap[K, *]] = new SemigroupK[SortedMap[K, *]] {
override def combineK[A](x: SortedMap[K, A], y: SortedMap[K, A]): SortedMap[K, A] = x ++ y
}

implicit def catsStdMonoidKForSortedMap[K: Order]: MonoidK[SortedMap[K, *]] = new MonoidK[SortedMap[K, *]] {
override def empty[A]: SortedMap[K, A] = SortedMap.empty[K, A](Order[K].toOrdering)

override def combineK[A](x: SortedMap[K, A], y: SortedMap[K, A]): SortedMap[K, A] = x ++ y
}
}
Expand Down
Loading