PyF-0.9.0.3: Quasiquotations for a python like interpolated string formatter
Safe HaskellNone
LanguageHaskell2010

PyF.Formatters

Description

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

Generic formating function

formatString Source #

Arguments

:: Maybe (Int, AlignMode 'AlignAll, Char)

Padding

-> Maybe Int

Precision (will truncate before padding)

-> String 
-> String 

Format a string

formatIntegral Source #

Arguments

:: Integral i 
=> Format t t' 'Integral 
-> SignMode 
-> Maybe (Int, AlignMode k, Char)

Padding

-> Maybe (Int, Char)

Grouping

-> i 
-> String 

Format an integral number

formatFractional Source #

Arguments

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

This formatter support alternate version

Constructors

CanAlt 
NoAlt 

data UpperStatus Source #

This formatter support Upper case 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 :: Format k k' k'' -> Q Exp #

liftTyped :: Format k k' k'' -> Q (TExp (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
Show SignMode Source # 
Instance details

Defined in PyF.Formatters

Lift SignMode Source # 
Instance details

Defined in PyF.Formatters

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

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 valueber

Instances

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

Defined in PyF.Formatters

Methods

lift :: AlignMode k -> Q Exp #

liftTyped :: AlignMode k -> Q (TExp (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