-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Combinator-based type-safe formatting (like printf() or FORMAT) -- @package formatting @version 6.2.2 -- | Internal format starters. module Formatting.Internal -- | A formatter. The r type means the returned value at the end. -- The more formatters you compose, the more this wil build up arguments -- from r to Int -> r to Char -> (Int -> -- r), etc. newtype Format r a Format :: ((Builder -> r) -> a) -> Format r a runFormat :: Format r a -> (Builder -> r) -> a -- | Useful instance for applying two formatters to the same input -- argument. For example: format (year <> "/" % month) now -- will yield "2015/01". -- | Useful instance for writing format string. With this you can write -- Foo instead of now "Foo!". -- | The same as (%). At present using Category has an import -- overhead, but one day it might be imported as standard. -- | Composition operator. Format is an instance of Category, -- but that is (at present) inconvenient to use with regular -- Prelude. So this function is provided as a convenience. (%) :: Format r a -> Format r' r -> Format r' a -- | Function compose two formatters. Will feed the result of one formatter -- into another. (%.) :: Format r (Builder -> r') -> Format r' a -> Format r a -- | Insert a constant monoidal value. now :: Builder -> Format r r -- | Monadic indexed bind for holey monoids. bind :: Format r a -> (Builder -> Format r' r) -> Format r' a -- | Insert a function which accepts some argument and produces a -- Builder which is appended to the output at the end. -- -- later (f :: Int -> Builder) produces Format r (Int -- -> r). later :: (a -> Builder) -> Format r (a -> r) -- | Run the formatter and return a lazy Text value. format :: Format Text a -> a -- | Run the formatter and return a strict Text value. sformat :: Format Text a -> a -- | Run the formatter and return a Builder value. bprint :: Format Builder a -> a -- | Run the formatter and print out the text to stdout. fprint :: Format (IO ()) a -> a -- | Run the formatter and put the output onto the given Handle. hprint :: Handle -> Format (IO ()) a -> a -- | Run the formatter and return a list of characters. formatToString :: Format [Char] a -> a instance Category Format instance a ~ r => IsString (Format r a) instance Monoid (Format r (a -> r)) -- | Formatting functions. module Formatting.Formatters -- | Output a lazy text. text :: Format r (Text -> r) -- | Output a strict text. stext :: Format r (Text -> r) -- | Output a string. string :: Format r (String -> r) -- | Output a showable value (instance of Show) by turning it into -- Text: -- --
--   >>> format ("Value number " % shown % " is " % shown % ".") 42 False
--   "Value number 42 is False."
--   
shown :: Show a => Format r (a -> r) -- | Output a character. char :: Format r (Char -> r) -- | Build a builder. builder :: Format r (Builder -> r) -- | Like const but for formatters. fconst :: Builder -> Format r (a -> r) -- | Render an integral e.g. 123 -> "123", 0 -> "0". int :: Integral a => Format r (a -> r) -- | Render some floating point with the usual notation, e.g. 123.32 => -- "123.32" float :: Real a => Format r (a -> r) -- | Render a floating point number using scientific/engineering notation -- (e.g. 2.3e123), with the given number of decimal places. expt :: Real a => Int -> Format r (a -> r) -- | Render a floating point number using normal notation, with the given -- number of decimal places. fixed :: Real a => Int -> Format r (a -> r) -- | Render a floating point number, with the given number of digits of -- precision. Uses decimal notation for values between 0.1 and 9,999,999, -- and scientific notation otherwise. prec :: Real a => Int -> Format r (a -> r) -- | Render a scientific number. sci :: Format r (Scientific -> r) -- | Render a scientific number with options. scifmt :: FPFormat -> Maybe Int -> Format r (Scientific -> r) -- | Render a floating point number using the smallest number of digits -- that correctly represent it. shortest :: Real a => Format r (a -> r) -- | Group integral numbers, e.g. groupInt 2 . on 123456 -> -- "12.34.56". groupInt :: (Buildable n, Integral n) => Int -> Char -> Format r (n -> r) -- | Add commas to an integral, e.g 12000 -> "12,000". commas :: (Buildable n, Integral n) => Format r (n -> r) -- | Add a suffix to an integral, e.g. 1st, 2nd, 3rd, 21st. ords :: Integral n => Format r (n -> r) -- | English plural suffix for an integral. plural :: (Num a, Eq a) => Text -> Text -> Format r (a -> r) -- | Shows the Int value of Enum instances using fromEnum. -- --
--   >>> format ("Got: " % char % " (" % asInt % ")") 'a' 'a'
--   "Got: a (97)"
--   
asInt :: Enum a => Format r (a -> r) -- | Pad the left hand side of a string until it reaches k characters wide, -- if necessary filling with character c. left :: Buildable a => Int -> Char -> Format r (a -> r) -- | Pad the right hand side of a string until it reaches k characters -- wide, if necessary filling with character c. right :: Buildable a => Int -> Char -> Format r (a -> r) -- | Pad the left & right hand side of a string until it reaches k -- characters wide, if necessary filling with character c. center :: Buildable a => Int -> Char -> Format r (a -> r) -- | Fit in the given length, truncating on the left. fitLeft :: Buildable a => Int -> Format r (a -> r) -- | Fit in the given length, truncating on the right. fitRight :: Buildable a => Int -> Format r (a -> r) -- | Render an integral at base n. base :: Integral a => Int -> Format r (a -> r) -- | Render an integer using binary notation. (No leading 0b is added.) -- Defined as bin = base 2. bin :: Integral a => Format r (a -> r) -- | Render an integer using octal notation. (No leading 0o is added.) -- Defined as oct = base 8. oct :: Integral a => Format r (a -> r) -- | Render an integer using hexadecimal notation. (No leading 0x is -- added.) Has a specialized implementation. hex :: Integral a => Format r (a -> r) -- | Render an integer using binary notation with a leading 0b. prefixBin :: Integral a => Format r (a -> r) -- | Render an integer using octal notation with a leading 0o. prefixOct :: Integral a => Format r (a -> r) -- | Render an integer using hexadecimal notation with a leading 0x. prefixHex :: Integral a => Format r (a -> r) -- | Renders a given byte count using an appropiate decimal binary suffix: -- --
--   >>> format (bytes shortest) 1024
--   "1KB"
--   
-- --
--   >>> format (bytes (fixed 2 % " ")) (1024*1024*5)
--   "5.00 MB"
--   
bytes :: (Ord f, Integral a, Fractional f) => Format Builder (f -> Builder) -> Format r (a -> r) -- | Build anything that implements the Buildable class. build :: Buildable a => Format r (a -> r) -- | The class of types that can be rendered to a Builder. class Buildable p -- | Single letters for short formatting. module Formatting.ShortFormatters -- | Output a lazy text. t :: Format r (Text -> r) -- | Render an integral e.g. 123 -> "123", 0 -> "0". d :: Integral a => Format r (a -> r) -- | Render an integer using binary notation. (No leading 0b is added.) b :: Integral a => Format r (a -> r) -- | Render an integer using octal notation. (No leading 0o is added.) o :: Integral a => Format r (a -> r) -- | Render an integer using hexadecimal notation. (No leading 0x is -- added.) x :: Integral a => Format r (a -> r) -- | Output a strict text. st :: Format r (Text -> r) -- | Output a string. s :: Format r (String -> r) -- | Output a showable value (instance of Show) by turning it into -- Text. sh :: Show a => Format r (a -> r) -- | Output a character. c :: Format r (Char -> r) -- | Render a floating point number using scientific/engineering notation -- (e.g. 2.3e123), with the given number of decimal places. ef :: Real a => Int -> Format r (a -> r) -- | Render a floating point number using normal notation, with the given -- number of decimal places. f :: Real a => Int -> Format r (a -> r) -- | Render a floating point number, with the given number of digits of -- precision. Uses decimal notation for values between 0.1 and 9,999,999, -- and scientific notation otherwise. pf :: Real a => Int -> Format r (a -> r) -- | Render a floating point number using the smallest number of digits -- that correctly represent it. sf :: Real a => Format r (a -> r) -- | Pad the left hand side of a string until it reaches k -- characters wide, if necessary filling with character ch. l :: Buildable a => Int -> Char -> Format r (a -> r) -- | Pad the right hand side of a string until it reaches k -- characters wide, if necessary filling with character ch. r :: Buildable a => Int -> Char -> Format r (a -> r) -- | Formatters for time. module Formatting.Time -- | Timezone offset on the format -HHMM. tz :: FormatTime a => Format r (a -> r) -- | Timezone name. tzName :: FormatTime a => Format r (a -> r) -- | As dateTimeFmt locale (e.g. %a %b %e %H:%M:%S %Z -- %Y). datetime :: FormatTime a => Format r (a -> r) -- | Same as %H:%M. hm :: FormatTime a => Format r (a -> r) -- | Same as %H:%M:%S. hms :: FormatTime a => Format r (a -> r) -- | As timeFmt locale (e.g. %H:%M:%S). hmsL :: FormatTime a => Format r (a -> r) -- | As time12Fmt locale (e.g. %I:%M:%S %p). hmsPL :: FormatTime a => Format r (a -> r) -- | Day half from (amPm locale), converted to lowercase, -- am, pm. dayHalf :: FormatTime a => Format r (a -> r) -- | Day half from (amPm locale), AM, PM. dayHalfU :: FormatTime a => Format r (a -> r) -- | Hour, 24-hour, leading 0 as needed, 00 - 23. hour24 :: FormatTime a => Format r (a -> r) -- | Hour, 12-hour, leading 0 as needed, 01 - 12. hour12 :: FormatTime a => Format r (a -> r) -- | Hour, 24-hour, leading space as needed, 0 - 23. hour24S :: FormatTime a => Format r (a -> r) -- | Hour, 12-hour, leading space as needed, 1 - 12. hour12S :: FormatTime a => Format r (a -> r) -- | Minute, 00 - 59. minute :: FormatTime a => Format r (a -> r) -- | Second, without decimal part, 00 - 60. second :: FormatTime a => Format r (a -> r) -- | Picosecond, including trailing zeros, 000000000000 - -- 999999999999. pico :: FormatTime a => Format r (a -> r) -- | Decimal point and up to 12 second decimals, without trailing zeros. -- For a whole number of seconds, this produces the empty string. decimals :: FormatTime a => Format r (a -> r) epoch :: FormatTime a => Format r (a -> r) -- | Same as %m/%d/%y. dateSlash :: FormatTime a => Format r (a -> r) -- | Same as %Y-%m-%d. dateDash :: FormatTime a => Format r (a -> r) -- | As dateFmt locale (e.g. %m/%d/%y). dateSlashL :: FormatTime a => Format r (a -> r) -- | Year. year :: FormatTime a => Format r (a -> r) -- | Last two digits of year, 00 - 99. yy :: FormatTime a => Format r (a -> r) -- | Century (being the first two digits of the year), 00 - -- 99. century :: FormatTime a => Format r (a -> r) -- | Month name, long form (fst from months locale), -- January - December. monthName :: FormatTime a => Format r (a -> r) -- | %H] month name, short form (snd from months -- locale), Jan - Dec@. monthNameShort :: FormatTime a => Format r (a -> r) -- | Month of year, leading 0 as needed, 01 - 12. month :: FormatTime a => Format r (a -> r) -- | Day of month, leading 0 as needed, 01 - 31. dayOfMonth :: FormatTime a => Format r (a -> r) -- | Day of month, 1st, 2nd, 25th, etc. dayOfMonthOrd :: FormatTime a => Format r (a -> r) -- | Day of month, leading space as needed, 1 - 31. dayOfMonthS :: FormatTime a => Format r (a -> r) -- | Day of year for Ordinal Date format, 001 - 366. day :: FormatTime a => Format r (a -> r) -- | Year for Week Date format e.g. 2013. weekYear :: FormatTime a => Format r (a -> r) -- | Last two digits of year for Week Date format, 00 - -- 99. weekYY :: FormatTime a => Format r (a -> r) -- | Century (first two digits of year) for Week Date format, 00 - -- 99. weekCentury :: FormatTime a => Format r (a -> r) -- | Week for Week Date format, 01 - 53. week :: FormatTime a => Format r (a -> r) -- | Day for Week Date format, 1 - 7. dayOfWeek :: FormatTime a => Format r (a -> r) -- | Day of week, short form (snd from wDays -- locale), Sun - Sat. dayNameShort :: FormatTime a => Format r (a -> r) -- | Day of week, long form (fst from wDays locale), -- Sunday - Saturday. dayName :: FormatTime a => Format r (a -> r) -- | Week number of year, where weeks start on Sunday (as -- sundayStartWeek), 00 - 53. weekFromZero :: FormatTime a => Format r (a -> r) -- | Day of week number, 0 (= Sunday) - 6 (= Saturday). dayOfWeekFromZero :: FormatTime a => Format r (a -> r) -- | Week number of year, where weeks start on Monday (as -- mondayStartWeek), 00 - 53. weekOfYearMon :: FormatTime a => Format r (a -> r) -- | Display a time span as one time relative to another. Input is assumed -- to be seconds. Typical inputs are NominalDiffTime and -- DiffTime. diff :: RealFrac n => Bool -> Format r (n -> r) -- | Display the absolute value time span in years. years :: RealFrac n => Int -> Format r (n -> r) -- | Display the absolute value time span in days. days :: RealFrac n => Int -> Format r (n -> r) -- | Display the absolute value time span in hours. hours :: RealFrac n => Int -> Format r (n -> r) -- | Display the absolute value time span in minutes. minutes :: RealFrac n => Int -> Format r (n -> r) -- | Display the absolute value time span in seconds. seconds :: RealFrac n => Int -> Format r (n -> r) -- | Formatter call. Probably don't want to use this. fmt :: FormatTime a => Text -> a -> Text -- | Combinator-based type-safe formatting (like printf() or FORMAT) for -- Text. -- -- Example: -- --
--   >>> format ("Person's name is " % text % ", age is " % hex) "Dave" 54
--   
-- -- See Formatting.Formatters for a complete list of formatting -- combinators. module Formatting -- | A formatter. The r type means the returned value at the end. -- The more formatters you compose, the more this wil build up arguments -- from r to Int -> r to Char -> (Int -> -- r), etc. data Format r a -- | Composition operator. Format is an instance of Category, -- but that is (at present) inconvenient to use with regular -- Prelude. So this function is provided as a convenience. (%) :: Format r a -> Format r' r -> Format r' a -- | Function compose two formatters. Will feed the result of one formatter -- into another. (%.) :: Format r (Builder -> r') -> Format r' a -> Format r a -- | Insert a constant monoidal value. now :: Builder -> Format r r -- | Insert a function which accepts some argument and produces a -- Builder which is appended to the output at the end. -- -- later (f :: Int -> Builder) produces Format r (Int -- -> r). later :: (a -> Builder) -> Format r (a -> r) -- | Run the formatter and return a lazy Text value. format :: Format Text a -> a -- | Run the formatter and return a strict Text value. sformat :: Format Text a -> a -- | Run the formatter and return a Builder value. bprint :: Format Builder a -> a -- | Run the formatter and print out the text to stdout. fprint :: Format (IO ()) a -> a -- | Run the formatter and put the output onto the given Handle. hprint :: Handle -> Format (IO ()) a -> a -- | Run the formatter and return a list of characters. formatToString :: Format [Char] a -> a -- | Examples that should always compile. If reading on Haddock, you can -- view the sources to each of these. module Formatting.Examples -- | Simple hello, world! hello :: Text -- | Printing strings. strings :: Text -- | Printing texts. texts :: Text -- | Printing builders. builders :: Text -- | Printing integers. integers :: Text -- | Printing floating points. floats :: Text -- | Printing integrals in hex (base-16). hexes :: Text -- | Padding. padding :: Text -- | Formatters for high-res, real-time and timer clock values from -- System.Clock. module Formatting.Clock -- | Format the duration from start to end (args passed in that order). -- -- Examples: -- --
--   4.00 s
--   500.69 ms
--   1.20 ms
--   19.38 µs
--   
timeSpecs :: Format r (TimeSpec -> TimeSpec -> r)