Portability | GHC |
---|---|
Stability | experimental |
Maintainer | [email protected] |
Safe Haskell | None |
Formatting.Formatters
Contents
Description
Formatting functions.
- text :: Format Text
- stext :: Format Text
- string :: Format String
- builder :: Format Builder
- fconst :: Builder -> Format a
- int :: Integral a => Format a
- float :: Real a => Format a
- expt :: Real a => Int -> Format a
- fixed :: Real a => Int -> Format a
- prec :: Real a => Int -> Format a
- sci :: Format Scientific
- scifmt :: FPFormat -> Maybe Int -> Format Scientific
- shortest :: Real a => Format a
- commas :: (Buildable n, Integral n) => Format n
- ords :: Integral n => Format n
- left :: Buildable a => Int -> Char -> Format a
- right :: Buildable a => Int -> Char -> Format a
- hex :: Integral a => Format a
- build :: Buildable a => Format a
- class Buildable p
Text/string types
Numbers
float :: Real a => Format aSource
Render some floating point with the usual notation, e.g. 123.32 => "123.32"
expt :: Real a => Int -> Format aSource
Render a floating point number using scientific/engineering notation (e.g. 2.3e123), with the given number of decimal places.
fixed :: Real a => Int -> Format aSource
Render a floating point number using normal notation, with the given number of decimal places.
prec :: Real a => Int -> Format aSource
Render a floating point number, with the given number of digits of precision. Uses decimal notation for values between 0.1 and 9,999,999, and scientific notation otherwise.
sci :: Format ScientificSource
Render a scientific number.
shortest :: Real a => Format aSource
Render a floating point number using the smallest number of digits that correctly represent it.
commas :: (Buildable n, Integral n) => Format nSource
Add commas to an integral, e.g 12000 -> 12,000.
Padding
left :: Buildable a => Int -> Char -> Format aSource
Pad the left hand side of a string until it reaches k characters wide, if necessary filling with character c.
right :: Buildable a => Int -> Char -> Format aSource
Pad the right hand side of a string until it reaches k characters wide, if necessary filling with character c.
Bases
hex :: Integral a => Format aSource
Render an integer using hexadecimal notation. (No leading 0x is added.)
Buildables
class Buildable p
The class of types that can be rendered to a Builder
.
Instances