[Haskell-cafe] Indenting with PPrint

Brandon Michael Moore brandon at heave.ugcs.caltech.edu
Tue May 8 14:51:18 EDT 2007


On Tue, May 08, 2007 at 07:39:15AM +0100, Joel Reymont wrote:
> 
> >If you happen to be formatting C I've also worked out how to get  
> >nice argument
> >lists out of both pretty printers.
> 
> I'm formatting C# but I'll certainly take your arg list tips.

These narrow like

foo (a, b)
foo (a,
     b)
foo
  (a, b)
foo
  (a,
   b)

as space gets tight.

PPrint:

name <> nest 2 softline <> parens (align (sep (punctuate comma args)))

Text.PrettyPrint.HughesPJ:

sep [name, lparen] <> sep (punctuate comma args) <> rparen

Brandon


More information about the Haskell-Cafe mailing list