Hey, this is my blog

It is somewhat abandoned.

Scala Slick Group

In slick, if each foo has many bars and I need to retrive several foos and associtated bars I will do something like this:

The type of join will be a List[(foo,bar)]. I want the bars grouped by foo, not a tuple of each. I can transform to a grouped format like so:

This groups one element from a tuple into a sublist. If I later add the requirement that each bar has many baz than I need to another method that transforms tuples of 3 into two nested lists.

I can do the same for grouping into three nested lists:

There is obviously a pattern here that should be abstractable. However, at the type level, tuples of different sizes are unqiue types, so this gets tricky. It should be possible to use the shapeless library to abstract over the tuple size. In practice I never need more than group3, so this will stay in its expanded form for now.