You cannot do this. note that
must be concluded at runtime
is a contradiction. Type inference only works at compile time.
In other words, when you write something like
val list: A :: B :: C :: C :: HNil = ...
list . , . , , toHlistMagical:
val list: List[Parent] = A() :: B() :: C() :: C() :: Nil
val hlist = list.toHlistMagical
:
def getHlist(list: List[Parent]) = list.toHlistMagical
, ? , , , A, B, C, C :
getHlist(C() :: B() :: A() :: A() :: Nil)
Any, list, HList, .
toHlist :
def getHlist(list: List[Parent]) = list.toHlist[A :: B :: C :: C :: HNil]
getHlist Option[A :: B :: C :: C :: HNil], , toHlist list Some, None, .