map -package:conduit -package:charset -package:aeson package:bytestring

O(n) map f xs is the ByteString obtained by applying f to each element of xs.
O(n) map f xs is the ByteString obtained by applying f to each element of xs
O(n) map f xs is the ShortByteString obtained by applying f to each element of xs.
The mapAccumL function behaves like a combination of map and foldl; it applies a function to each element of a ByteString, passing an accumulating parameter from left to right, and returning a final value of this accumulator together with the new ByteString.
The mapAccumR function behaves like a combination of map and foldr; it applies a function to each element of a ByteString, passing an accumulating parameter from right to left, and returning a final value of this accumulator together with the new ByteString.
The mapAccumL function behaves like a combination of map and foldl; it applies a function to each element of a ByteString, passing an accumulating parameter from left to right, and returning a final value of this accumulator together with the new ByteString.
The mapAccumR function behaves like a combination of map and foldr; it applies a function to each element of a ByteString, passing an accumulating parameter from right to left, and returning a final value of this accumulator together with the new ByteString.
Map a function over a ByteString and concatenate the results
Create a Builder that encodes each Word8 of a strict ByteString using a BoundedPrim. For example, we can write a Builder that filters a strict ByteString as follows.
import qualified Data.ByteString.Builder.Prim as P
filterBS p = P.condB p (P.liftFixedToBounded P.word8) P.emptyB
Heavy inlining. Encode all bytes of a strict ByteString from left-to-right with a FixedPrim. This function is quite versatile. For example, we can use it to construct a Builder that maps every byte before copying it to the buffer to be filled.
mapToBuilder :: (Word8 -> Word8) -> S.ByteString -> Builder
mapToBuilder f = primMapByteStringFixed (contramapF f word8)
We can also use it to hex-encode a strict ByteString as shown by the byteStringHex example above.
Chunk-wise application of primMapByteStringBounded.
Heavy inlining. Encode all bytes of a lazy ByteString from left-to-right with a FixedPrim.
Create a Builder that encodes a list of values consecutively using a BoundedPrim for each element. This function is more efficient than
mconcat . map (primBounded w)
or
foldMap (primBounded w)
because it moves several variables out of the inner loop.
Encode a list of values from left-to-right with a FixedPrim.
Change a BoundedPrim such that it first applies a function to the value to be encoded. Note that BoundedPrims are Contravariant http://hackage.haskell.org/package/contravariant. Hence, the following laws hold.
contramapB id = id
contramapB f . contramapB g = contramapB (g . f)
Change a primitives such that it first applies a function to the value to be encoded. Note that primitives are Contravariant http://hackage.haskell.org/package/contravariant. Hence, the following laws hold.
contramapF id = id
contramapF f . contramapF g = contramapF (g . f)
Map a function over a ByteString and concatenate the results