-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Combinator-based type-safe formatting (like printf() or FORMAT) -- @package formatting @version 5.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) type Holey m r a = HoleyT r a m -- | 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 HoleyT r a m Holey :: ((m -> r) -> a) -> HoleyT r a m runHM :: HoleyT r a m -> (m -> r) -> a -- | Composition operator. The same as category composition. (%) :: Monoid n => Holey n b c -> Holey n b1 b -> Holey n b1 c -- | Function compose two holeys. Will feed the result of one holey into -- another. (%.) :: Holey m r (a -> b) -> Holey a b c -> Holey m r 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) instance (IsString m, a ~ r) => IsString (Holey m r a) instance Functor (HoleyT 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 -- | 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 a
-- | Output a character.
char :: Format Char
-- | 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 scientific number.
sci :: Format Scientific
-- | Render a scientific number with options.
scifmt :: FPFormat -> Maybe Int -> Format Scientific
-- | Render a floating point number using the smallest number of digits
-- that correctly represent it.
shortest :: Real a => Format a
-- | Group integral numbers, e.g. groupInt 2 . on 123456 ->
-- "12.34.56".
groupInt :: (Buildable n, Integral n) => Int -> Char -> Format n
-- | Add commas to an integral, e.g 12000 -> "12,000".
commas :: (Buildable n, Integral n) => Format n
-- | Add a suffix to an integral, e.g. 1st, 2nd, 3rd, 21st.
ords :: Integral n => Format n
-- | Shows the Int value of Enum instances using fromEnum.
--
--
-- >>> format ("Got: " % char % " (" % asInt % ")") 'a' 'a'
-- "Got: a (97)"
--
asInt :: Enum a => Format a
-- | 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
-- | 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 a
-- | Fit in the given length, truncating on the left.
fitLeft :: Buildable a => Int -> Format a
-- | Fit in the given length, truncating on the right.
fitRight :: Buildable a => Int -> Format a
base :: Integral a => Int -> Format a
-- | Render an integer using binary notation. (No leading 0b is added.)
-- Defined as bin = base 2.
bin :: Integral a => Format a
-- | Render an integer using octal notation. (No leading 0o is added.)
-- Defined as oct = base 8.
oct :: Integral a => Format a
-- | Render an integer using hexadecimal notation. (No leading 0x is
-- added.) Has a specialized implementation.
hex :: Integral a => Format a
-- | Render an integer using binary notation with a leading 0b.
prefixBin :: Integral a => Format a
-- | Render an integer using octal notation with a leading 0o.
prefixOct :: Integral a => Format a
-- | Render an integer using hexadecimal notation with a leading 0x.
prefixHex :: 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 lazy Text value.
format :: Holey Builder Text a -> a
-- | Run the formatter and return a strict Text value.
sformat :: 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 integral e.g. 123 -> "123", 0 -> "0".
d :: Integral a => Format a
-- | Render an integer using binary notation. (No leading 0b is added.)
b :: Integral a => Format a
-- | Render an integer using octal notation. (No leading 0o is added.)
o :: Integral a => Format a
-- | Render an integer using hexadecimal notation. (No leading 0x is
-- added.)
x :: Integral a => Format a
-- | Output a strict text.
st :: Format Text
-- | Output a string.
s :: Format String
-- | Output a showable value (instance of Show) by turning it into
-- Text.
sh :: Show a => Format a
-- | Output a character.
c :: Format Char
-- | 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 ch.
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 ch.
r :: Buildable a => Int -> Char -> Format a
-- | Formatters for time.
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
-- | %H] month name, short form (snd from months
-- locale), Jan - Dec@.
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, 1st, 2nd, 25th, etc.
dayOfMonthOrd :: 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. Input is assumed
-- to be seconds. Typical inputs are NominalDiffTime and
-- DiffTime.
diff :: RealFrac n => Bool -> Format n
-- | Display the absolute value time span in years.
years :: RealFrac n => Int -> Format n
-- | Display the absolute value time span in days.
days :: RealFrac n => Int -> Format n
-- | Display the absolute value time span in hours.
hours :: RealFrac n => Int -> Format n
-- | Display the absolute value time span in minutes.
minutes :: RealFrac n => Int -> Format n
-- | Display the absolute value time span in seconds.
seconds :: RealFrac n => Int -> Format n
-- | 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 lazy Text value.
format :: Holey Builder Text a -> a
-- | Run the formatter and return a strict Text value.
sformat :: 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