What is the plan for default Eql
given instances?
I was trying out Multiversal equality for Scala 3 with Dotty 0.27.0-RC1 (http://dotty.epfl.ch/docs/reference/contextual/multiversal-equality.html) and was surprised to see the following behavior
$ dotr -language:strictEquality
scala> Option(1) == Option(1)
1 |Option(1) == Option(1)
|^^^^^^^^^^^^^^^^^^^^^^
|Values of types Option[Int] and Option[Int] cannot be compared with == or !=
scala> Vector(1) == List(2)
val res3: Boolean = false
scala> 'a' == 42
val res1: Boolean = false
I expected the Option(1) == Option(1)
to compile successfully and Vector(1) == List(2)
to fail compilation. However, looking at the implementation I see that there’s a default Eql
given instance for all sequences but there’s no default given instance of Eql[T, T]
https://github.com/lampepfl/dotty/blob/972ae73be961ce19103fe8edfa7246b44de7625a/library/src/scala/Eql.scala#L32
I am concerned multiversal equality won’t gain wide adoption with the current implementation given it’s both too strict and not strict enough at the same time. I suspect users who optionally enable -language:strictEquality
would prefer to fail the compilation when comparing unrelated types (even if they are equal at runtime). I feel like it would be more natural to either 1) remove all default instances or 2) at least provide a default given instance for Eql[T, T]
.