-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Business-quality formatting of numbers, dates, and other things -- @package formattable @version 0.1 -- | Formatting for numeric values. module Formattable.NumFormat data NumFormat NumFormat :: Double -> Text -> Text -> Text -> Text -> NumStyle -> Maybe (Int, PrecisionType) -> NegativeStyle -> NumFormat -- | Units of measure to use in formatting the number. This is useful for -- things like percentages where you would use (units of 0.01) or -- financial statements (units of 1000 for example). _nfUnits :: NumFormat -> Double -- | A prefix to add to the number, commonly used for currency designation. _nfPrefix :: NumFormat -> Text -- | A suffix for the number. Percent, for example. _nfSuffix :: NumFormat -> Text -- | The character to use as thousands separator if applicable. _nfThouSep :: NumFormat -> Text -- | Character to use for the decimal separator. _nfDecSep :: NumFormat -> Text -- | The formatting style _nfStyle :: NumFormat -> NumStyle -- | Amount of precision to display _nfPrec :: NumFormat -> Maybe (Int, PrecisionType) -- | Styles for negative numbers _nfNegStyle :: NumFormat -> NegativeStyle -- | Data structure describing available styles of number formatting. data NumStyle -- | Format with scientific notation Exponent :: NumStyle -- | Format with standard decimal notation Fixed :: NumStyle -- | The aruments a and b define bounds. If the absolute value of the -- number is in the interval [10 ^ a, 10 ^ b], then it uses the Fixed -- style. If the number is outside this interval, then use the Exponent -- style. SmartExponent :: Int -> Int -> NumStyle -- | Adds the symbol for the closest smaller SI prefix as the suffix to the -- formatted number. This suffix appears before any other suffix you -- designate. SIStyle :: NumStyle -- | Like SIStyle but only applies the SI prefix if the number to be -- formatted falls within the range [a,b] given by the SmartSI arguments. SmartSI :: Double -> Double -> NumStyle -- | A reasonable default value for NumStyle. autoStyle :: NumStyle -- | Data structure for different methods of specifying precision. data PrecisionType -- | Specifies precision as a fixed number of significant digits SigFigs :: PrecisionType -- | Specifies precision with a fixed number of digits after the decimal -- place. Decimals :: PrecisionType -- | Different styles for representing negative numbers. data NegativeStyle -- | Shows negative numbers as -123.000 NegMinusSign :: NegativeStyle -- | Shows negative numbers as (123.000) NegParens :: NegativeStyle nfUnits :: Lens' NumFormat Double nfPrefix :: Lens' NumFormat Text nfSuffix :: Lens' NumFormat Text nfThouSep :: Lens' NumFormat Text nfDecSep :: Lens' NumFormat Text nfStyle :: Lens' NumFormat NumStyle nfPrec :: Lens' NumFormat (Maybe (Int, PrecisionType)) nfNegStyle :: Lens' NumFormat NegativeStyle -- | Int format with no thousands separator. rawIntFmt :: NumFormat -- | Int format with comma as the thousands separator. intFmt :: NumFormat -- | Common format for percentages. Example: 75.000% percentFmt :: NumFormat -- | Common format for generic numeric quantities of the form 123,456.99. numFmt :: NumFormat -- | Common format for US dollar quantities of the form $123,456.99. usdFmt :: NumFormat -- | Convenience wrapper for percentages that lets you easily control the -- number of decimal places. formatPct :: Real a => Int -> a -> Text -- | This function checks to see if the number is smaller than the number -- of digits of precision being displayed and if so, switches to -- scientific notation. formatNum :: Real a => NumFormat -> a -> Text -- | This function checks to see if the number is smaller than the number -- of digits of precision being displayed and if so, switches to -- scientific notation. formatIntegral :: Integral a => NumFormat -> a -> Text instance Eq a => Eq (RawNum a) instance Show a => Show (RawNum a) instance Default NumFormat instance Typeable NumFormat instance Eq NumStyle instance Show NumStyle instance Eq PrecisionType instance Show PrecisionType instance Eq NegativeStyle instance Show NegativeStyle instance Eq NumFormat instance Show NumFormat -- | Practical formatting interface for output values intended for human -- consumption. We try to support several variants often required by -- real-world applications. module Formattable -- | Provides a uniform interface for formatting all kinds of types. class Format a where type family TheFormat a runFormat :: Format a => TheFormat a -> a -> Text instance Format Bool instance Format Text instance Format UTCTime instance Format Day instance Format Float instance Format Double instance Format Word64 instance Format Word32 instance Format Word16 instance Format Word8 instance Format Word instance Format Int64 instance Format Int32 instance Format Int16 instance Format Int8 instance Format Int instance Format Integer