From bfe9faa637bce1fc499a33beb979ce9dcd35e983 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Fri, 6 May 2016 19:06:57 +0200 Subject: Make Eq contravariant (and add it to commit set). --- src/scala/Eq.scala | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 src/scala/Eq.scala (limited to 'src/scala') diff --git a/src/scala/Eq.scala b/src/scala/Eq.scala new file mode 100644 index 000000000..697ec4318 --- /dev/null +++ b/src/scala/Eq.scala @@ -0,0 +1,17 @@ +package scala + +/** A marker class indicating that values of kind `T` can be compared. */ +class Eq[-L, -R] + +/** Besides being a companion object, this object + * can also be used as a value that's compatible with + * any instance of `Eq`. + */ +object Eq extends Eq[Any, Any] { + + /** An implicit that provides an `Eq` instance for all types `T` + * such that `T <: EqClass[T]`. + */ + implicit def eqAny[L, R]: Eq[L, R] = Eq +} + -- cgit v1.2.3