Studying formlessness, I wonder why this does not compile:
def someHList[H <: HList]: H = HNil
since the HNil object extends the HNil trait that extends the HList?
What is the correct way to define a method in an attribute that returns some HList that is implemented only by the expanding class?
I would like to do something like the following:
trait Parent {
def someHList[H <: HList]: H
}
object Child1 extends Parent {
def someHList[H <: HList] = HNil
}
object Child2 extends Parent {
def someHList[H <: HList] = 1 :: "two" :: HNil
}
Any advice is appreciated. Thank!
EDIT
To understand, as I understand it, what I defined in my original question:
1.) It is advisable not to indicate Hexplicitly in each implementation class, but let it be displayed (on the call site?).
2.) I would like to use HNil as the default implementation in the parent attribute, which can be overridden in subclasses. My example probably should have been:
trait Parent {
def someHList[H <: HList]: H = HNil
}
object Child extends Parent {
override def someHList[H <: HList] = 1 :: "two" :: HNill
}