I have this situation (stripped down to the essential parts)
class Foo[L <: HList](columns: L) {
class toRecord(row: Row) extends Poly1 {
implicit def caseColumn[T] = at[Column[T]] { /* map to a record field */ }
}
def asRecord = {
val resultSet: Stream[Row] = // computation to get result set
resultSet.map { row =>
val m = new toRecord(row) // this can't work
columns.map(m)
}
}
}
This doesn't work since map
wants a stable identifier and m
is not.
So I would need as many Poly1 singleton objects
as many rows I have in the result set.
This is the same problem discussed here: https://groups.google.com/forum/#!topic/shapeless-dev/P5DXRgnzqkY, but I can't find a way of making this work.
In the linked discussion Miles Sabin proposed a fold
with a Poly2
instead of a map
with a Poly1
, but I can't figure how to use this suggestion in my case.
RightFolder
has 3 type arguments, not 4, should it beRightFolder.Aux
? And theB
type param in thecaseColumn
has to beB <: HList
, otherwise the concatenation with::
does not work. – Chalkstone