text-all-0.4.2: Everything Data.Text related in one package

Safe HaskellNone
LanguageHaskell2010

Data.Text.All

Contents

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 takeWhileEnd function.
  • An instance for Semigroup Text.
  • An instance for Binary Text.
  • An instance for printf (i.e. you can use a Text as one of printf's arguments).

Synopsis

Standard modules from text

module Data.Text

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).

toStrict :: ToStrict t => t -> Text Source #

toLazy :: ToLazy t => t -> LText Source #

toBuilder :: ToBuilder t => t -> Builder Source #

toString :: ToString t => t -> String Source #

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.

show :: Show a => a -> Text Source #

lshow :: Show a => a -> LText Source #

bshow :: Show a => a -> Builder Source #

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.

format :: Params ps => Format -> ps -> Text Source #

lformat :: Params ps => Format -> ps -> LText Source #

bformat :: Params ps => Format -> ps -> Builder Source #

Builder

data 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.

bsingleton :: Char -> Builder Source #

A Builder producing a single character.

flush :: Builder #

O(1). Pop the strict Text we have constructed so far, if any, yielding a new chunk in the result lazy Text.