buildbox-2.1.9.4: Rehackable components for writing buildbots and test harnesses.

Safe HaskellSafe
LanguageHaskell98

BuildBox.Pretty

Description

Pretty printing utils.

Synopsis

Documentation

class Pretty a where Source #

Minimal complete definition

ppr

Methods

ppr :: a -> Doc Source #

padRc :: Int -> Char -> Doc -> Doc Source #

Right justify a doc, padding with a given character.

padR :: Int -> Doc -> Doc Source #

Right justify a string with spaces.

padLc :: Int -> Char -> Doc -> Doc Source #

Left justify a string, padding with a given character.

padL :: Int -> Doc -> Doc Source #

Left justify a string with spaces.

blank :: Doc Source #

Blank text. This is different different from empty because it comes out a a newline when used in a vcat.

pprEngDouble :: String -> Double -> Maybe Doc Source #

Pretty print an engineering value, to 4 significant figures. Valid range is 10^(-24) (y/yocto) to 10^(+24) (Y/Yotta). Out of range values yield Nothing.

examples:

  liftM render $ pprEngDouble "J" 102400    ==>   Just "1.024MJ"
  liftM render $ pprEngDouble "s" 0.0000123 ==>   Just "12.30us"
  

pprEngInteger :: String -> Integer -> Maybe Doc Source #

Like pprEngDouble but don't display fractional part when the value is < 1000. Good for units where fractional values might not make sense (like bytes).