无形:抽象* arity并获取返回类型作为内部抽象类型成员的元组

时间:2014-08-17 14:51:14

标签: scala shapeless

abstract class Test[T] {
  type Value
}

// This is wrong with respect to Scala syntax.
def fun(tests: Test[_]*): Tuple(tests(0)#Value, tests(1)#Value) = {
}

我想要的是对任意数量的var args的arity抽象,其中类型由抽象类型成员Value持有,如上所示。例如,从任何arity转到Product,从Product转到HList或其他任何东西,然后从那个转到元组。

def test[F, A, L, S, Rc <: Test[_]](f: F)(implicit ftp: FnToProduct.Aux[F, L => S],
  ev: S <:< Seq[Rc#Value]) {

  val sq = ev(ftp(f))

  // now I'd like to build a type to reference the return sequence in a tuple
  // What is the real way to do the below?
  type ReturnTpe = sq.foldLeft(HNil)((l, col) => col#Value :: l).tupled
}

0 个答案:

没有答案