Skip to content

Commit 40fdb71

Browse files
committed
TestRig
1 parent 8931ac1 commit 40fdb71

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package singleton.ops.impl
2+
3+
import singleton.ops._
4+
5+
trait Rig[V <: XInt] {
6+
val value: Int
7+
override def toString: String = s"Rig($value)"
8+
}
9+
10+
object Rig {
11+
// get the 'Out' type resulting from resolving an implicit type
12+
object impeval {
13+
trait Out[O]
14+
def apply[I <: { type Out } ](implicit i: I): Out[i.Out] = new Out[i.Out] {}
15+
}
16+
17+
implicit def rigAddition[L <: Rig[_], R <: Rig[_], O <: Rig[_]](implicit
18+
add: Add.Aux[L, R, O]): OpIntercept.Aux[OpId.+, L, R, W.`0`.T, O] =
19+
new OpIntercept[OpId.+, L, R, W.`0`.T] {
20+
type Out = O
21+
val value = add.value
22+
}
23+
24+
trait Add[L, R] {
25+
type Out
26+
val value: Out
27+
}
28+
object Add {
29+
type Aux[L, R, O] = Add[L, R] { type Out = O }
30+
31+
implicit def addRig[LV <: XInt, RV <: XInt, OV <: XInt](implicit
32+
add: OpInt.Aux[LV + RV, OV]): Add.Aux[Rig[LV], Rig[RV], Rig[OV]] =
33+
new Add[Rig[LV], Rig[RV]] {
34+
type Out = Rig[OV]
35+
val value = new Rig[OV] { val value = add.value }
36+
}
37+
}
38+
}
39+

0 commit comments

Comments
 (0)