Safe Haskell | Safe-Inferred |
---|---|
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
Synopsis
- formatString :: forall paddingWidth precision. (Integral paddingWidth, Integral precision) => Maybe (paddingWidth, AlignMode 'AlignAll, Char) -> Maybe precision -> String -> String
- formatIntegral :: Integral paddingWidth => Integral i => Format t t' 'Integral -> SignMode -> Maybe (paddingWidth, AlignMode k, Char) -> Maybe (Int, Char) -> i -> String
- formatFractional :: (RealFloat f, Integral paddingWidth, Integral precision) => Format t t' 'Fractional -> SignMode -> Maybe (paddingWidth, AlignMode k, Char) -> Maybe (Int, Char) -> Maybe precision -> 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 formatting function
:: forall paddingWidth precision. (Integral paddingWidth, Integral precision) | |
=> Maybe (paddingWidth, AlignMode 'AlignAll, Char) | Padding |
-> Maybe precision | Precision (will truncate before padding) |
-> String | |
-> String |
Format a string
:: Integral paddingWidth | |
=> Integral i | |
=> Format t t' 'Integral | |
-> SignMode | |
-> Maybe (paddingWidth, AlignMode k, Char) | Padding |
-> Maybe (Int, Char) | Grouping |
-> i | |
-> String |
Format an integral number
:: (RealFloat f, Integral paddingWidth, Integral precision) | |
=> Format t t' 'Fractional | |
-> SignMode | |
-> Maybe (paddingWidth, AlignMode k, Char) | Padding |
-> Maybe (Int, Char) | Grouping |
-> Maybe precision | 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 |
Sign handling
Instances
Data SignMode Source # | |
Defined in PyF.Formatters gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> SignMode -> c SignMode # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c SignMode # toConstr :: SignMode -> Constr # dataTypeOf :: SignMode -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c SignMode) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c SignMode) # gmapT :: (forall b. Data b => b -> b) -> SignMode -> SignMode # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> SignMode -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> SignMode -> r # gmapQ :: (forall d. Data d => d -> u) -> SignMode -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> SignMode -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> SignMode -> m SignMode # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> SignMode -> m SignMode # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> SignMode -> m SignMode # | |
Show SignMode Source # | |
Lift SignMode Source # | |
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 value |
data AlignForString Source #
Instances
Show AlignForString Source # | |
Defined in PyF.Formatters showsPrec :: Int -> AlignForString -> ShowS # show :: AlignForString -> String # showList :: [AlignForString] -> ShowS # |