PyF-0.11.3.0: Quasiquotations for a python like interpolated string formatter
Safe HaskellSafe-Inferred
LanguageHaskell2010

PyF.Formatters

Description

Formatters for integral / fractional and strings.

The following is supported:

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 Hexadecimal Octal / Character representation
Synopsis

Generic formatting function

formatString Source #

Arguments

:: 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.

formatIntegral Source #

Arguments

:: 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.

formatFractional Source #

Arguments

:: (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 AltStatus Source #

This formatter supports an alternate version.

Constructors

CanAlt 
NoAlt 

data UpperStatus Source #

This formatter support an uppercase version.

Constructors

CanUpper 
NoUpper 

data FormatType Source #

This formatter formats an integral or a fractional.

Constructors

Fractional 
Integral 

data Format (k :: AltStatus) (k' :: UpperStatus) (k'' :: FormatType) where Source #

All the Formatters.

Instances

Instances details
Lift (Format k k' k'' :: Type) Source # 
Instance details

Defined in PyF.Formatters

Methods

lift :: Quote m => Format k k' k'' -> m Exp #

liftTyped :: forall (m :: Type -> Type). Quote m => Format k k' k'' -> Code m (Format k k' k'') #

data SignMode Source #

Sign handling

Constructors

Plus

Display - sign and + sign

Minus

Only display - sign

Space

Display - sign and a space for positive numbers

Instances

Instances details
Data SignMode Source # 
Instance details

Defined in PyF.Formatters

Methods

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 # 
Instance details

Defined in PyF.Formatters

Lift SignMode Source # 
Instance details

Defined in PyF.Formatters

Methods

lift :: Quote m => SignMode -> m Exp #

liftTyped :: forall (m :: Type -> Type). Quote m => SignMode -> Code m SignMode #

data AnyAlign where Source #

Existential version of AlignMode

Constructors

AnyAlign :: AlignMode (k :: AlignForString) -> AnyAlign 

Instances

Instances details
Show AnyAlign Source # 
Instance details

Defined in PyF.Formatters

Lift AnyAlign Source # 
Instance details

Defined in PyF.Formatters

Methods

lift :: Quote m => AnyAlign -> m Exp #

liftTyped :: forall (m :: Type -> Type). Quote m => AnyAlign -> Code m AnyAlign #

Internal usage only

data AlignMode (k :: AlignForString) where Source #

Alignement

Constructors

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

Instances

Instances details
Lift (AlignMode k :: Type) Source # 
Instance details

Defined in PyF.Formatters

Methods

lift :: Quote m => AlignMode k -> m Exp #

liftTyped :: forall (m :: Type -> Type). Quote m => AlignMode k -> Code m (AlignMode k) #

Show (AlignMode k) Source # 
Instance details

Defined in PyF.Formatters

data AlignForString Source #

Constructors

AlignAll 
AlignNumber 

Instances

Instances details
Show AlignForString Source # 
Instance details

Defined in PyF.Formatters