Syntax for prioritising one existing ordering over another

class V extends Ordered[V]
class S extends V

trait P extends Ordered[P]

I would like class S to mix in trait P. However I get a divergent implicits error when using < relop.

Is there a way of saying, when you order S, take V's ordering only and ignore P's, perhaps via an implicit, without having to reimplement the ordering logic. What would the syntax for this be?


AFAICS this can’t work, just due to type erasure. Solution: Goodbye Ordered, hello Ordering.

1 Like

Agreed – this is one of the classic reasons to use the typeclass-based Ordering instead of the inheritance-based Ordered: you can have more than one definition for it…