Scala:Parvector不符合上限[_] =>> seq [?]

发布于 2025-02-13 09:58:28 字数 850 浏览 0 评论 0原文

我正在使用平行集合模块,版本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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文