<div>Hi Conal,</div><div><br></div><div>On Sun, Jan 15, 2012 at 6:45 AM, Conal Elliott <span dir="ltr"><<a href="mailto:conal@conal.net">conal@conal.net</a>></span> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I'm using haskell-src-exts together with SYB for a code-rewriting project, and I'm having difficulty with parenthesization. I naïvely expected that parentheses would be absent from the abstract syntax, being removed during parsing and inserted during pretty-printing. It's easy for me to remove them myself, but harder to add them (minimally) after transformation. Rather than re-inventing the wheel, I thought I'd ask for help.<br>
</blockquote><div><br></div><div>It's not at all straight-forward to properly insert minimal parentheses during pretty-printing, since "minimal" is a semantic notion. For that to work, we would need the pretty-printer to take a set of known fixities as an argument, just like the parser currently does. I'm not opposed to the idea in principle, but it's not how it currently works.</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Has anyone written automatic minimal parens insertion for haskell-src-exts?<span class="HOEnZb"><font color="#888888"><br>
</font></span></blockquote><div><br></div><div>... or we could do it this way, in a two-stage modular process which gives even more flexibility. I'm not aware of any such functionality, currently, but if it exists (or happens to come into existence) then I would be interested in including it in haskell-src-exts.<br>
</div><div><br></div><div>Best regards,</div><div><br></div><div>/Niklas</div>