ByteString.TreeBuilder

bytestring-tree-builder-0.2.7.1: A very efficient ByteString builder implementation based on the binary tree

Safe Haskell | None
Language | Haskell2010

ByteString.TreeBuilder

Contents

- Declaration
  - Primitives
  - Extras
- Execution

Synopsis

- data Builder
- byteString :: ByteString -> Builder
- byte :: Word8 -> Builder
- asciiIntegral :: Integral a => a -> Builder
- asciiChar :: Char -> Builder
- utf8Char :: Char -> Builder
- utf8Ord :: Int -> Builder
- utf8Text :: Text -> Builder
- utf8LazyText :: Text -> Builder
- intercalate :: (Foldable f, Monoid m) => m -> f m -> m
- length :: Builder -> Int
- toByteString :: Builder -> ByteString
- toLazyByteString :: Builder -> ByteString

# Documentation

data Builder #

A binary-tree-based datastructure optimized for aggregation of bytestrings using the O(1) appending operation.

Instances

IsString Builder # |
Methods fromString :: String -> Builder #
Semigroup Builder # |
Methods (<>) :: Builder -> Builder -> Builder # sconcat :: NonEmpty Builder -> Builder # stimes :: Integral b => b -> Builder -> Builder #
Monoid Builder # | Implements `mappend` with O(1) complexity.
Methods mempty :: Builder # mappend :: Builder -> Builder -> Builder # mconcat :: [Builder] -> Builder #

# Declaration

## Primitives

byteString :: ByteString -> Builder #

Lifts a bytestring into the builder.

byte :: Word8 -> Builder #

Lifts a single byte into the builder.

## Extras

asciiIntegral :: Integral a => a -> Builder #

asciiChar :: Char -> Builder #

utf8Char :: Char -> Builder #

utf8Ord :: Int -> Builder #

utf8Text :: Text -> Builder #

utf8LazyText :: Text -> Builder #

intercalate :: (Foldable f, Monoid m) => m -> f m -> m #

# Execution

length :: Builder -> Int #

O(1). Gets the total length.

toByteString :: Builder -> ByteString #

O(n). Converts the builder into a strict bytestring.

toLazyByteString :: Builder -> ByteString #

O(n). Converts the builder into a lazy bytestring.