[[a]] -> [a] -base +bytestring
O(n) Concatenate a list of ByteStrings.
unlines is an inverse operation to lines. It joins lines, after appending a terminating newline to each.
Encode a list of values 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 the canonical
> filter p =
> B.toLazyByteString .
> E.encodeLazyByteStringWithF (E.ifF p E.word8) E.emptyF)
> mconcat . map (primBounded w)
> foldMap (primBounded w)
because it moves several variables out of the inner loop.
O(n) The intercalate function takes a ByteString and a list of ByteStrings and concatenates the list after interspersing the first argument between each element of the list.
A fmap-like operator for builder primitives, both bounded and fixed size.
Builder primitives are contravariant so it's like the normal fmap, but backwards (look at the type). (If it helps to remember, the operator symbol is like ($) but backwards.)
We can use it for example to prepend and/or append fixed values to an primitive.
> showEncoding ((\x -> ('\'', (x, '\''))) >$< fixed3) 'x' = "'x'"
> fixed3 = char7 >*< char7 >*< char7
Note that the rather verbose syntax for composition stems from the requirement to be able to compute the size / size bound at compile time.