I want to use java.time.LocalDate
and java.time.LocalDateTime
with an implicit Ordered
like:
val date1 = java.time.Loc
A slight modification to the implicit ordered
should do the trick.
type AsComparable[A] = A => Comparable[_ >: A]
implicit def ordered[A: AsComparable]: Ordering[A] = new Ordering[A] {
def compare(x: A, y: A): Int = x compareTo y
}
Now every type which is comparable to itself or to a supertype of itself should have an Ordering
.