forked from typelevel/kind-projector
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.scala
More file actions
86 lines (71 loc) · 2.13 KB
/
test.scala
File metadata and controls
86 lines (71 loc) · 2.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
package underscores
object Test {
// some type-level helper methods
def foo[T] = ()
def bar[T[_]] = ()
def baz[T[_, _]] = ()
// used for seeing what kind of tree we will start with
type ?? = Unit
foo[Either[Int, ??]]
foo[Tuple3[Int, ??, ??]]
// used for seeing what kind of tree we want to end up with
bar[({type L[X] = Either[Int, X]})#L]
baz[({type L[X,Y] = Tuple3[Int, X, Y]})#L]
// used to test the plugin
bar[Either[Int, _]]
baz[Tuple3[Int, _, _]]
baz[Tuple3[_, Int, _]]
// should not be changed by the plugin
foo[Either[Int, Double]]
foo[Tuple3[Int, Int, Double]]
// xyz
type Fake[A] = A
foo[Fake[(Int, Double) => Either[Double, Int]]]
baz[Lambda[(A, B) => Either[B, A]]]
class Graph { type Node }
foo[Graph { type Node = Int }]
bar[Lambda[N => Graph { type Node = N }]]
//bar[Graph { type Node = ? }] // TODO, maybe?
//bar[Graph#?Node] // TODO, maybe?
// higher order
def qux[T[_[_]]] = ()
qux[({type L[A[_]] = Unit})#L]
qux[Lambda[A[_] => Unit]]
qux[Lambda[A[B] => Unit]]
trait Functor[F[_]]
trait EitherT[F[_], A, B]
qux[Functor[_[_]]]
qux[EitherT[_[_], Int, Double]]
// higher higher order
def vex[T[_[_[_]]]] = ()
vex[({type L[A[_[_]]] = Unit})#L]
vex[Lambda[A[_[_]] => Unit]]
vex[Lambda[A[B[_]] => Unit]]
vex[Lambda[A[_[C]] => Unit]]
vex[Lambda[A[B[C]] => Unit]]
trait FunctorK[F[_[_]]]
vex[FunctorK[_[_[_]]]]
def hex[T[_[_[_[_]]]]] = ()
hex[({type L[A[_[_[_]]]] = Unit})#L]
hex[Lambda[A[_[_[_]]] => Unit]]
// covariant
def mux[T[+_]] = ()
mux[({type L[+A] = Either[A, Int]})#L]
mux[Either[`+_`, Int]]
mux[Lambda[`+A` => Either[A, Int]]]
mux[Lambda[+[A] => Either[A, Int]]]
// contravariant
def bux[T[-_, +_]] = ()
bux[({type L[-A, +B] = Function2[A, Int, B]})#L]
bux[Function2[`-_`, Int, `+_`]]
bux[Lambda[(`-A`, `+B`) => Function2[A, Int, B]]]
bux[Lambda[(-[A], +[B]) => Function2[A, Int, B]]]
// higher-kinded variance
trait ~>[-F[_], +G[_]]
def tux[T[-F[_]]] = ()
def hux[T[+G[_]]] = ()
tux[~>[`-_`[_], Option]]
hux[~>[Option, `+_`[_]]]
tux[Lambda[`-F[_]` => ~>[F, Option]]]
hux[Lambda[`+G[_]` => ~>[Option, G]]]
}