You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/docs/reference/contextual/multiversal-equality.md
+11-10Lines changed: 11 additions & 10 deletions
Original file line number
Diff line number
Diff line change
@@ -67,19 +67,19 @@ given Eql[B, A] = Eql.derived
67
67
The `scala.Eql` object defines a number of `Eql` given instances that together
68
68
define a rule book for what standard types can be compared (more details below).
69
69
70
-
There's also a "fallback" instance named `eqlAny` that allows comparisons
70
+
There is also a "fallback" instance named `eqlAny` that allows comparisons
71
71
over all types that do not themselves have an `Eql` given. `eqlAny` is defined as follows:
72
72
73
73
```scala
74
74
defeqlAny[L, R]:Eql[L, R] =Eql.derived
75
75
```
76
76
77
-
Even though `eqlAny` is not declared a given, the compiler will still construct an `eqlAny` instance as answer to an implicit search for the
77
+
Even though `eqlAny` is not declared as `given`, the compiler will still construct an `eqlAny` instance as answer to an implicit search for the
78
78
type `Eql[L, R]`, unless `L` or `R` have `Eql` instances
79
-
defined on them, or the language feature `strictEquality` is enabled
79
+
defined on them, or the language feature `strictEquality` is enabled.
80
80
81
-
The primary motivation for having `eqlAny` is backwards compatibility,
82
-
if this is of no concern, one can disable `eqlAny` by enabling the language
81
+
The primary motivation for having `eqlAny` is backwards compatibility.
82
+
If this is of no concern, one can disable `eqlAny` by enabling the language
83
83
feature `strictEquality`. As for all language features this can be either
84
84
done with an import
85
85
@@ -112,7 +112,7 @@ The precise rules for equality checking are as follows.
112
112
113
113
If the `strictEquality` feature is enabled then
114
114
a comparison using `x == y` or `x != y` between values `x: T` and `y: U`
115
-
is legal if there is a given of type `Eql[T, U]`.
115
+
is legal if there is a `given` of type `Eql[T, U]`.
116
116
117
117
In the default case where the `strictEquality` feature is not enabled the comparison is
118
118
also legal if
@@ -123,8 +123,8 @@ also legal if
123
123
124
124
Explanations:
125
125
126
-
-_lifting_ a type `S` means replacing all references to abstract types
127
-
in covariant positions of `S` by their upper bound, and to replacing
126
+
-_lifting_ a type `S` means replacing all references to abstract types
127
+
in covariant positions of `S` by their upper bound, and replacing
128
128
all refinement types in covariant positions of `S` by their parent.
129
129
- a type `T` has a _reflexive_`Eql` instance if the implicit search for `Eql[T, T]`
130
130
succeeds.
@@ -153,8 +153,9 @@ Instances are defined so that every one of these types has a _reflexive_ `Eql` i
153
153
## Why Two Type Parameters?
154
154
155
155
One particular feature of the `Eql` type is that it takes _two_ type parameters, representing the types of the two items to be compared. By contrast, conventional
156
-
implementations of an equality type class take only a single type parameter which represents the common type of _both_ operands. One type parameter is simpler than two, so why go through the additional complication? The reason has to do with the fact that, rather than coming up with a type class where no operation existed before,
157
-
we are dealing with a refinement of pre-existing, universal equality. It's best illustrated through an example.
156
+
implementations of an equality type class take only a single type parameter which represents the common type of _both_ operands.
157
+
One type parameter is simpler than two, so why go through the additional complication? The reason has to do with the fact that, rather than coming up with a type class where no operation existed before,
158
+
we are dealing with a refinement of pre-existing, universal equality. It is best illustrated through an example.
158
159
159
160
Say you want to come up with a safe version of the `contains` method on `List[T]`. The original definition of `contains` in the standard library was:
0 commit comments