I wished Haskell as nice macro system (i.e. without IO or stage restriction) but it doesn’t seem that there is an appetite for it. So I was reading (for the nth time) about generic and I was wandering if it would make sense and be useful to be able use type families to deconstruct and transform type ala Generic.
Type families can be seen as a function taking a type and returning a new one, so why not allow them transform the type. It could be used to create a HKD from a plain record, merge to records etc …
For example one could write (using Generic class)
type family F f a where
F f (a :+: b) = F f a :+: F f b
F f (a :*: b) = F f a :*: F f b
F f a = f a
Would that be of any use, or is there already a way to do so (or something else better in the pipeline achieving the same goal )?