| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Data.Text.All
Description
Note that thanks to a restrictive lower bound on text, you can be sure
that the following things will be present in the Data.Text reexport:
- The
takeWhileEndfunction. - An instance for
Semigroup Text. - An instance for
Binary Text. - An instance for
printf(i.e. you can use aTextas one ofprintf's arguments).
- module Data.Text
- module Data.Text.IO
- module Data.Text.Encoding
- type LText = Text
- toStrict :: ToStrict t => t -> Text
- toLazy :: ToLazy t => t -> LText
- toBuilder :: ToBuilder t => t -> Builder
- toString :: ToString t => t -> String
- toByteString :: ToByteString t => t -> ByteString
- toLByteString :: ToLByteString t => t -> ByteString
- show :: Show a => a -> Text
- lshow :: Show a => a -> LText
- bshow :: Show a => a -> Builder
- module Data.Text.Format
- module Data.Text.Buildable
- format :: Params ps => Format -> ps -> Text
- lformat :: Params ps => Format -> ps -> LText
- bformat :: Params ps => Format -> ps -> Builder
- data Builder :: *
- bsingleton :: Char -> Builder
- flush :: Builder
Standard modules from text
module Data.Text
module Data.Text.IO
module Data.Text.Encoding
Lazy Text
Conversion
These functions can convert from strict/lazy Text, Builder,
String, and strict/lazy ByteString (in which case they use lenient
UTF-8 decoding).
toByteString :: ToByteString t => t -> ByteString Source #
toLByteString :: ToLByteString t => t -> ByteString Source #
Showing
Variants below use show from Prelude. If you want faster showing,
either use text-show or some
formatting library.
Formatting
format is a function similar to printf in spirit. Don't forget to enable
OverloadedStrings if you want to use it!
>>>format "{}+{}={}" (2, 2, 4)"2+2=4"
If you have only one argument, use a list:
>>>format "2+2={}" [4]"2+2=4"
There are some formatting options available:
>>>format "123 = 0x{}, pi = {}" (hex 123, fixed 5 pi)"123 = 0x7b, pi = 3.14159"
For more formatters, see Data.Text.Format.
module Data.Text.Format
module Data.Text.Buildable
Builder
A Builder is an efficient way to build lazy Text values.
There are several functions for constructing builders, but only one
to inspect them: to extract any data, you have to turn them into
lazy Text values using toLazyText.
Internally, a builder constructs a lazy Text by filling arrays
piece by piece. As each buffer is filled, it is 'popped' off, to
become a new chunk of the resulting lazy Text. All this is
hidden from the user of the Builder.