Blaze.ByteString.Builder.Compat.Write

blaze-builder-0.4.2.2: Efficient buffered output.

Copyright | (c) 2013 Leon P Smith
License | BSD3
Maintainer | https://github.com/blaze-builder
Stability | stable
Safe Haskell | Safe-Inferred
Language | Haskell98

Blaze.ByteString.Builder.Compat.Write

Description

Conversions from the new Prims to the old Writes.

Synopsis

- data Write
- writePrimFixed :: FixedPrim a -> a -> Write
- writePrimBounded :: BoundedPrim a -> a -> Write

# Documentation

data Write #

A write of a bounded number of bytes.

When defining a function `write :: a -> Write` for some `a`, then it is important to ensure that the bound on the number of bytes written is data-independent. Formally,

     forall x y. getBound (write x) = getBound (write y)

The idea is that this data-independent bound is specified such that the compiler can optimize the check, if there are enough free bytes in the buffer, to a single subtraction between the pointer to the next free byte and the pointer to the end of the buffer with this constant bound of the maximal number of bytes to be written.

#### Instances

Instances details

Monoid Write # |
Instance details Defined in Blaze.ByteString.Builder.Internal.Write Methods mempty :: Write # mappend :: Write -> Write -> Write # mconcat :: [Write] -> Write #
Semigroup Write # |
Instance details Defined in Blaze.ByteString.Builder.Internal.Write Methods (<>) :: Write -> Write -> Write # sconcat :: NonEmpty Write -> Write # stimes :: Integral b => b -> Write -> Write #

writePrimFixed :: FixedPrim a -> a -> Write #

writePrimBounded :: BoundedPrim a -> a -> Write #