scala - 找不到路径相关类型的值

标签 scala dependent-type

也许我需要复习依赖类型,但我不明白为什么以下方法不起作用:

trait Code { type In; type Out }

trait Handler[In, Out]

class Foo(val code: Code)(handler: Option[Handler[code.In, code.Out]])

错误:
<console>:52: error: not found: value code
       class Foo(val code: Code)(handler: Option[Handler[code.In, code.Out]])
                                                         ^
<console>:52: error: not found: value code
       class Foo(val code: Code)(handler: Option[Handler[code.In, code.Out]])
                                                                  ^

编辑 : 我现在可以看到如何解决这个问题了。我仍然想知道为什么上述方法不起作用?

最佳答案

另一种解决方法:

trait Foo {
  val code: Code
  val handler: Handler[code.In, code.Out] 
}

关于scala - 找不到路径相关类型的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24207625/

相关文章:

coq - 如何在 coq 中将定理应用于带有限制的定义

scala - Scala 中的链接类型

dependent-type - 在精益模式匹配时如何传播假设

recursion - 依赖参数的结构递归

scala - 使用 Java 枚举的类型别名

scala - 在 Scala 中找不到 BigInt 的 intValueExact

scala - 用于嵌套集合的 zipWithIndex(没有可变状态的发布)

scala - Akka HTTP 2.0 使用 SSL (HTTPS)

scala - 如何在 Kafka Streams 中使用 Futures

scala - 在scala中,如何指示编译器实现两个抽象类型的等价?