Portability | portable to Hugs and GHC |
---|---|
Stability | experimental |
Maintainer | Johan Tibell <johan.tibell@gmail.com> |
Efficient construction of lazy texts.
The Builder type
A Builder
is an efficient way to build lazy Text
s. There
are several functions for constructing Builder
s, but only one to
inspect them: to extract any data, you have to turn them into lazy
Text
s using toLazyText
.
Internally, a Builder
constructs a lazy Text
by filling byte
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
.
toLazyText :: Builder -> TextSource
toLazyTextWith :: Int -> Builder -> TextSource
Constructing Builders
singleton :: Char -> BuilderSource
O(1). A Builder taking a single character, satisfying
toLazyText
(singleton
c) =singleton
c
fromText :: Text -> BuilderSource
O(1). A Builder taking a Text
, satisfying
toLazyText
(fromText
t) =fromChunks
[t]
fromLazyText :: Text -> BuilderSource
O(1). A Builder taking a lazy Text
, satisfying
toLazyText
(fromLazyText
t) = t