Вы имели в виду нечто подобное?
import shapeless._
import shapeless.record._
import shapeless.labelled._
object expectedMetadata {
def apply[T](implicit g: GetFieldTypes[T]): Map[String, String] = g.getFieldTypes
sealed trait GetFieldTypes[T] {
def getFieldTypes: Map[String,String]
}
implicit val hnil = new GetFieldTypes[HNil] {
def getFieldTypes = Map.empty
}
implicit def hcons[K <: Symbol, V, T <: HList](implicit
wit: Witness.Aux[K],
typ: Typeable[V],
rest: GetFieldTypes[T]
) = new GetFieldTypes[FieldType[K, V] :: T] {
def getFieldTypes = rest.getFieldTypes + (wit.value.name -> typ.describe)
}
implicit def caseClass[T, G](implicit
lg: LabelledGeneric.Aux[T, G],
rest: GetFieldTypes[G]
) = new GetFieldTypes[T] {
def getFieldTypes = rest.getFieldTypes
}
}
Пример использования:
scala> case class Sample(id: String, date: LocalDate)
scala> expectedMetadata[Sample]
res1: Map[String,String] = Map(date -> LocalDate, id -> String)