diff --git a/core/src/main/scala/cats/instances/all.scala b/core/src/main/scala/cats/instances/all.scala index 586d5f287db..b64f1c73810 100644 --- a/core/src/main/scala/cats/instances/all.scala +++ b/core/src/main/scala/cats/instances/all.scala @@ -20,3 +20,4 @@ trait AllInstances with TupleInstances with UUIDInstances with SymbolInstances + with OrderInstances diff --git a/core/src/main/scala/cats/instances/order.scala b/core/src/main/scala/cats/instances/order.scala new file mode 100644 index 00000000000..53b019d8904 --- /dev/null +++ b/core/src/main/scala/cats/instances/order.scala @@ -0,0 +1,5 @@ +package cats +package instances + +trait OrderInstances extends cats.kernel.OrderToOrderingConversion + diff --git a/core/src/main/scala/cats/instances/package.scala b/core/src/main/scala/cats/instances/package.scala index d08087f0220..1a2aabfd6c2 100644 --- a/core/src/main/scala/cats/instances/package.scala +++ b/core/src/main/scala/cats/instances/package.scala @@ -32,4 +32,5 @@ package object instances { object try_ extends TryInstances object tuple extends TupleInstances object uuid extends UUIDInstances + object order extends OrderInstances } diff --git a/kernel/src/main/scala/cats/kernel/Order.scala b/kernel/src/main/scala/cats/kernel/Order.scala index bf31262d938..75cb082acc5 100644 --- a/kernel/src/main/scala/cats/kernel/Order.scala +++ b/kernel/src/main/scala/cats/kernel/Order.scala @@ -139,7 +139,16 @@ abstract class OrderFunctions[O[T] <: Order[T]] extends PartialOrderFunctions[O] ev.max(x, y) } -object Order extends OrderFunctions[Order] { +trait OrderToOrderingConversion { + /** + * Implicitly convert a `Order[A]` to a `scala.math.Ordering[A]` + * instance. + */ + implicit final def catsKernelOrderingForOrder[A](implicit ev: Order[A]): Ordering[A] = + ev.toOrdering +} + +object Order extends OrderFunctions[Order] with OrderToOrderingConversion { /** * Access an implicit `Order[A]`. */ @@ -160,13 +169,6 @@ object Order extends OrderFunctions[Order] { def compare(x: A, y: A) = f(x, y) } - /** - * Implicitly convert a `Order[A]` to a `scala.math.Ordering[A]` - * instance. - */ - implicit def catsKernelOrderingForOrder[A](implicit ev: Order[A]): Ordering[A] = - ev.toOrdering - /** * An `Order` instance that considers all `A` instances to be equal. */