File tree 3 files changed +54
-0
lines changed
3 files changed +54
-0
lines changed Original file line number Diff line number Diff line change
1
+ trait Eq [A ] {
2
+ def eqv (a1 : A , a2 : A ): Boolean
3
+ }
4
+
5
+ given stringEq : Eq [String ] with {
6
+ def eqv (a1 : String , a2 : String ) = a1 == a2
7
+ }
8
+
9
+ abstract class Newtype [Src ] {
10
+ opaque type Type = Src
11
+
12
+ protected final def derive [F [_]](using ev : F [Src ]): F [Type ] = ev
13
+ }
14
+
15
+ object Sample extends Newtype [String ] {
16
+ given eq : Eq [Type ] = derive
17
+ }
Original file line number Diff line number Diff line change
1
+ trait JsonRowEntry {
2
+ def readAs [E ](implicit c : Read [E ]): Option [E ] = ???
3
+ }
4
+ trait Read [T ]
5
+ trait Codec [T ] extends Read [T ]
6
+ trait CodecTypeProjection [C [_]]
7
+ object JsonTransform {
8
+ given SetCodec [T , C [_]: CodecTypeProjection ]: scala.Conversion [C [T ], C [Set [T ]]] = ???
9
+ given SetCodecExp [T , C [_]: CodecTypeProjection ](using codec : C [T ]): C [Set [T ]] = codec
10
+ given Codec [String ] = ???
11
+ given CodecTypeProjection [Read ] = ???
12
+ }
13
+
14
+ @ main def Test () = {
15
+ import JsonTransform .given
16
+ val tree = new JsonRowEntry {}
17
+ tree.readAs[Set [String ]]
18
+ }
19
+
20
+ trait Box [E ]
21
+
22
+ trait Domain
23
+
24
+ def fun [E , D [_] <: Domain ](box : Box [E ])(implicit domain : D [E ]): Unit = {
25
+
26
+ val newBox : Box [E ] = ???
27
+
28
+ fun(newBox)
29
+ }
Original file line number Diff line number Diff line change
1
+ sealed trait Domain [E ]
2
+
3
+ final def splitBounds [E , D [X ] <: Domain [X ]](
4
+ bounds : Seq [E ],
5
+ )( using domain : D [E ]): Seq [E ] =
6
+ val newBounds : Seq [E ] = ???
7
+ splitBounds(newBounds) // does not compile
8
+ splitBounds[E ,D ](newBounds) // does compile
You can’t perform that action at this time.
0 commit comments