formatting-3.1.4: Combinator-based type-safe formatting (like printf() or FORMAT)

PortabilityGHC
Stabilityexperimental
Maintainerchrisdone@gmail.com
Safe HaskellNone

Formatting.Formatters

Contents

Description

Formatting functions.

Synopsis

Text/string types

text :: Format TextSource

Output a lazy text.

stext :: Format TextSource

Output a strict text.

string :: Format StringSource

Output a string.

builder :: Format BuilderSource

Build a builder.

fconst :: Builder -> Format aSource

Like const but for formatters.

Numbers

int :: Integral a => Format aSource

Render an integral e.g. 123 -> "123", 0 -> "0".

float :: Real a => Format aSource

Render some floating point with the usual notation, e.g. 123.32 => "123.32"

expt :: Real a => Int -> Format aSource

Render a floating point number using scientific/engineering notation (e.g. 2.3e123), with the given number of decimal places.

fixed :: Real a => Int -> Format aSource

Render a floating point number using normal notation, with the given number of decimal places.

prec :: Real a => Int -> Format aSource

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.

shortest :: Real a => Format aSource

Render a floating point number using the smallest number of digits that correctly represent it.

commas :: (Buildable n, Integral n) => Format nSource

Add commas to an integral, e.g 12000 -> 12,000.

ords :: Integral n => Format nSource

Add a suffix to an integral, e.g. 1st, 2nd, 3rd, 21st.

Padding

left :: Buildable a => Int -> Char -> Format aSource

Pad the left hand side of a string until it reaches k characters wide, if necessary filling with character c.

right :: Buildable a => Int -> Char -> Format aSource

Pad the right hand side of a string until it reaches k characters wide, if necessary filling with character c.

Bases

hex :: Integral a => Format aSource

Render an integer using hexadecimal notation. (No leading 0x is added.)

Buildables

build :: Buildable a => Format aSource

Build anything that implements the Buildable class.