-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Combinator-based type-safe formatting (like printf() or FORMAT) -- -- Combinator-based type-safe formatting (like printf() or FORMAT), -- modelled from the HoleyMonoids package. @package formatting @version 3.1.3 -- | Copy of the holey monoids library but with constructor exported. module Formatting.Holey -- | A formatter. type Format a = forall r. Holey Builder r (a -> r) -- | The type of a monoid with holes. The underlying monoid is represented -- by type parameter m. The r is the result type and -- stays polymorphic until the very last moment when run is -- called. The last argument a is always a function with zero or -- more arguments, finally resulting in r. Ordering the -- arguments in this order allows holey monoids to be composed using -- ., stacking the expected arguments. Note that the Monoid -- constraint is only used in the identity Holey and in composing -- two Holeys. newtype Holey m r a Holey :: ((m -> r) -> a) -> Holey m r a runHM :: Holey m r a -> (m -> r) -> a -- | Composition operator. The same as category composition. (%) :: Monoid n => Holey n b c -> Holey n b1 b -> Holey n b1 c -- | Insert a constant monoidal value. now :: m -> Holey m r r -- | Monadic indexed bind for holey monoids. bind :: Holey m b c -> (m -> Holey n a b) -> Holey n a c -- | Insert a monoidal value that is not specified until the computation is -- run. The argument that is expected later is converted to the -- monoid type using the given conversion function. later :: (a -> m) -> Holey m r (a -> r) -- | Convert between underlying Monoid types. hmap :: (m -> n) -> Holey m r a -> Holey n r a instance (IsString m, a ~ r) => IsString (Holey m r a) -- | Formatting functions. module Formatting.Formatters -- | Output a lazy text. text :: Format Text -- | Output a strict text. stext :: Format Text -- | Output a string. string :: Format String -- | Build a builder. builder :: Format Builder -- | Like const but for formatters. fconst :: Builder -> Format a -- | Render an integral e.g. 123 -> "123", 0 -> "0". int :: Integral a => Format a -- | Render some floating point with the usual notation, e.g. 123.32 => -- "123.32" float :: Real a => Format a -- | 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 a -- | Render a floating point number using normal notation, with the given -- number of decimal places. fixed :: Real a => Int -> Format a -- | 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 a -- | Render a floating point number using the smallest number of digits -- that correctly represent it. shortest :: Real a => Format a -- | Add commas to an integral, e.g 12000 -> 12,000. commas :: (Buildable n, Integral n) => Format n -- | 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 a -- | 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 a -- | Render an integer using hexadecimal notation. (No leading 0x is -- added.) hex :: Integral a => Format a -- | Build anything that implements the Buildable class. build :: Buildable a => Format a -- | The class of types that can be rendered to a Builder. class Buildable p -- | Internal format starters. module Formatting.Internal -- | Run the formatter and return a Text value. format :: Holey Builder Text a -> a -- | Run the formatter and return a Builder value. bprint :: Holey Builder Builder a -> a -- | Run the formatter and print out the text to stdout. fprint :: Holey Builder (IO ()) a -> a -- | Run the formatter and put the output onto the given Handle. hprint :: Handle -> Holey Builder (IO ()) a -> a -- | Single letters for short formatting. module Formatting.ShortFormatters -- | Output a lazy text. t :: Format Text -- | Render an integer using hexadecimal notation. (No leading 0x is -- added.) x :: Format Integer -- | Output a strict text. st :: Format Text -- | Output a string. s :: Format String -- | 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 a -- | Render a floating point number using normal notation, with the given -- number of decimal places. f :: Real a => Int -> Format a -- | 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 a -- | Render a floating point number using the smallest number of digits -- that correctly represent it. sf :: Real a => Format a -- | Pad the left hand side of a string until it reaches k characters wide, -- if necessary filling with character c. l :: Buildable a => Int -> Char -> Format a -- | Pad the right hand side of a string until it reaches k characters -- wide, if necessary filling with character c. r :: Buildable a => Int -> Char -> Format a -- | Formatters for time. -- -- Example: -- --
-- REPL> before <- getCurrentTime -- REPL> after <- getCurrentTime -- REPL> format (hms % " - " % hms % " = " % diff False) before after (before,after) -- "19:05:06 - 19:05:08 = 3 seconds" -- REPL> --module Formatting.Time -- | Timezone offset on the format -HHMM. tz :: FormatTime a => Format a -- | Timezone name. tzName :: FormatTime a => Format a -- | As dateTimeFmt locale (e.g. %a %b %e %H:%M:%S %Z -- %Y). datetime :: FormatTime a => Format a -- | Same as %H:%M. hm :: FormatTime a => Format a -- | Same as %H:%M:%S. hms :: FormatTime a => Format a -- | As timeFmt locale (e.g. %H:%M:%S). hmsL :: FormatTime a => Format a -- | As time12Fmt locale (e.g. %I:%M:%S %p). hmsPL :: FormatTime a => Format a -- | Day half from (amPm locale), converted to lowercase, -- am, pm. dayHalf :: FormatTime a => Format a -- | Day half from (amPm locale), AM, PM. dayHalfU :: FormatTime a => Format a -- | Hour, 24-hour, leading 0 as needed, 00 - 23. hour24 :: FormatTime a => Format a -- | Hour, 12-hour, leading 0 as needed, 01 - 12. hour12 :: FormatTime a => Format a -- | Hour, 24-hour, leading space as needed, 0 - 23. hour24S :: FormatTime a => Format a -- | Hour, 12-hour, leading space as needed, 1 - 12. hour12S :: FormatTime a => Format a -- | Minute, 00 - 59. minute :: FormatTime a => Format a -- | Second, without decimal part, 00 - 60. second :: FormatTime a => Format a -- | Picosecond, including trailing zeros, 000000000000 - -- 999999999999. pico :: FormatTime a => Format a -- | 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 a epoch :: FormatTime a => Format a -- | Same as %m/%d/%y. dateSlash :: FormatTime a => Format a -- | Same as %Y-%m-%d. dateDash :: FormatTime a => Format a -- | As dateFmt locale (e.g. %m/%d/%y). dateSlashL :: FormatTime a => Format a -- | Year. year :: FormatTime a => Format a -- | Last two digits of year, 00 - 99. yy :: FormatTime a => Format a -- | Century (being the first two digits of the year), 00 - -- 99. century :: FormatTime a => Format a -- | Month name, long form (fst from months locale), -- January - December. monthName :: FormatTime a => Format a monthNameShort :: FormatTime a => Format a -- | Month of year, leading 0 as needed, 01 - 12. month :: FormatTime a => Format a -- | Day of month, leading 0 as needed, 01 - 31. dayOfMonth :: FormatTime a => Format a -- | Day of month, leading space as needed, 1 - 31. dayOfMonthS :: FormatTime a => Format a -- | Day of year for Ordinal Date format, 001 - 366. day :: FormatTime a => Format a -- | Year for Week Date format e.g. 2013. weekYear :: FormatTime a => Format a -- | Last two digits of year for Week Date format, 00 - -- 99. weekYY :: FormatTime a => Format a -- | Century (first two digits of year) for Week Date format, 00 - -- 99. weekCentury :: FormatTime a => Format a -- | Week for Week Date format, 01 - 53. week :: FormatTime a => Format a -- | Day for Week Date format, 1 - 7. dayOfWeek :: FormatTime a => Format a -- | Day of week, short form (snd from wDays -- locale), Sun - Sat. dayNameShort :: FormatTime a => Format a -- | Day of week, long form (fst from wDays locale), -- Sunday - Saturday. dayName :: FormatTime a => Format a -- | Week number of year, where weeks start on Sunday (as -- sundayStartWeek), 00 - 53. weekFromZero :: FormatTime a => Format a -- | Day of week number, 0 (= Sunday) - 6 (= Saturday). dayOfWeekFromZero :: FormatTime a => Format a -- | Week number of year, where weeks start on Monday (as -- mondayStartWeek), 00 - 53. weekOfYearMon :: FormatTime a => Format a -- | Display a time span as one time relative to another. Equiv. to (t1 - -- t2) for some (t1,t2) pair. diff :: Bool -> Format (UTCTime, UTCTime) -- | 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
-- | Run the formatter and return a Text value.
format :: Holey Builder Text a -> a
-- | Run the formatter and return a Builder value.
bprint :: Holey Builder Builder a -> a
-- | Run the formatter and print out the text to stdout.
fprint :: Holey Builder (IO ()) a -> a
-- | Run the formatter and put the output onto the given Handle.
hprint :: Handle -> Holey Builder (IO ()) 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