logfmt-0.0.1: Formatting
Safe HaskellNone
LanguageHaskell2010

Data.Fmt.Code

Synopsis

Documentation

v :: ToLogStr a => Fmt1 LogStr s a #

Encode a loggable value.

Semantics are similar to printf:

>>> Text.Printf.printf "%v" 42 :: String
"42"
>>> runLogFmt v 42
"42"

Character encodings

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

Format a character.

c7 :: Fmt1 LogStr s Char #

ASCII encode a Char.

c8 :: Fmt1 LogStr s Char #

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

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

Format a showable value.

s7 :: Fmt1 LogStr s String #

ASCII encode a String.

s8 :: Fmt1 LogStr s String #

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

Ascii float encodings

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

Format a floating point number to a given number of digits of precision.

Semantics are similar to printf:

>>> Text.Printf.printf "%.5e" pi :: String
"3.14159e0"
>>> runLogFmt (e 5) pi
"3.14159e0"

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

Format a floating point number to a given number of digits of precision.

Semantics are similar to printf:

>>> Text.Printf.printf "%.5f" maximal32 :: String
"340282330000000000000000000000000000000.00000"
>>> runLogFmt (f 5) maximal32
"340282330000000000000000000000000000000.00000"

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

Format a floating point number to a given number of digits of precision.

Semantics are similar to printf:

>>> Text.Printf.printf "%.5g" maximal32 :: String
"3.40282e38"
>>> runLogFmt (g 5) maximal32
"3.40282e38"

Decimal encodings

d :: Fmt1 LogStr s Int #

Decimal encoding of an Int using the ASCII digits.

hhd :: Fmt1 LogStr s Int8 #

Decimal encoding of an Int8 using the ASCII digits.

e.g.

toLazyByteString (int8Dec 42)   = "42"
toLazyByteString (int8Dec (-1)) = "-1"

hd :: Fmt1 LogStr s Int16 #

Decimal encoding of an Int16 using the ASCII digits.

ld :: Fmt1 LogStr s Int32 #

Decimal encoding of an Int32 using the ASCII digits.

lld :: Fmt1 LogStr s Int64 #

Decimal encoding of an Int64 using the ASCII digits.

u :: Fmt1 LogStr s Word #

Decimal encoding of a Word using the ASCII digits.

hhu :: Fmt1 LogStr s Word8 #

Decimal encoding of a Word8 using the ASCII digits.

hu :: Fmt1 LogStr s Word16 #

Decimal encoding of a Word16 using the ASCII digits.

lu :: Fmt1 LogStr s Word32 #

Decimal encoding of a Word32 using the ASCII digits.

llu :: Fmt1 LogStr s Word64 #

Decimal encoding of a Word64 using the ASCII digits.

Hexadecimal encodings

x :: Fmt1 LogStr s Word #

Shortest hexadecimal encoding of a Word using lower-case characters.

hhx :: Fmt1 LogStr s Word8 #

Shortest hexadecimal encoding of a Word8 using lower-case characters.

hx :: Fmt1 LogStr s Word16 #

Shortest hexadecimal encoding of a Word16 using lower-case characters.

hx' :: Fmt1 LogStr s Word16 #

Encode a Word16 using 4 nibbles.

lx :: Fmt1 LogStr s Word32 #

Shortest hexadecimal encoding of a Word32 using lower-case characters.

lx' :: Fmt1 LogStr s Word32 #

Encode a Word32 using 8 nibbles.

llx :: Fmt1 LogStr s Word64 #

Shortest hexadecimal encoding of a Word64 using lower-case characters.

Semantics are similar to printf:

>>> Text.printf "%s: %llx" "Val" (-7) :: String
"Val: fffffffffffffff9"
>>> printf (s % ": " % llx) "Val" (-7)
"Val: fffffffffffffff9"

llx' :: Fmt1 LogStr s Word64 #

Encode a Word64 using 16 nibbles.

Binary encodings

b :: Fmt1 LogStr s ByteString #

Format a lazy byte string.

b' :: Fmt1 LogStr s ByteString #

Format a strict byte string.

 fmap (. pack) t' :: Fmt1 Builder s String

hhb :: Fmt1 LogStr s Word8 #

Encode a Word8 as-is

hb :: Fmt1 LogStr s Word16 #

Encode a Word16 using little-endian format.

hb' :: Fmt1 LogStr s Word16 #

Encode a Word16 using big-endian format.

lb :: Fmt1 LogStr s Word32 #

Encode a Word32 using little-endian format.

lb' :: Fmt1 LogStr s Word32 #

Encode a Word32 using big-endian format.

llb :: Fmt1 LogStr s Word64 #

Encode a Word64 using little-endian format.

Semantics are similar to printf:

>>> Text.printf "%s: %llb" "Val" (-7) :: String
"Val: fffffffffffffff9"
>>> printf (s % ": " % llb) "Val" (-7)
"Val: fffffffffffffff9"

llb' :: Fmt1 LogStr s Word64 #

Encode a Word64 using big-endian format.