I write general code for processing lists of instances of the case class, collecting values ββin each field, combining, and then passing it to the library.
Using formless LabelledGeneric and polymorphic functions, it looks like this:
object toNamedSingletonListOfValues extends Poly1 { implicit def caseField[K,T] = at[FieldType[K, T]](field => { field.key -> List[T](field) }) } val generic = LabelledGeneric[MyClass] val records = listOfMyClassInstances.map(generic.to) val values = records.map(_.map(toNamedSingletonListOfValues)) // Then combining and passing
However, I need a way to get field.key , because the library needs parameter names.
Could you offer a solution?
scala record shapeless
Uspenskiy Vladimir
source share