-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Quasiquotations for a python like interpolated string formater -- -- Quasiquotations for a python like interpolated string formater. @package PyF @version 0.9.0.1 module PyF.Class -- | The three categories of formatting in PyF data PyFCategory -- | Format as an integral, no fractional part, precise value PyFIntegral :: PyFCategory -- | Format as a fractional, approximate value with a fractional part PyFFractional :: PyFCategory -- | Format as a string PyFString :: PyFCategory -- | Classify a type to a PyFCategory This classification will be -- used to decide which formatting to use when no type specifier in -- provided. type family PyFClassify t :: PyFCategory -- | Convert a type to string The default implementation uses Show class PyFToString t pyfToString :: PyFToString t => t -> String pyfToString :: (PyFToString t, Show t) => t -> String instance PyF.Class.PyFToString GHC.Base.String instance PyF.Class.PyFToString Data.Text.Internal.Lazy.Text instance PyF.Class.PyFToString Data.Text.Internal.Text instance GHC.Show.Show t => PyF.Class.PyFToString t -- | Formatters for integral / fractional and strings. -- -- Is support: -- -- For all types: -- --
-- >>> import Text.Megaparsec
--
-- >>> parse parsePythonFormatString "" "hello {1+1:>10.2f}"
-- Right [
-- Raw "hello ",
-- Replacement "1+1"
-- (
-- Just (FormatMode
-- (Padding 10 (Just (Nothing,AnyAlign AlignRight)))
-- (FixedF (Precision 2) NormalForm Minus)
-- Nothing))]
--
parseGenericFormatString :: Parser [Item]
-- | A format string is composed of many chunks of raw string or
-- replacement
data Item
-- | A raw string
Raw :: String -> Item
-- | A replacement string, composed of an arbitrary Haskell expression
-- followed by an optional formatter
Replacement :: Exp -> Maybe FormatMode -> Item
-- | A Formatter, listing padding, format and and grouping char
data FormatMode
FormatMode :: Padding -> TypeFormat -> Maybe Char -> FormatMode
-- | Padding, containing the padding width, the padding char and the
-- alignement mode
data Padding
PaddingDefault :: Padding
Padding :: Integer -> Maybe (Maybe Char, AnyAlign) -> Padding
-- | Floating point precision
data Precision
PrecisionDefault :: Precision
Precision :: ExprOrValue Integer -> Precision
-- | All formating type
data TypeFormat
-- | Default, depends on the infered type of the expression
DefaultF :: Precision -> SignMode -> TypeFormat
-- | Binary, such as `0b0121`
BinaryF :: AlternateForm -> SignMode -> TypeFormat
-- | Character, will convert an integer to its character representation
CharacterF :: TypeFormat
-- | Decimal, base 10 integer formatting
DecimalF :: SignMode -> TypeFormat
-- | Exponential notation for floatting points
ExponentialF :: Precision -> AlternateForm -> SignMode -> TypeFormat
-- | Exponential notation with capitalised e
ExponentialCapsF :: Precision -> AlternateForm -> SignMode -> TypeFormat
-- | Fixed number of digits floating point
FixedF :: Precision -> AlternateForm -> SignMode -> TypeFormat
-- | Capitalized version of the previous
FixedCapsF :: Precision -> AlternateForm -> SignMode -> TypeFormat
-- | General formatting: FixedF or ExponentialF depending on
-- the number magnitude
GeneralF :: Precision -> AlternateForm -> SignMode -> TypeFormat
-- | Same as GeneralF but with upper case E and infinite /
-- NaN
GeneralCapsF :: Precision -> AlternateForm -> SignMode -> TypeFormat
-- | Octal, such as 00245
OctalF :: AlternateForm -> SignMode -> TypeFormat
-- | Simple string
StringF :: Precision -> TypeFormat
-- | Hexadecimal, such as 0xaf3e
HexF :: AlternateForm -> SignMode -> TypeFormat
-- | Hexadecimal with capitalized letters, such as 0XAF3E
HexCapsF :: AlternateForm -> SignMode -> TypeFormat
-- | Percent representation
PercentF :: Precision -> AlternateForm -> SignMode -> TypeFormat
-- | If the formatter use its alternate form
data AlternateForm
AlternateForm :: AlternateForm
NormalForm :: AlternateForm
-- | Default formating mode, no padding, default precision, no grouping, no
-- sign handling
pattern DefaultFormatMode :: FormatMode
type Parser t = ParsecT Void String (Reader ParsingContext) t
data ParsingContext
ParsingContext :: (Char, Char) -> [Extension] -> ParsingContext
[delimiters] :: ParsingContext -> (Char, Char)
[enabledExtensions] :: ParsingContext -> [Extension]
-- | Represents a value of type t or an Haskell expression
-- supposed to represents that value
data ExprOrValue t
Value :: t -> ExprOrValue t
HaskellExpr :: Exp -> ExprOrValue t
instance GHC.Show.Show PyF.Internal.PythonSyntax.Item
instance GHC.Show.Show PyF.Internal.PythonSyntax.FormatMode
instance GHC.Show.Show PyF.Internal.PythonSyntax.TypeFormat
instance GHC.Show.Show PyF.Internal.PythonSyntax.AlternateForm
instance GHC.Show.Show PyF.Internal.PythonSyntax.TypeFlag
instance GHC.Show.Show PyF.Internal.PythonSyntax.Precision
instance GHC.Show.Show t => GHC.Show.Show (PyF.Internal.PythonSyntax.ExprOrValue t)
instance GHC.Show.Show PyF.Internal.PythonSyntax.Padding
instance GHC.Show.Show PyF.Internal.PythonSyntax.ParsingContext
-- | This module uses the python mini language detailed in
-- PythonSyntax to build an template haskell expression
-- representing a formatted string.
module PyF.Internal.QQ
-- | Parse a string and return a formatter for it
toExp :: (Char, Char) -> String -> Q Exp
toExpPython :: String -> Q Exp
instance PyF.Internal.QQ.FormatAny2 (PyF.Class.PyFClassify t) t k => PyF.Internal.QQ.FormatAny t k
instance (GHC.Show.Show t, GHC.Real.Integral t) => PyF.Internal.QQ.FormatAny2 'PyF.Class.PyFIntegral t k
instance GHC.Float.RealFloat t => PyF.Internal.QQ.FormatAny2 'PyF.Class.PyFFractional t k
instance PyF.Class.PyFToString t => PyF.Internal.QQ.FormatAny2 'PyF.Class.PyFString t 'PyF.Formatters.AlignAll
instance (TypeError ...) => PyF.Internal.QQ.FormatAny2 'PyF.Class.PyFString t 'PyF.Formatters.AlignNumber
-- | A lot of quasiquoters to format and interpolate string expression
module PyF
-- | Generic formatter, can format an expression to any t as long
-- as t is an instance of IsString.
fmt :: QuasiQuoter
fmtWithDelimiters :: (Char, Char) -> QuasiQuoter