| Safe Haskell | Safe |
|---|---|
| Language | Haskell98 |
BuildBox.Pretty
Contents
Description
Pretty printing utils.
- class Pretty a where
- padRc :: Int -> Char -> Doc -> Doc
- padR :: Int -> Doc -> Doc
- padLc :: Int -> Char -> Doc -> Doc
- padL :: Int -> Doc -> Doc
- blank :: Doc
- pprEngDouble :: String -> Double -> Maybe Doc
- pprEngInteger :: String -> Integer -> Maybe Doc
- renderIndent :: Pretty a => a -> String
- renderPlain :: Pretty a => a -> String
- ppr :: Pretty a => a -> Doc
Documentation
The member prettyList is only used to define the instance Pretty
a => Pretty [a]. In normal circumstances only the pretty function
is used.
Minimal complete definition
Instances
| Pretty Bool | |
| Pretty Char | |
| Pretty Double | |
| Pretty Float | |
| Pretty Int | |
| Pretty Integer | |
| Pretty () | |
| Pretty Doc | |
| Pretty Bytes # | |
| Pretty Seconds # | |
| Pretty Sized # | |
| Pretty Used # | |
| Pretty Timed # | |
| Pretty BuildError # | |
| Pretty Platform # | |
| Pretty Environment # | |
| Pretty a => Pretty [a] | |
| Pretty a => Pretty (Maybe a) | |
| Pretty a => Pretty (Range a) # | |
| Pretty a => Pretty (Comparison a) # | |
| (Pretty a, Pretty b) => Pretty (a, b) | |
| (Pretty a, Pretty b, Pretty c) => Pretty (a, b, c) | |
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).
renderIndent :: Pretty a => a -> String Source #
Render a thing as a string.
renderPlain :: Pretty a => a -> String Source #
Render a thing with no indenting.