Skip to content

Ordering[T] and friends should be contravariant #7179

@scabug

Description

@scabug

The Ordering[T] trait and its friends Equiv[T] and PartialOrdering[T] should be contravariant in T. This would for example allow SeqLike.sorted to be declared as:

def sorted(implicit ord: math.Ordering[A]): Repr

rather than

def sorted[B >: A](implicit ord: math.Ordering[B]): Repr

It would also provide a good didactic example of contravariance in the library!

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions