Collecting all external names in a module
claus.reinke at talk21.com
Sat Sep 18 15:01:05 EDT 2010
> I started writing a manual traversal of the RenamedSource AST
> (as I want qualified names) but I thought I check if I'm going
> about this right before I spend all the time required to write
> the traversal for the whole AST.
Manual traversal code on ASTs tends to consist mainly
of boilerplate, so I'd like to emphasize Simon's suggestion:
> You could even use generic programming to do it (all the Hs
> things are in class Data I think).
There is a page on the GHC wiki on generic AST traversals
by now probably out of date (eg, the instances may now be
available without needing ghc-syb, I think?), but it should
get you started (using generic programming is a lot easier
than trying to understand its types, you just need to make
sure that your traversals avoid some holes in the GHC
ASTs; there's a Data-based show variant that illustrates
the idea), and you might be able to correct out-of-date info.
More information about the Glasgow-haskell-users