bug in fptools/libraries/haskell-src/Language/Haskell/Pretty.hs

Bernard James POPE bjpop at cs.mu.OZ.AU
Wed Jul 17 08:59:24 EDT 2002


Hi,

When pretty printing this haskell code:

   case x of 
      -1 -> x

The pretty printer in PPSemiColon mode produces something like:

   case x of
      {- 1

thus making a false comment, due to the brace crashing into the
negative sign.

I think this is a design issue, but probably the offending code is:

   topLevel :: Doc -> [Doc] -> Doc
   topLevel header dl = do
            e <- fmap layout getPPEnv
            case e of
                PPOffsideRule -> header $$ vcat dl
                PPSemiColon -> header $$ (braces . vcat . punctuate semi) dl
                PPInLine -> header $$ (braces . vcat . punctuate semi) dl
                PPNoLayout -> header <+> (braces . hsep . punctuate semi) dl


Also, while I'm on the topic of the pretty printer I wonder whether
it would be possible (and considered a good idea) to add an argument
to PPHsMode that allows for wider lines of code, I think currently it is
starting to get flustered around 100 columns or so.  Perhaps there is already
a good way of doing this and I'm just missing it?

The reason I ask is that I am pretty printing some code which is the output
of a program transformation. Quite often the code creeps off to the far rhs,
at this point the pretty printer starts aggressively breaking lines which
is less than pretty.

Cheers,
Bernie.



More information about the Glasgow-haskell-bugs mailing list