/
repl-kind.check
72 lines (51 loc) · 1.72 KB
/
repl-kind.check
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
scala> :kind Int
Int's kind is A
scala> :kind scala.Option
Option's kind is F[+A]
scala> :k (Int, Int) => Int
(Int, Int) => Int's kind is A
scala> :k -v Either
Either's kind is F[+A1,+A2]
* -(+)-> * -(+)-> *
This is a type constructor: a 1st-order-kinded type.
scala> :k -v scala.collection.SortedMapOps
scala.collection.SortedMapOps's kind is X[K,+V,+CC[X,Y] <: [X, Y]scala.collection.Map[X,Y] with scala.collection.SortedMapOps[X, Y, CC, _],+C <: scala.collection.SortedMapOps[K,V,CC,C]]
* -> * -(+)-> (* -> * -> *([X, Y]scala.collection.Map[X,Y] with scala.collection.SortedMapOps[X, Y, CC, _])) -(+)-> *(scala.collection.SortedMapOps[K,V,CC,C]) -(+)-> *
This is a type constructor that takes type constructor(s): a higher-kinded type.
scala> :kind -v Tuple2
Tuple2's kind is F[+A1,+A2]
* -(+)-> * -(+)-> *
This is a type constructor: a 1st-order-kinded type.
scala> :kind -v Tuple2[Int, Int]
(Int, Int)'s kind is A
*
This is a proper type.
scala> trait Functor[F[_]] {}
trait Functor
scala> :kind -v Functor
Functor's kind is X[F[A]]
(* -> *) -> *
This is a type constructor that takes type constructor(s): a higher-kinded type.
scala> object Bar { class Bop }
object Bar
scala> import Bar.Bop
import Bar.Bop
scala> :kind Bop
Bar.Bop's kind is A
scala> type IntTuple[+A] = (Int, A)
type IntTuple
scala> :kind IntTuple
IntTuple's kind is F[+A]
scala> :kind ({type l[A] = Either[Int, A]})#l
scala.util.Either[Int,?]'s kind is F[+A]
scala> trait Nat[-F1[_], +F2[_]] {}
trait Nat
scala> type ~>[-F1[_], +F2[_]] = Nat[F1, F2]
type $tilde$greater
scala> :kind ({type l[F[-_]] = F ~> List})#l
Nat[?,[+A]List[A]]'s kind is X[-F[A]]
scala> :kind 5
5's kind is A
scala> :kind Nonexisting
<console>: error: type Nonexisting was not found
scala> :quit