stringfmt
Safe HaskellSafe-Inferred
LanguageHaskell2010

Data.Fmt.Code

Description

Numeric and binary encoding formatters.

All numeric encoders are polymorphic over IsString m, so they work with any output type (String, Text.Builder, ByteString.Builder, etc.).

Naming follows C printf conventions:

  • d, u, x — decimal signed, unsigned, hex
  • hh, h, l, ll — width prefixes (8, 16, 32, 64 bit)
  • Primed variants (hx', lx') — fixed-width (zero-padded)
Synopsis

Generic (IsString m)

c :: IsString m => Fmt1 m s Char Source #

Format a character.

s :: (IsString m, Show a) => Fmt1 m s a Source #

Format a showable value.

Floating point

e :: (IsString m, RealFloat a) => Int -> Fmt1 m s a Source #

Scientific notation with prec digits of precision.

f :: (IsString m, RealFloat a) => Int -> Fmt1 m s a Source #

Fixed-point notation with prec digits after the decimal.

g :: (IsString m, RealFloat a) => Int -> Fmt1 m s a Source #

General notation (shorter of e and f).

Decimal encodings

d :: IsString m => Fmt1 m s Int Source #

Decimal encoding of an Int.

hhd :: IsString m => Fmt1 m s Int8 Source #

Decimal encoding of an Int8.

hd :: IsString m => Fmt1 m s Int16 Source #

Decimal encoding of an Int16.

ld :: IsString m => Fmt1 m s Int32 Source #

Decimal encoding of an Int32.

lld :: IsString m => Fmt1 m s Int64 Source #

Decimal encoding of an Int64.

u :: IsString m => Fmt1 m s Word Source #

Decimal encoding of a Word.

hhu :: IsString m => Fmt1 m s Word8 Source #

Decimal encoding of a Word8.

hu :: IsString m => Fmt1 m s Word16 Source #

Decimal encoding of a Word16.

lu :: IsString m => Fmt1 m s Word32 Source #

Decimal encoding of a Word32.

llu :: IsString m => Fmt1 m s Word64 Source #

Decimal encoding of a Word64.

Hexadecimal encodings

x :: IsString m => Fmt1 m s Word Source #

Shortest hex of a Word, lower-case.

hhx :: IsString m => Fmt1 m s Word8 Source #

Shortest hex of a Word8, lower-case.

hhx' :: IsString m => Fmt1 m s Word8 Source #

Fixed-width hex of a Word8 (2 nibbles).

hx :: IsString m => Fmt1 m s Word16 Source #

Shortest hex of a Word16, lower-case.

hx' :: IsString m => Fmt1 m s Word16 Source #

Fixed-width hex of a Word16 (4 nibbles).

lx :: IsString m => Fmt1 m s Word32 Source #

Shortest hex of a Word32, lower-case.

lx' :: IsString m => Fmt1 m s Word32 Source #

Fixed-width hex of a Word32 (8 nibbles).

llx :: IsString m => Fmt1 m s Word64 Source #

Shortest hex of a Word64, lower-case.

llx' :: IsString m => Fmt1 m s Word64 Source #

Fixed-width hex of a Word64 (16 nibbles).

Character encodings (Builder-specific)

c7 :: Fmt1 Builder s Char Source #

ASCII encode a Char.

c8 :: Fmt1 Builder s Char Source #

Latin-1 (ISO/IEC 8859-1) encode a Char.

s7 :: Fmt1 Builder s String Source #

ASCII encode a String.

s8 :: Fmt1 Builder s String Source #

Latin-1 (ISO/IEC 8859-1) encode a String.

Binary encodings (Builder-specific)

hhb :: Fmt1 Builder s Word8 Source #

Encode a Word8 as a single byte.

hb :: Fmt1 Builder s Word16 Source #

Encode a Word16 little-endian.

hb' :: Fmt1 Builder s Word16 Source #

Encode a Word16 big-endian.

lb :: Fmt1 Builder s Word32 Source #

Encode a Word32 little-endian.

lb' :: Fmt1 Builder s Word32 Source #

Encode a Word32 big-endian.

llb :: Fmt1 Builder s Word64 Source #

Encode a Word64 little-endian.

llb' :: Fmt1 Builder s Word64 Source #

Encode a Word64 big-endian.