The builder monoid from BlazeHtml.
Usage is fairly straightforward. Builders can be constructed from many
strings :: [String] strings = replicate 10000 "Hello there!"
Concatenation should happen through the
concatenation :: Builder concatenation = mconcat $ map fromString strings
result :: L.ByteString result = toLazyByteString concatenation
- data Builder
- data Write = Write !Int (Ptr Word8 -> IO ())
- writeByte :: Word8 -> Write
- writeByteString :: ByteString -> Write
- writeSingleton :: (a -> Write) -> a -> Builder
- writeList :: (a -> Write) -> [a] -> Builder
- singleton :: Word8 -> Builder
- fromByteString :: ByteString -> Builder
- toLazyByteString :: Builder -> ByteString
Main builder type
Main builder type. It simply contains a function to extract the actual data.
Custom writes to the builder
Write abstraction so we can avoid some gory and bloody details. A write abstration holds the exact size of the write in bytes, and a function to carry out the write operation.
Write a strict
Construct a builder writing a list of data from a write abstraction.
Builder from a single byte.
O(n). A Builder taking a
ByteString, copying it.