Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
This module contains Formatable and VarContainer instances for most used types.
Synopsis
- data Single a = Single {
- getSingle :: a
- data Several a = Several {
- getSeveral :: [a]
- data Shown a = Shown {
- shown :: a
- data DefaultValue = DefaultValue Variable
- data ThenCheck c1 c2 = ThenCheck c1 c2
- type WithDefault c = ThenCheck c DefaultValue
- withDefault :: VarContainer c => c -> Variable -> WithDefault c
- optional :: VarContainer c => c -> WithDefault c
- genericIntFormat :: Integral a => VarFormat -> a -> Either String Builder
- genericFloatFormat :: RealFloat a => VarFormat -> a -> Either String Builder
Utility data types
Container for single parameter. Example usage:
format "Hello, {}!" (Single name)
Instances
Eq a => Eq (Single a) Source # | |
Show a => Show (Single a) Source # | |
Formatable a => ClosedVarContainer (Single a) Source # | |
Defined in Data.Text.Format.Heavy.Instances allVarNames :: Single a -> [VarName] Source # | |
Formatable a => VarContainer (Single a) Source # | |
Formatable a => Formatable (Single a) Source # | |
Container for several parameters of the same type. Example usage:
format "{} + {} = {}" $ Several [2, 3, 5]
Several | |
|
Instances
Eq a => Eq (Several a) Source # | |
Show a => Show (Several a) Source # | |
Formatable a => ClosedVarContainer (Several a) Source # | |
Defined in Data.Text.Format.Heavy.Instances allVarNames :: Several a -> [VarName] Source # | |
Formatable a => VarContainer (Several a) Source # | |
Values packed in Shown will be formatted using their Show instance.
For example,
formatText "values: {}." (Shown (True, False)) ==> "values: (True, False)."
Combinators
data DefaultValue Source #
Variable container which contains fixed value for any variable name.
Instances
VarContainer DefaultValue Source # | |
Defined in Data.Text.Format.Heavy.Instances |
Combiled variable container, which uses parameters from c1
,
and if variable is not found there it will check in c2
.
ThenCheck c1 c2 |
Instances
(ClosedVarContainer c1, ClosedVarContainer c2) => ClosedVarContainer (ThenCheck c1 c2) Source # | |
Defined in Data.Text.Format.Heavy.Instances allVarNames :: ThenCheck c1 c2 -> [VarName] Source # | |
(VarContainer c1, VarContainer c2) => VarContainer (ThenCheck c1 c2) Source # | |
type WithDefault c = ThenCheck c DefaultValue Source #
Convenience type synonym.
withDefault :: VarContainer c => c -> Variable -> WithDefault c Source #
Use variables from specified container, or use default value if variable is not found in container.
optional :: VarContainer c => c -> WithDefault c Source #
Use variables from specified container, or use empty string variable is not found in container.
Generic formatters
genericIntFormat :: Integral a => VarFormat -> a -> Either String Builder Source #
Generic formatter for integer types
genericFloatFormat :: RealFloat a => VarFormat -> a -> Either String Builder Source #
Generic formatter for floating-point types