| Copyright | (c) Andrey Mulik 2021 |
|---|---|
| License | BSD-style |
| Maintainer | work.a.mulik@gmail.com |
| Portability | non-portable (requires non-portable module) |
| Safe Haskell | Safe-Inferred |
| Language | Haskell2010 |
SDP.Text.Builder
Contents
Description
SDP.Text.Builder provides sdp instances for text Builder.
Note that Builder is a service type for efficient Text creation which
isn't intended for element-wise operations and content changes. Linear
instance provided for convenience and many functions (folds, selections,
etc.) creates intermediate structures (text, string, etc.).
Synopsis
- module SDP.Linear
- data Builder
- fromText :: Text -> Builder
- toLazyText :: Builder -> Text
- fromLazyText :: Text -> Builder
- flush :: Builder
Export
module SDP.Linear
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.
Instances
O(1). A Builder taking a Text, satisfying
toLazyText(fromTextt) =fromChunks[t]
toLazyText :: Builder -> Text #
O(n). Extract a lazy Text from a Builder with a default
buffer size. The construction work takes place if and when the
relevant part of the lazy Text is demanded.
fromLazyText :: Text -> Builder #
O(1). A Builder taking a lazy Text, satisfying
toLazyText(fromLazyTextt) = t
O(1). Pop the strict Text we have constructed so far, if any,
yielding a new chunk in the result lazy Text.