I'm upgrading a library where I translate Haskell to another language. Right now I'm using Meta.Parse to read in a Haskell module, and get back its TemplateHaskell AST, as described here.
The problem I'm running into is that, when I run the parse, I get a bunch of infix operators parsed as UInfixE and UInfixP, meaning that they are of unresolved associativity.
The description of the associativity talks about how the Haskell compiler resolves these.
I'm wondering, is there a function avaliable which can do this reassociation on the trees I get from parsing? I'm looking for something like this:
reassoc :: [Dec] -> [Dec]
I could write the massive AST traversal that does this, but it seems like it would be a massive amount of boilerplate, and clearly the function already exists in some form (hopefully in a form that plays nice with TH).
Does such a thing exist? Is there an easy way to get rid of unresolved infix operators in the AST I get from parsing declarations?
EDIT: Even a function which, given the Name of an operator, could give its precedence and associativity, would be very useful.