Mapped provides exactly this limitation without the additional need for Length . From the documentation :
Enter a class that indicates that the result of wrapping each HList L element in the constructor of type F is Out .
Here's what it looks like in 1.2.4:
import shapeless._ def foo[L1 <: HList, L2 <: HList](l1: L1, l2: L2)(implicit ev: MappedAux[L1, Ordering, L2] ) = () val l1 = 1 :: 1.2 :: "hello" :: HNil val l2 = Ordering[Int] :: Ordering[Double] :: Ordering[String] :: HNil val l3 = Ordering[Int] :: Ordering[Double] :: Ordering[Char] :: HNil
And then:
scala> foo(l1, l2) scala> foo(l1, l3) <console>:17: error: could not find implicit value for parameter ev: ...
As expected. For 2.0, just add shapeless.ops.hlist._ import and replace MappedAux with Mapped.Aux and you are ready to go.
Travis brown
source share