[Haskell-cafe] Meaning of "ribbonsPerLine" at Text.PrettyPrint.HughesPJ ?

Malcolm Wallace Malcolm.Wallace at cs.york.ac.uk
Thu Jun 19 08:44:47 EDT 2008

To answer the original question (in the subject line),

  "The ribbon ratio is the number of times the ribbon fits into a line.
   The ribbon is the number of characters on a line excluding leading
   and trailing white spaces.
See also the original paper on which the Text.PrettyPrint.HughesPJ code
is based:
section 7.4.

The idea is that the pretty-printer should not cram lots of text into a
single line, if it would look nicer split across two (shorter) lines.
The ribbonsPerLine ratio is the factor that determines this level of
"prettiness".  A ratio of 1.0 means to cram everything into the line if
you can.  A larger ratio means to go for more lines, but less text on
each.  Somewhere between 1.2 and 1.8 is likely to be more or less
pleasing: 1.0 will be ugly, 2.0 or above will look decidedly fragmented.


More information about the Haskell-Cafe mailing list