
On Mon, Sep 20, 2010 at 12:47 PM, Simon Peyton-Jones
Thomas had it right; it’s just a particular kind of fold. The key parts of the traversal would be:
· Occurrences. getExpr g (HsVar v) = g_occ g v
Don't I need to work on LHsExpr rather than HsExpr? How would I otherwise get the location? getExpr :: Gather v res -> LHsExpr v -> res getExpr g (L loc e) = case e of HsVar v -> g_occ g (L loc v) HsApp e1 e2 -> g_union g (getExpr g e1) (getExpr g e2)
· Binding> getExpr (Lam v e) = g_del v (getExpr g e)
I still don't quite the purpose of this, is it to say the v is now shadowing whatever had the same name in the scope surrounding the lambda? Or is "g_del" intended to mean "g_declaration" and capture the declaration sites (and if so, how I know if it's a exported top-level declaration or not)?
Does that help? Maybe one could generalise a bit.
Definitely. Thanks for the pointers. Cheers, Johan