[Haskell] pretty printing Haskell code with auto parens?

Malcolm Wallace Malcolm.Wallace at cs.york.ac.uk
Wed Apr 13 05:21:28 EDT 2005


"Conal Elliott" <conal at 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


More information about the Haskell mailing list