@@ -84,7 +84,7 @@ For the `Tree` ADT from above the following `Mirror` instances will be automatic
84
84
85
85
``` scala
86
86
// Mirror for Tree
87
- new Mirror .Sum with
87
+ new Mirror .Sum :
88
88
type MirroredType = Tree
89
89
type MirroredElemTypes [T ] = (Branch [T ], Leaf [T ])
90
90
type MirroredMonoType = Tree [_]
@@ -96,7 +96,7 @@ new Mirror.Sum with
96
96
case _ : Leaf [_] => 1
97
97
98
98
// Mirror for Branch
99
- new Mirror .Product with
99
+ new Mirror .Product :
100
100
type MirroredType = Branch
101
101
type MirroredElemTypes [T ] = (Tree [T ], Tree [T ])
102
102
type MirroredMonoType = Branch [_]
@@ -107,7 +107,7 @@ new Mirror.Product with
107
107
new Branch (...)
108
108
109
109
// Mirror for Leaf
110
- new Mirror .Product with
110
+ new Mirror .Product :
111
111
type MirroredType = Leaf
112
112
type MirroredElemTypes [T ] = Tuple1 [T ]
113
113
type MirroredMonoType = Leaf [_]
@@ -212,7 +212,7 @@ instance for the appropriate ADT subtype using the auxiliary method `check` (4).
212
212
213
213
``` scala
214
214
def eqSum [T ](s : Mirror .SumOf [T ], elems : List [Eq [_]]): Eq [T ] =
215
- new Eq [T ] with
215
+ new Eq [T ]:
216
216
def eqv (x : T , y : T ): Boolean =
217
217
val ordx = s.ordinal(x) // (3)
218
218
(s.ordinal(y) == ordx) && check(elems(ordx))(x, y) // (4)
@@ -223,7 +223,7 @@ on the `Eq` instances for the fields of the data type (5),
223
223
224
224
``` scala
225
225
def eqProduct [T ](p : Mirror .ProductOf [T ], elems : List [Eq [_]]): Eq [T ] =
226
- new Eq [T ] with
226
+ new Eq [T ]:
227
227
def eqv (x : T , y : T ): Boolean =
228
228
iterator(x).zip(iterator(y)).zip(elems.iterator).forall { // (5)
229
229
case ((x, y), elem) => check(elem)(x, y)
@@ -254,13 +254,13 @@ object Eq:
254
254
def iterator [T ](p : T ) = p.asInstanceOf [Product ].productIterator
255
255
256
256
def eqSum [T ](s : Mirror .SumOf [T ], elems : => List [Eq [_]]): Eq [T ] =
257
- new Eq [T ] with
257
+ new Eq [T ]:
258
258
def eqv (x : T , y : T ): Boolean =
259
259
val ordx = s.ordinal(x)
260
260
(s.ordinal(y) == ordx) && check(elems(ordx))(x, y)
261
261
262
262
def eqProduct [T ](p : Mirror .ProductOf [T ], elems : => List [Eq [_]]): Eq [T ] =
263
- new Eq [T ] with
263
+ new Eq [T ]:
264
264
def eqv (x : T , y : T ): Boolean =
265
265
iterator(x).zip(iterator(y)).zip(elems.iterator).forall {
266
266
case ((x, y), elem) => check(elem)(x, y)
0 commit comments