Safe Haskell | None |
---|---|

Language | Haskell2010 |

## Synopsis

- octF :: Integral a => a -> Builder
- binF :: Integral a => a -> Builder
- baseF :: (HasCallStack, Integral a) => Int -> a -> Builder
- floatF :: Real a => a -> Builder
- exptF :: Real a => Int -> a -> Builder
- fixedF :: Real a => Int -> a -> Builder
- commaizeF :: (Buildable a, Integral a) => a -> Builder
- ordinalF :: (Buildable a, Integral a) => a -> Builder
- groupInt :: (Buildable a, Integral a) => Int -> Char -> a -> Builder
- atBase :: Integral a => Int -> a -> String
- showSigned' :: Real a => (a -> ShowS) -> a -> ShowS
- intToDigit' :: Int -> Char

# Documentation

`>>>`

`import Fmt`

octF :: Integral a => a -> Builder Source #

Format a number as octal:

`>>>`

"[7, 10, 11, 12]"`listF' octF [7,8,9,10]`

binF :: Integral a => a -> Builder Source #

Format a number as binary:

`>>>`

"[111, 1000, 1001, 1010]"`listF' binF [7,8,9,10]`

baseF :: (HasCallStack, Integral a) => Int -> a -> Builder Source #

Format a number in arbitrary base (up to 36):

`>>>`

"111201101"`baseF 3 10000`

`>>>`

"41104"`baseF 7 10000`

`>>>`

"7ps"`baseF 36 10000`

floatF :: Real a => a -> Builder Source #

Format a floating-point number:

`>>>`

"3.1415"`floatF 3.1415`

Numbers smaller than 1e-6 or bigger-or-equal to 1e21 will be displayed using scientific notation:

`>>>`

"[0.000001, 9.0e-7]"`listF' floatF [1e-6,9e-7]`

`>>>`

"[900000000000000000000.0, 1.0e21]"`listF' floatF [9e20,1e21]`

exptF :: Real a => Int -> a -> Builder Source #

Format a floating-point number using scientific notation, with the given amount of decimal places.

`>>>`

"[3.14159e0, 1.00000e-1, 1.00000e1]"`listF' (exptF 5) [pi,0.1,10]`

fixedF :: Real a => Int -> a -> Builder Source #

Format a floating-point number without scientific notation:

`>>>`

"[3.14159, 0.10000, 10.00000]"`listF' (fixedF 5) [pi,0.1,10]`

commaizeF :: (Buildable a, Integral a) => a -> Builder Source #

Break digits in a number:

`>>>`

"15,830,000"`commaizeF 15830000`

ordinalF :: (Buildable a, Integral a) => a -> Builder Source #

Add an ordinal suffix to a number:

`>>>`

"15th"`ordinalF 15`

`>>>`

"22nd"`ordinalF 22`

intToDigit' :: Int -> Char Source #