mig*_*uel 15 haskell scala higher-kinded-types
当我在Haskell中询问那种情况时[Int]
,[]
我得到:
Prelude> :k [Int]
[Int] :: *
Prelude> :k []
[] :: * -> *
Run Code Online (Sandbox Code Playgroud)
这是有道理的:第一个是合适的类型,第二个是更高的类型.
但是当我在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.
Run Code Online (Sandbox Code Playgroud)
......它说都是更高级的类型.为什么第一个没有被归类为合适的类型?造成这种差异的原因是什么?
似乎完全看好scala
这[Int]
部分List[Int]
,但选择忽略它并且总是刻意地看待"外部"类型.
如果这不是真的,那么type ListOfInt = List[Int]
接下来:k -v ListOfInt
会产生*
不是,* -> *
但事实并非如此:
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.
Run Code Online (Sandbox Code Playgroud)