为约束类型构造函数定义类类

时间:2015-09-28 09:40:21

标签: scala types scalaz shapeless type-constraints

我经常遇到这个问题,特别是在使用无形状的地方,但找不到合理的解决方案。更具体地说,在我的上一个案例中,我想为scalaz Coyoneda定义spray Directiveshapeless HList受{{3}}约束。尝试这样做会给出一个合理的错误:

Error:(6, 12) kinds of the type arguments (spray.routing.Directive,A,A) do not conform to the expected kinds of the type parameters (type F,type A,type B).
spray.routing.Directive's type parameters do not match type F's expected parameters:
type L's bounds <: shapeless.HList are stricter than type _'s declared bounds >: Nothing <: Any

  Coyoneda[Directive, A, A](dir)(identity)
           ^

由于提供的函数(例如在这种情况下为identity)知道约束,我猜这将是一个有效的定义。是否有任何我从理论上缺失的东西以及任何定义它的方法?

0 个答案:

没有答案
相关问题