Re: [Haskell-cafe] generating parens for pretty-printing code in haskell-src-exts

2012-01-21 Thread Niklas Broberg
Hi Conal, On Sun, Jan 15, 2012 at 6:45 AM, Conal Elliott co...@conal.net wrote: 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

Re: [Haskell-cafe] generating parens for pretty-printing code in haskell-src-exts

2012-01-21 Thread Levent Erkok
Neil Mitchell's HLint (http://community.haskell.org/~ndm/hlint/) warns about extra parens in Haskell code. So, it must have code for detecting those. I wonder if you can just insert parens liberally in a first run, and then use his algorithm to remove those that are unnecessary. The two passes can

[Haskell-cafe] generating parens for pretty-printing code in haskell-src-exts

2012-01-14 Thread Conal Elliott
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

Re: [Haskell-cafe] generating parens for pretty-printing code in haskell-src-exts

2012-01-14 Thread Stephen Tetley
Hi Conal I don't know if any Haskell src-exts code exists. Norman Ramsey has published an algorithm for it, plus ML code: http://www.cs.tufts.edu/~nr/pubs/unparse-abstract.html I've transcribed the code to Haskell a couple of times for small expression languages. As far as I remember you need