[英]classOf[] for a higher-kinded type
Given class Foo[F[_]]
, how do I get the Class
object? 给定
class Foo[F[_]]
,如何获取Class
对象? The usual syntax doesn't work: 常用语法不起作用:
scala> classOf[Foo[_]]
<console>:9: error: _$1 takes no type parameters, expected: one
classOf[Foo[_]]
^
Neither does 也没有
scala> classOf[Foo[_[_]]]
<console>:9: error: _$1 does not take type parameters
classOf[Foo[_[_]]]
^
Ah, right. 嗯对 Leaving this in case someone looks for it:
如果有人寻找它,则留给它:
scala> classOf[Foo[F] forSome { type F[_] }]
warning: there were 1 feature warning(s); re-run with -feature for details
res0: Class[Foo[_[_] <: Any]] = class Foo
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.