@@ -40,17 +40,16 @@ object runtime {
40
40
}
41
41
42
42
trait TypeClassCompanion {
43
- type Impl [T ] <: Extension [T , _ ]
43
+ type Impl [T ] <: Extension [T ]
44
44
def impl [T ](implicit ev : Impl [T ]): Impl [T ] = ev
45
45
}
46
46
47
- trait Extension [From , To <: TypeClass ] extends TypeClassCommon {
47
+ trait Extension [From ] extends TypeClassCommon {
48
48
type This = From
49
- type Instance = To
50
49
}
51
50
52
51
implicit def inject [From ](x : From )
53
- (implicit ev : Extension [From , _ ]): ev.Instance { type This = From } =
52
+ (implicit ev : Extension [From ]): ev.Instance { type This = From } =
54
53
ev.inject(x)
55
54
}
56
55
import runtime ._
@@ -66,7 +65,7 @@ object semiGroups {
66
65
type Instance <: SemiGroup
67
66
}
68
67
object SemiGroup extends TypeClassCompanion {
69
- type Impl [T ] = Extension [T , SemiGroup ] with SemiGroupCommon
68
+ type Impl [T ] = Extension [T ] with SemiGroupCommon
70
69
}
71
70
72
71
trait Monoid extends SemiGroup {
@@ -78,10 +77,10 @@ object semiGroups {
78
77
def unit : This
79
78
}
80
79
object Monoid extends TypeClassCompanion {
81
- type Impl [T ] = Extension [T , Monoid ] with MonoidCommon
80
+ type Impl [T ] = Extension [T ] with MonoidCommon
82
81
}
83
82
84
- implicit object IntOps extends Extension [Int , Monoid ] with MonoidCommon {
83
+ implicit object IntOps extends Extension [Int ] with MonoidCommon {
85
84
type This = Int
86
85
type Instance = Monoid
87
86
def unit : Int = 0
@@ -91,7 +90,7 @@ object semiGroups {
91
90
}
92
91
}
93
92
94
- implicit object StringOps extends Extension [String , Monoid ] with MonoidCommon {
93
+ implicit object StringOps extends Extension [String ] with MonoidCommon {
95
94
type This = String
96
95
type Instance = Monoid
97
96
def unit = " "
@@ -101,7 +100,7 @@ object semiGroups {
101
100
}
102
101
}
103
102
104
- def sum [T ](xs : List [T ])(implicit $ ev : Monoid .Impl [T ]) =
103
+ def sum [T ](xs : List [T ])(implicit ev : Monoid .Impl [T ]) =
105
104
(Monoid .impl[T ].unit /: xs)((x, y) => x `add` y)
106
105
}
107
106
@@ -156,10 +155,10 @@ object ord {
156
155
def minimum : This
157
156
}
158
157
object Ord extends TypeClassCompanion {
159
- type Impl [T ] = Extension [T , Ord ] with OrdCommon
158
+ type Impl [T ] = Extension [T ] with OrdCommon
160
159
}
161
160
162
- implicit object IntOrd extends Extension [Int , Ord ] with OrdCommon {
161
+ implicit object IntOrd extends Extension [Int ] with OrdCommon {
163
162
type This = Int
164
163
type Instance = Ord
165
164
val minimum : Int = Int .MinValue
@@ -171,7 +170,7 @@ object ord {
171
170
}
172
171
173
172
class ListOrd [T ](implicit ev : Ord .Impl [T ])
174
- extends Extension [List [T ], Ord ] with OrdCommon { self =>
173
+ extends Extension [List [T ]] with OrdCommon { self =>
175
174
type This = List [T ]
176
175
type Instance = Ord
177
176
def minimum : List [T ] = Nil
@@ -246,17 +245,16 @@ object runtime1 {
246
245
}
247
246
248
247
trait TypeClassCompanion1 {
249
- type Impl [T [_]] <: Extension1 [T , _ ]
248
+ type Impl [T [_]] <: Extension1 [T ]
250
249
def impl [T [_]](implicit ev : Impl [T ]): Impl [T ] = ev
251
250
}
252
251
253
- trait Extension1 [From [_], To [ X ] <: TypeClass1 ] extends TypeClassCommon1 {
252
+ trait Extension1 [From [_]] extends TypeClassCommon1 {
254
253
type This [X ] = From [X ]
255
- type Instance [X ] = To [X ]
256
254
}
257
255
258
256
implicit def inject1 [A , From [_]](x : From [A ])
259
- (implicit ev : Extension1 [From , _ ]): ev.Instance [A ] { type This = From } =
257
+ (implicit ev : Extension1 [From ]): ev.Instance [A ] { type This = From } =
260
258
ev.inject(x)
261
259
}
262
260
import runtime1 ._
@@ -273,7 +271,7 @@ object functors {
273
271
def pure [A ](x : A ): This [A ]
274
272
}
275
273
object Functor extends TypeClassCompanion1 {
276
- type Impl [T [_]] = Extension1 [T , Functor ] with FunctorCommon
274
+ type Impl [T [_]] = Extension1 [T ] with FunctorCommon
277
275
}
278
276
279
277
trait Monad [A ] extends Functor [A ] {
@@ -286,14 +284,14 @@ object functors {
286
284
type Instance [X ] <: Monad [X ]
287
285
}
288
286
object Monad extends TypeClassCompanion1 {
289
- type Impl [T [_]] = Extension1 [T , Monad ] with MonadCommon
287
+ type Impl [T [_]] = Extension1 [T ] with MonadCommon
290
288
}
291
289
292
290
def develop [A , F [X ]](n : Int , x : A , f : A => A )(implicit ev : Functor .Impl [F ]): F [A ] =
293
291
if (n == 0 ) Functor .impl[F ].pure(x)
294
292
else develop(n - 1 , x, f).map(f)
295
293
296
- implicit object ListMonad extends Extension1 [List , Monad ] with MonadCommon {
294
+ implicit object ListMonad extends Extension1 [List ] with MonadCommon {
297
295
type This [A ] = List [A ]
298
296
type Instance = Monad
299
297
def pure [A ](x : A ) = x :: Nil
0 commit comments