使用 simulacrum 的类型类定义中的类型不匹配
Type mismatch in typeclass definition using simulacrum
我很难定义以下类型类:
@typeclass trait ElementIterator[It[_]] {
def record[Item[Element], Element <: ElementT, Ctx >: Context[ElementT]]
(iterator: It[Item[Element]],
name: String,
what: RefExpr[Ctx, Any])
(implicit ctxLike: ContextLike[Item],
withVariables: WithVariables[Item[Element]]
): It[Item[Element]]
}
我收到以下错误:
Error:(11, 4) type mismatch;
found : sre.task.Core.WithVariables[Item[A]]
required: sre.task.Core.WithVariables[Item[Element]]
Note: implicit value elementIteratorForIterator is not applicable here because it comes after the application point and it lacks an explicit result type
@typeclass trait ElementIterator[It[_]] {
我不确定这里发生了什么。在我看来,当在隐式参数列表中使用 Element
时,它将被重新分配给一个新类型变量 A
而不是将其与 iterator
s 类型中的变量匹配。
我真正想要的是 WithVariables
具有与 It
.
相同的类型参数
这里到底发生了什么?这是一个错误吗?
这很可能是拟像的限制。考虑在 github 上提交错误报告。
解决方法是禁用 ops
.
的生成
@typeclass trait ElementIterator[It[_]] {
@noop def record[Item[Element], Element <: ElementT, Ctx >: Context[ElementT]]
(iterator: It[Item[Element]],
name: String,
what: RefExpr[Ctx, Any])
(implicit ctxLike: ContextLike[Item],
withVariables: WithVariables[Item[Element]]
): It[Item[Element]]
}
我很难定义以下类型类:
@typeclass trait ElementIterator[It[_]] {
def record[Item[Element], Element <: ElementT, Ctx >: Context[ElementT]]
(iterator: It[Item[Element]],
name: String,
what: RefExpr[Ctx, Any])
(implicit ctxLike: ContextLike[Item],
withVariables: WithVariables[Item[Element]]
): It[Item[Element]]
}
我收到以下错误:
Error:(11, 4) type mismatch;
found : sre.task.Core.WithVariables[Item[A]]
required: sre.task.Core.WithVariables[Item[Element]]
Note: implicit value elementIteratorForIterator is not applicable here because it comes after the application point and it lacks an explicit result type
@typeclass trait ElementIterator[It[_]] {
我不确定这里发生了什么。在我看来,当在隐式参数列表中使用 Element
时,它将被重新分配给一个新类型变量 A
而不是将其与 iterator
s 类型中的变量匹配。
我真正想要的是 WithVariables
具有与 It
.
这里到底发生了什么?这是一个错误吗?
这很可能是拟像的限制。考虑在 github 上提交错误报告。
解决方法是禁用 ops
.
@typeclass trait ElementIterator[It[_]] {
@noop def record[Item[Element], Element <: ElementT, Ctx >: Context[ElementT]]
(iterator: It[Item[Element]],
name: String,
what: RefExpr[Ctx, Any])
(implicit ctxLike: ContextLike[Item],
withVariables: WithVariables[Item[Element]]
): It[Item[Element]]
}