Scala:Parvector不符合上限[_] =>> seq [?]
我正在使用平行集合模块,版本1.0.4( github )。 我有以下类型定义定义矩阵的通用版本的定义:
type Matrix[T, C[_] <: Seq[_]] = C[C[T]]
正如预期的那样,使用向量作为集合类型时初始化此类矩阵有效:
val vecMatrix: Matrix[Double, Vector] =
Vector(Vector(0.5, 0.6), Vector(0.6, 0.8))
但是,使用Parvector会产生编译器错误:
val parvecMatrix: Matrix[Double, ParVector] =
ParVector(ParVector(0.5, 0.6), ParVector(0.6, 0.8))
类型参数collection.parallel.immutable.parvector不符合上限[_] =&gt;&gt; seq [?]
我读这本书是因为Parvector不是Seq的子类型。但是,scala.collection.parallel.parseqlike的文档,Parvector的线性超级画作,明确指出:
并行序列继承
seq
特征。
文档错误吗?还是我的代码有一个问题可以防止上部界限?
I am using Scala 3.1.3 with the parallel collections module, version 1.0.4 (Github).
I have the following type definition defining a generic version of a matrix:
type Matrix[T, C[_] <: Seq[_]] = C[C[T]]
As expected, initializing such a matrix works when using Vector as the collection type:
val vecMatrix: Matrix[Double, Vector] =
Vector(Vector(0.5, 0.6), Vector(0.6, 0.8))
However, using ParVector instead yields a compiler error:
val parvecMatrix: Matrix[Double, ParVector] =
ParVector(ParVector(0.5, 0.6), ParVector(0.6, 0.8))
Type argument collection.parallel.immutable.ParVector does not conform to upper bound [_] =>> Seq[?]
I read this as meaning ParVector is not a subtype of Seq. However, the documentation of scala.collection.parallel.ParSeqLike, a linear supertrait of ParVector, explicitly states:
Parallel sequences inherit the
Seq
trait.
Is the documentation wrong? Or is there an issue with my code that prevents the upper bound from working?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论