generics-sop icon indicating copy to clipboard operation
generics-sop copied to clipboard

Staged generics don't obviously support traversal

Open treeowl opened this issue 3 years ago • 1 comments

One of the trickiest things to implement well using plain GHC generics is a generic traverse. One of a few rather involved bags of tricks are needed to avoid extra fmap invocations in the ambient Applicative, and none of these are sufficient (with current GHC) to get the generic representations to inline away reliably. I don't claim to understand staged generics fully, but it's not at all obvious to me that they are up to the task either. Are they? If so, how?

treeowl avatar Feb 08 '22 00:02 treeowl

Yes, this is a tricky aspect. Section 6.5 of the staged-sop paper talks about this problem and presents something which I consider to be a solution, although I wouldn't be surprised if improvements are possible in this area. Does this help, or do you have reason to believe the approach described there would not work in general?

kosmikus avatar Feb 18 '22 07:02 kosmikus