Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
是否有可能以某种方式创建为嵌套类型绑定的上下文?像这样的东西:
def f[T : U[List]](a: T)
Ofc,这不是 Scala 语法,而是说明了我想要实现的目标,即在隐式U[List[T]]. 这可能吗?
U[List[T]]
谢谢。
您可以使用类型别名来做到这一点:
type UList[X] = U[List[X]] def f[T : UList](a: T)
或者
def f[T:({type UL[X] = U[List[X]]})#UL](a: T)