Transform shapeless HList into a smaller HList

Viewed 1264

I have a shapeless HList that has the following structure:

type ABCAB = List[A] :: List[B] :: List[C] :: List[A] :: List[B] :: HNil
val abcab: ABCAB = List[A]() :: List(B) :: List[C]() :: List(A) :: List(B) :: HNil

that I would like to transform into a simpler type where lists of same type are appended, left to right:

type ABC = List[A] :: List[B] :: List[C] :: HNil        
val abc: ABC = abcab.magic                       // does magic exist in shapeless?
abc == List(A) :: List(B,B) :: List[C]() :: HNil // true

Is there some built-in functionality in shapeless v1.2.4 for this?

2 Answers
Related