I would like to transform an HList type parameter to a nested Map-type, e.g. Int :: String :: String :: HNil
should become Map[Int, Map[String, Map[String, T]]]]
where T would be another type parameter of the same function, like:
def somedef[T, L <: HList](t: T)(implicit f: ???): f.Out
where f.Out is T in case of HNil or a nested Map-structure with dept L.size
Is there any way this can be done?
I'm not aware of a standard thing to do such a transformation, but you could roll out your custom converter in the same way as various HList ops (like
map
) are implemented inside shapeless (seetrait Mapper
). The code could be something like this:You can see it online