[英]What does the `*` mean in a generic type?
I was learning Cats library and found *
as a generic type, like that:我正在学习 Cats 库,发现
*
作为一个泛型类型,就像这样:
implicit def catsDataSemigroupKForValidated[A](implicit A: Semigroup[A]): SemigroupK[Validated[A, *]] =
new SemigroupK[Validated[A, *]] {
def combineK[B](x: Validated[A, B], y: Validated[A, B]): Validated[A, B] = x match {
case v @ Valid(_) => v
case Invalid(ix) =>
y match {
case Invalid(iy) => Invalid(A.combine(ix, iy))
case v @ Valid(_) => v
}
}
}
My guess is that the *
is used, because the combineK
method return Validated[A, B]
so there is no need to specify generic type.我的猜测是使用了
*
,因为combineK
方法返回Validated[A, B]
所以不需要指定泛型类型。 Or it could be Any
type (like Inteliij is suggested).或者它可以是
Any
类型(建议使用 Inteliij)。 I would be very glad for your explanations.我会很高兴你的解释。
The cats code you are looking at is master branch, which is for Dotty (Scala 3).您正在查看的猫代码是 master 分支,用于 Dotty (Scala 3)。
*
is a type parameter placeholder in 3.0: *
是 3.0 中的类型参数占位符:
https://dotty.epfl.ch/docs/reference/changed-features/wildcards.html https://dotty.epfl.ch/docs/reference/changed-features/wildcards.html
Note that it is already deprecated in 3.2 and removed in 3.3 in favor for _
.请注意,它已在 3.2 中被弃用,并在 3.3 中被删除以支持
_
。
EDIT编辑
It's also used in kind projector plugin它也用于实物投影仪插件
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.