Typed partition and generalized groupBy in macros