Is there a way to persist(I mean keep in a var) (is it possible?) a dynamically growing HList
? my pseudo code:
var llist = 1 :: 2 :: "foo" :: true :: HNil
var list: HList = HNil // here is a wrong type! in fact we dont need HList type
object mapFunc extends Poly1 {
implicit def default[T] = at[T](t => { list = t :: list })
}
llist map mapFunc
Obviously, this code doesnt work. so ofc it works, but we cant even do list.head
by reason of incorrect HList
typing (as i recognize, list
even doesnt keep type parameter at all).
The result type:
shapeless.HList = true :: foo :: 2 :: 1 :: HNil
so, that's incorrect.
EDIT
the information above is not enough, i see.
So i wanted to have in some object, smth like a variable, which can be of any HList
type;
class className {
var hlist: HList = _ // it is not correct
}
in order to pass sometimes HList
in this variable;
className.hlist = llist
p.s. @milessabin mb right that its better to find another solution to my problem.