cons +bytestring

cons :: Char -> ByteString -> ByteString
bytestring Data.ByteString.Lazy.Char8
O(1) cons is analogous to '(:)' for lists.
cons :: Char -> ByteString -> ByteString
bytestring Data.ByteString.Char8
O(n) cons is analogous to (:) for lists, but of different complexity, as it requires a memcpy.
cons :: Word8 -> ByteString -> ByteString
bytestring Data.ByteString.Lazy
O(1) cons is analogous to '(:)' for lists.
cons :: Word8 -> ByteString -> ByteString
bytestring Data.ByteString
O(n) cons is analogous to (:) for lists, but of different complexity, as it requires a memcpy.
cons' :: Char -> ByteString -> ByteString
bytestring Data.ByteString.Lazy.Char8
O(1) Unlike cons, 'cons\'' is strict in the ByteString that we are consing onto. More precisely, it forces the head and the first chunk. It does this because, for space efficiency, it may coalesce the new byte onto the first 'chunk' rather than starting a new 'chunk'. So that means you can't use a lazy recursive contruction like this: > let xs = cons\' c xs in xs You can however use cons, as well as repeat and cycle, to build infinite lazy ByteStrings.
cons' :: Word8 -> ByteString -> ByteString
bytestring Data.ByteString.Lazy
O(1) Unlike cons, 'cons\'' is strict in the ByteString that we are consing onto. More precisely, it forces the head and the first chunk. It does this because, for space efficiency, it may coalesce the new byte onto the first 'chunk' rather than starting a new 'chunk'. So that means you can't use a lazy recursive contruction like this: > let xs = cons\' c xs in xs You can however use cons, as well as repeat and cycle, to build infinite lazy ByteStrings.
uncons :: ByteString -> Maybe (Char, ByteString)
bytestring Data.ByteString.Char8, bytestring Data.ByteString.Lazy.Char8
O(1) Extract the head and tail of a ByteString, returning Nothing if it is empty.
uncons :: ByteString -> Maybe (Word8, ByteString)
bytestring Data.ByteString, bytestring Data.ByteString.Lazy
O(1) Extract the head and tail of a ByteString, returning Nothing if it is empty.