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

Safe HaskellNone
LanguageHaskell2010

Data.Text.All

Contents

Description

Here are the nice things from text that you get (thanks to a restrictive lower bound) but that aren't documented elsewhere in this module:

  • The takeWhileEnd function.
  • An instance for Semigroup.
  • An instance for printf (i.e. you can use a Text as one of printf's arguments).
  • An instance for Binary.

Synopsis

Standard modules from text

module Data.Text

Lazy Text

Conversion

These functions can convert from strict/lazy Text, Builder, and String.

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

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

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

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

Showing

show is a fast variant of show for Text / Builder that only works for some types – it's very fast for Int, etc, but doesn't work for types that you have defined yourself. (If you want more instances, import text-show-instances.)

show' is a shortcut for pack.show that works for everything with a Show instance but is slower.

Strict Text

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

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

Lazy Text

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

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

Builder

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.