Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
Formatters for integral / fractional and strings.
Is support:
For all types:
- Grouping of the integral part (i.e: adding a custom char to separate groups of digits)
- Padding (left, right, around, and between the sign and the number)
- Sign handling (i.e: display the positive sign or not)
For floating:
- Precision
- Fixed Exponential Generic formatting
For integrals:
- Binary Hexa Octal / Character representation
- formatString :: Maybe (Int, AlignMode AlignAll, Char) -> Maybe Int -> String -> String
- formatIntegral :: (Show i, Integral i) => Format t t' Integral -> SignMode -> Maybe (Int, AlignMode k, Char) -> Maybe (Int, Char) -> i -> String
- formatFractional :: RealFloat f => Format t t' Fractional -> SignMode -> Maybe (Int, AlignMode k, Char) -> Maybe (Int, Char) -> Maybe Int -> f -> String
- data AltStatus
- data UpperStatus
- data FormatType
- data Format (k :: AltStatus) (k' :: UpperStatus) (k'' :: FormatType) where
- Decimal :: Format NoAlt NoUpper Integral
- Character :: Format NoAlt NoUpper Integral
- Binary :: Format CanAlt NoUpper Integral
- Hexa :: Format CanAlt CanUpper Integral
- Octal :: Format CanAlt NoUpper Integral
- Fixed :: Format CanAlt CanUpper Fractional
- Exponent :: Format CanAlt CanUpper Fractional
- Generic :: Format CanAlt CanUpper Fractional
- Percent :: Format CanAlt NoUpper Fractional
- Alternate :: Format CanAlt u f -> Format NoAlt u f
- Upper :: Format alt CanUpper f -> Format NoAlt NoUpper f
- data SignMode
- data AnyAlign where
- AnyAlign :: AlignMode (k :: AlignForString) -> AnyAlign
- data AlignMode (k :: AlignForString) where
- getAlignForString :: AlignMode k -> Maybe (AlignMode AlignAll)
- data AlignForString
Generic formating function
:: Maybe (Int, AlignMode AlignAll, Char) | Padding |
-> Maybe Int | Precision (will truncate before padding) |
-> String | |
-> String |
Format a string
:: (Show i, Integral i) | |
=> Format t t' Integral | |
-> SignMode | |
-> Maybe (Int, AlignMode k, Char) | Padding |
-> Maybe (Int, Char) | Grouping |
-> i | |
-> String |
Format an integral number
:: RealFloat f | |
=> Format t t' Fractional | |
-> SignMode | |
-> Maybe (Int, AlignMode k, Char) | Padding |
-> Maybe (Int, Char) | Grouping |
-> Maybe Int | Precision |
-> f | |
-> String |
Format a fractional number
Formatter details
data Format (k :: AltStatus) (k' :: UpperStatus) (k'' :: FormatType) where Source #
All the Formatters
Decimal :: Format NoAlt NoUpper Integral | |
Character :: Format NoAlt NoUpper Integral | |
Binary :: Format CanAlt NoUpper Integral | |
Hexa :: Format CanAlt CanUpper Integral | |
Octal :: Format CanAlt NoUpper Integral | |
Fixed :: Format CanAlt CanUpper Fractional | |
Exponent :: Format CanAlt CanUpper Fractional | |
Generic :: Format CanAlt CanUpper Fractional | |
Percent :: Format CanAlt NoUpper Fractional | |
Alternate :: Format CanAlt u f -> Format NoAlt u f | |
Upper :: Format alt CanUpper f -> Format NoAlt NoUpper f |
Existential version of AlignMode
AnyAlign :: AlignMode (k :: AlignForString) -> AnyAlign |
Internal usage only
data AlignMode (k :: AlignForString) where Source #
Alignement
AlignLeft :: AlignMode AlignAll | Left padding |
AlignRight :: AlignMode AlignAll | Right padding |
AlignInside :: AlignMode AlignNumber | Padding will be added between the sign and the number |
AlignCenter :: AlignMode AlignAll | Padding will be added around the valueber |