buildbox-2.2.1.1: 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 -> Text Source #

data Text :: * #

A space efficient, packed, unboxed Unicode text type.

Instances

Pretty Text Source # 

Methods

ppr :: Text -> Text Source #

type Item Text 
type Item Text = Char

(%) :: Text -> Text -> Text Source #

Append two text strings.

(%%) :: Text -> Text -> Text Source #

Append two text strings separated by a space.

empty :: Text Source #

An empty text string.

char :: Char -> Text Source #

Convert a single Char to text.

string :: String -> Text Source #

Convert a String to text.

text :: Text -> Text Source #

Convert a Text to Text (id).

vcat :: [Text] -> Text Source #

Concatenate a list of text vertically.

vsep :: [Text] -> Text Source #

Concatenate a list of text vertically, with blank lines in between.

hcat :: [Text] -> Text Source #

Concatenate a list of text.

hsep :: [Text] -> Text Source #

Concatenate a list of text, with spaces in between.

parens :: Text -> Text Source #

Wrap a text thing in round parens.

braces :: Text -> Text Source #

Wrap a text thing in round parens.

brackets :: Text -> Text Source #

Wrap a text thing in round parens.

angles :: Text -> Text Source #

Wrap a text thing in round parens.

indents :: Int -> [Text] -> Text Source #

Indent some text by the given number of characters.

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

Right justify a doc, padding with a given character.

padR :: Int -> Text -> Text Source #

Right justify a string with spaces.

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

Left justify a string, padding with a given character.

padL :: Int -> Text -> Text Source #

Left justify a string with spaces.

pprEngDouble :: String -> Double -> Maybe Text 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 Text 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).