A compiler error should inform you of the desire for an implicit value of type shapeless.ops.hlist.ToList[H, A[_]] . You can provide one of them by adding an implicit argument list to your method signature:
object B { def method[H <: HList](h: H)(implicit ev: ToList[H, A[_]]) = h.toList[A[_]] }
Now you can write the following:
val someAs = new A[Int] {} :: new A[String] {} :: HNil
And then:
scala> B.method(someAs) res0: List[A[_]] = List( $anon$1@5dd508ef , $anon$2@4d3db309 )
Almost every HList operation will require this kind of implicit evidence.
source share