* John Meacham
Yeah, I have used those before, and still use Data.Data generics in jhc in some places but always found them unwieldy. As you note in your page, .exact structural children and logical children of a type may be different and I found them brittle when I modified a type, I ended up not being able to use standard types like [] and Maybe as much because I occasionally wanted to do more interesting things with traversal.
To be 100% clear, the approach proposed on that page doesn't have this limitation and doesn't conflate structural and logical children. (Sorry if I'm stating the obvious; I am not sure what you're referring to by "those".)
This hybrid explicit dictionary approach that applies the traversal to components in parallel seems to be a sweet spot. I attempted something like it before using typeclasses, but it didn't work because I needed to modify the traversal functions en route sometimes based on dynamic info so anything hardcoded at the type level, even with clever newtype deriving, I found lacking.
It's great that it works for you! I guess you're dealing with an intermediate representation of Haskell code. My motivation behind traverse-with-class is dealing with full Haskell AST as defined in haskell-src-exts. An traversal dictionary for that would be enormous, and most of the components would be the same in any particular traversal (but you don't know in advance which ones, of course). So traverse-with-class helped me to manage that complexity. I also had to deal with modifying the traversal; e.g. here's how I propagate scope information in haskell-names: https://github.com/haskell-suite/haskell-names/blob/master/src/Language/Hask... https://github.com/haskell-suite/haskell-names/blob/master/src/Language/Hask... It's a small edsl, so it may look weird at first, but it actually worked out pretty nicely. Roman