私はこのようなことをしたいと思います:
def run(subjects: List[Subject]) = {
val configs = compute()
subjects.map(s => configs.map(c => test(s,c)))
// or flatMap, I don't really care at this point
}
私のユースケースでは、サブジェクトは実際Subject[T]
にはあり、結果にはタイプセーフなバージョンが必要T
です。ので、私は持っています:
def run[L <: HList](subjects: L)(implicit mapper: Mapper[testFun.type, L]) = {
val configs = compute()
subjects.map(testFun)
}
ただし、この投稿testFun
によると、シングルトン型が必要な構成を渡すことができません。
オプションは次のとおりです。
val cfgHL = HList.fill(subjects.length)(configs)
(subjects zip cfgHL).map(testFun)
しかし、HList
現在、手術はありませんfill
。ヒントはありますか?