在下面的代碼(從Functional Programming in Scala):「更高Kinded類型應啓用」 警告
trait Functor[F[_]] {
def map[A,B](fa: F[A])(f: A => B): F[B]
}
trait Monad[F[_]] {
def unit[A](a: => A): F[A]
def flatMap[A,B](ma: F[A])(f: A => F[B]): F[B]
def apply[A](a: => A): F[A]
}
我看到下面的警告:
[warn] C:\...\Monad.scala:3: higher-kinded type should be enabled
[warn] by making the implicit value scala.language.higherKinds visible.
[warn] This can be achieved by adding the import clause 'import scala.language.higherKinds'
[warn] or by setting the compiler option -language:higherKinds.
[warn] See the Scala docs for value scala.language.higherKinds for a discussion
[warn] why the feature should be explicitly enabled.
[warn] trait Functor[F[_]] {
[warn] ^
[warn] C:\...\Monad.scala:7: higher-kinded type should be enabled
[warn] by making the implicit value scala.language.higherKinds visible.
[warn] trait Monad[F[_]] {
這是怎麼回事?請注意,我讀了這個post,但並不理解它。
參見[SIP-18 - 模塊化中語言功能(http://docs.scala-lang.org/sips/完成/模塊化-語言的features.html)。 – senia