What pretty printers are available for Haskell code (not necessarily complete) that handle automatic insertion of minimally required parentheses? I assumed that Language.Haskell.Pretty did that, but apparently it relies on manual insertion of parentheses in the abstract syntax. Thanks, - Conal
No reply yet. Alternatively, does anyone happen to have a HsExp->HsExp (for Language.Haskell.Syntax) pass that inserts disambiguating parentheses as needed, to be applied just before pretty-printing? Cheers, - Conal -----Original Message----- From: haskell-bounces@haskell.org [mailto:haskell-bounces@haskell.org] On Behalf Of Conal Elliott Sent: Friday, April 08, 2005 3:54 PM To: haskell@haskell.org Subject: [Haskell] pretty printing Haskell code with auto parens? What pretty printers are available for Haskell code (not necessarily complete) that handle automatic insertion of minimally required parentheses? I assumed that Language.Haskell.Pretty did that, but apparently it relies on manual insertion of parentheses in the abstract syntax. Thanks, - Conal
On Tue, Apr 12, 2005 at 06:33:13PM -0700, Conal Elliott wrote:
No reply yet.
Alternatively, does anyone happen to have a HsExp->HsExp (for Language.Haskell.Syntax) pass that inserts disambiguating parentheses as needed, to be applied just before pretty-printing?
There is one included in 'hatchet' which I have succescfully reused in other projects. A bug is that it doesn't refix infix patterns, but that should be easy to fix. http://www.cs.mu.oz.au/~bjpop/hatchet.html You will probably have to write something to collect fixities from imported modules. -- John Meacham - ⑆repetae.net⑆john⑈
"Conal Elliott" <conal@conal.net> writes:
What pretty printers are available for Haskell code (not necessarily complete) that handle automatic insertion of minimally required parentheses? I assumed that Language.Haskell.Pretty did that, but apparently it relies on manual insertion of parentheses in the abstract syntax.
The Hat tracing system has a pretty-printer for Haskell expressions that inserts minimal parentheses. However, the Haskell expressions themselves are not parsed, they are reconstructed from runtime trace data. Because of this, the "abstract syntax tree" has significant differences from a standard internal compiler representation. Nevertheless, you might find the pretty-printing code has some useful algorithm that you can rework for your own purposes. (Note that the PP combinator library is Wadler-style, not HughesPJ-style.) http://haskell.org/hat Regards, Malcolm
participants (3)
-
Conal Elliott -
John Meacham -
Malcolm Wallace