module Data.Text.All
(
module Data.Text,
module Data.Text.IO,
module Data.Text.Encoding,
LText,
toStrict, toLazy, toBuilder, toString,
show, lshow, bshow,
module Data.Text.Format,
module Data.Text.Buildable,
format, lformat, bformat,
Builder,
bsingleton,
flush,
)
where
import Data.Text
import Data.Text.IO
import Data.Text.Encoding
import qualified Data.Text.Lazy.Builder as B
import Data.Text.Lazy.Builder (Builder, flush)
import qualified Data.Text.Lazy as TL
import Data.Text.Format hiding (format, print, hprint, build)
import Data.Text.Format.Params
import Data.Text.Buildable
import qualified Data.Text.Format as Format
import qualified Prelude as P
import Prelude hiding (show)
type LText = TL.Text
show :: Show a => a -> Text
show = pack . P.show
lshow :: Show a => a -> LText
lshow = TL.pack . P.show
bshow :: Show a => a -> Builder
bshow = B.fromString . P.show
format :: Params ps => Format -> ps -> Text
format f = TL.toStrict . Format.format f
lformat :: Params ps => Format -> ps -> LText
lformat = Format.format
bformat :: Params ps => Format -> ps -> Builder
bformat = Format.build
class ToStrict t where
toStrict :: t -> Text
instance (a ~ Char) => ToStrict [a] where
toStrict = pack
instance ToStrict LText where
toStrict = TL.toStrict
instance ToStrict Builder where
toStrict = TL.toStrict . B.toLazyText
class ToLazy t where
toLazy :: t -> LText
instance (a ~ Char) => ToLazy [a] where
toLazy = TL.pack
instance ToLazy Text where
toLazy = TL.fromStrict
instance ToLazy Builder where
toLazy = B.toLazyText
class ToBuilder t where
toBuilder :: t -> Builder
instance (a ~ Char) => ToBuilder [a] where
toBuilder = B.fromString
instance ToBuilder Text where
toBuilder = B.fromText
instance ToBuilder LText where
toBuilder = B.fromLazyText
class ToString t where
toString :: t -> String
instance ToString Text where
toString = unpack
instance ToString LText where
toString = TL.unpack
instance ToString Builder where
toString = TL.unpack . B.toLazyText
bsingleton :: Char -> Builder
bsingleton = B.singleton