[jhc] The Wonders of generic applicative traversal routines

John Meacham john at repetae.net
Tue May 13 13:26:30 UTC 2014


On Tue, May 13, 2014 at 4:28 AM, Roman Cheplyaka <roma at ro-che.info> wrote:
> 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".)

Ah, sorry. I was refering to the 'syb' ones. looks like gtraverse is a
better primitive.

> 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).

Actually, the data structure I am traversing and haskell-src are quite
related and have a common ancestor. They both branched from the same project
a long while ago though, Every now and again I consider merging in the
changes, maybe after I get done rewriting the existing code with traversals
I will look into it again. It would mean there is a lot less code I'd have
to modify if I can just swap out traversal routines.

> 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/Haskell/Names/Open/Base.hs#L54
> https://github.com/haskell-suite/haskell-names/blob/master/src/Language/Haskell/Names/Open/Instances.hs

Interesting. On the subject of module and haskell name resolution, A major
issue for jhc is how haddock just refuses to deal with code it can't handle
and barfs, especially on my module/name resolution which allows fully
recursive imports without restriction

(based on the formal definition given in
http://ogi.altocumulus.org/~hallgren/hsmod/Description.pdf
)

With the --annotate-src option, jhc can spit out annotated source specifying
exactly where each name maps, still trying to figure out how to get that
into haddock though but seeing as how bugs with attached fixes get closed
like this (http://trac.haskell.org/haddock/ticket/257) I'm not sure how
well that will go. Last time I tried to submit a patch that let haddock skip
over extensions it didn't recognize it wasn't put in.

> It's a small edsl, so it may look weird at first, but it actually worked out
> pretty nicely.

I do have aversions to implicit parameters in general, I think this is the
first time I've seen them in the wild actually. will have to look at what
you are doing with them.

   John



--
John Meacham - http://notanumber.net/
</roma at ro-che.info>


More information about the jhc mailing list