You should be able to write a FlipTypeMap
... but that's not very composable. A better choice here might be to do the type-level version of map ($ 2) (map (/) [1,2,3])
instead of map (flip (/) 2) [1,2,3]
by taking advantage of -XPolyKinds
:
type family TypeMap (a :: j -> k) (xs :: [j]) :: [k]
type instance TypeMap t '[] = '[]
type instance TypeMap t (x ': xs) = t x ': TypeMap t xs
type family ApList (xs :: [j -> k]) (a :: j) :: [k]
type instance ApList '[] t = '[]
type instance ApList (x ': xs) t = x t ': ApList xs t
test2 :: HList rqs -> HList (TypeMap (,) rqs `ApList` Int)
test2 HNil = HNil
test2 (HCons x xs) = HCons (x,3) $ test2 xs