{-# LANGUAGE RankNTypes #-}
module Formatting.ShortFormatters
( t
, d
, b
, o
, x
, st
, s
, sh
, c
, f
, sf
, l
, r
) where
import Formatting.Formatters (bin, int, oct)
import Formatting.Internal
import qualified Data.Text as S
import qualified Data.Text as T
import qualified Data.Text.Format as T
import Data.Text.Lazy (Text)
import qualified Data.Text.Lazy.Builder as T
import Formatting.Buildable (Buildable)
import qualified Formatting.Buildable as B (build)
t :: Format r (Text -> r)
t :: Format r (Text -> r)
t = (Text -> Builder) -> Format r (Text -> r)
forall a r. (a -> Builder) -> Format r (a -> r)
later Text -> Builder
T.fromLazyText
{-# INLINE t #-}
d :: Integral a => Format r (a -> r)
d :: Format r (a -> r)
d = Format r (a -> r)
forall a r. Integral a => Format r (a -> r)
int
{-# INLINE d #-}
b :: Integral a => Format r (a -> r)
b :: Format r (a -> r)
b = Format r (a -> r)
forall a r. Integral a => Format r (a -> r)
bin
{-# INLINE b #-}
o :: Integral a => Format r (a -> r)
o :: Format r (a -> r)
o = Format r (a -> r)
forall a r. Integral a => Format r (a -> r)
oct
{-# INLINE o #-}
x :: Integral a => Format r (a -> r)
x :: Format r (a -> r)
x = (a -> Builder) -> Format r (a -> r)
forall a r. (a -> Builder) -> Format r (a -> r)
later a -> Builder
forall a. Integral a => a -> Builder
T.hex
{-# INLINE x #-}
st :: Format r (S.Text -> r)
st :: Format r (Text -> r)
st = (Text -> Builder) -> Format r (Text -> r)
forall a r. (a -> Builder) -> Format r (a -> r)
later Text -> Builder
T.fromText
{-# INLINE st #-}
s :: Format r (String -> r)
s :: Format r (String -> r)
s = (String -> Builder) -> Format r (String -> r)
forall a r. (a -> Builder) -> Format r (a -> r)
later (Text -> Builder
T.fromText (Text -> Builder) -> (String -> Text) -> String -> Builder
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Text
T.pack)
{-# INLINE s #-}
sh :: Show a => Format r (a -> r)
sh :: Format r (a -> r)
sh = (a -> Builder) -> Format r (a -> r)
forall a r. (a -> Builder) -> Format r (a -> r)
later (Text -> Builder
T.fromText (Text -> Builder) -> (a -> Text) -> a -> Builder
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Text
T.pack (String -> Text) -> (a -> String) -> a -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> String
forall a. Show a => a -> String
show)
{-# INLINE sh #-}
c :: Format r (Char -> r)
c :: Format r (Char -> r)
c = (Char -> Builder) -> Format r (Char -> r)
forall a r. (a -> Builder) -> Format r (a -> r)
later Char -> Builder
forall p. Buildable p => p -> Builder
B.build
{-# INLINE c #-}
f :: Real a => Int -> Format r (a -> r)
f :: Int -> Format r (a -> r)
f Int
i = (a -> Builder) -> Format r (a -> r)
forall a r. (a -> Builder) -> Format r (a -> r)
later (Int -> a -> Builder
forall a. Real a => Int -> a -> Builder
T.fixed Int
i)
{-# INLINE f #-}
sf :: Real a => Format r (a -> r)
sf :: Format r (a -> r)
sf = (a -> Builder) -> Format r (a -> r)
forall a r. (a -> Builder) -> Format r (a -> r)
later a -> Builder
forall a. Real a => a -> Builder
T.shortest
{-# INLINE sf #-}
l :: Buildable a => Int -> Char -> Format r (a -> r)
l :: Int -> Char -> Format r (a -> r)
l Int
i Char
ch = (a -> Builder) -> Format r (a -> r)
forall a r. (a -> Builder) -> Format r (a -> r)
later (Int -> Char -> a -> Builder
forall a. Buildable a => Int -> Char -> a -> Builder
T.left Int
i Char
ch)
{-# INLINE l #-}
r :: Buildable a => Int -> Char -> Format r (a -> r)
r :: Int -> Char -> Format r (a -> r)
r Int
i Char
ch = (a -> Builder) -> Format r (a -> r)
forall a r. (a -> Builder) -> Format r (a -> r)
later (Int -> Char -> a -> Builder
forall a. Buildable a => Int -> Char -> a -> Builder
T.right Int
i Char
ch)
{-# INLINE r #-}