I want to build a pipeline dependency where 2nd level depends on 1st one, 3rd depends on 2nd AND 1st and so on …
I have defined such structures
trait Level[A <: Level[A]] {
type DependsOn <: Level[DependsOn]
val previousDependencies: List[DependsOn]
}
trait First extends Level[First] {
type DependsOn = Nothing
}
trait Second extends Level[Second] {
type DependsOn = First
}
class FirstLevel extends First {
val previousDependencies = List.empty
}
class SecondLevel(val previousDependencies: List[FirstLevel]) extends Second
Until now it all works. But I can't get it to work with third structure that depends on two previous ones. I have tried shapeless Product
and Coproduct
but I can't get it to work properly. I know it has to be a Product
meaning sum type, to it implies using shapeless HList
. Please help :)