phadej / staged-gg

Staged GHC.Generics
BSD 3-Clause "New" or "Revised" License
4 stars 1 forks source link

Is a generic traverse almost possible? #12

Open treeowl opened 2 years ago

treeowl commented 2 years ago

I understand that due to the limitations of typed template Haskell, we can't really hope to implement a proper genericTraverse. Unfortunately, I can't currently see an obvious approach to writing one with these generics even if those limitations are overcome. Imagine we try to implement something like

gtr :: (Generic1 t, GTrav (Rep1 t), Quote q) => Code q (Dict (Applicative f)) -> Code q (a -> f b) -> Code q (t a) -> Code q (f (t b))

How would we go about it? Once we apply from1 to the Code q (t a) argument, we find we need

_ :: Rep1 t (Code q) a -> Code q (f (t b))

How can we find a place to use to1 to make code for constructing the result containers?