When asking for the kind of [Int]
and []
in Haskell I get:
Prelude> :k [Int]
[Int] :: *
Prelude> :k []
[] :: * -> *
which makes sense: the first one is a proper type and the second one is a higher kinded type.
But when I do the same in Scala:
scala> :k -v List[Int]
scala.collection.immutable.List's kind is F[+A]
* -(+)-> *
This is a type constructor: a 1st-order-kinded type.
scala> :k -v List
scala.collection.immutable.List's kind is F[+A]
* -(+)-> *
This is a type constructor: a 1st-order-kinded type.
... it says both are higher kinded types. Why the first one isn't classified as a proper type? What's the reason for this difference?
It seems that scala
sees the [Int]
part in List[Int]
perfectly well, but chooses to ignore it and always look at the "outer" type deliberately.
If this weren't true, then type ListOfInt = List[Int]
followed by :k -v ListOfInt
would yield *
not * -> *
but that's not the case:
scala> :k -v List
scala.collection.immutable.List's kind is F[+A]
* -(+)-> *
This is a type constructor: a 1st-order-kinded type.
scala> :k -v List[Int]
scala.collection.immutable.List's kind is F[+A]
* -(+)-> *
This is a type constructor: a 1st-order-kinded type.
scala> type ListOfInt = List[Int]
defined type alias ListOfInt
scala> :k -v ListOfInt
scala.collection.immutable.List's kind is F[+A]
* -(+)-> *
This is a type constructor: a 1st-order-kinded type.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With