lens-3.3: Lenses, Folds and Traversals

Portabilityportable
Stabilityprovisional
MaintainerEdward Kmett <ekmett@gmail.com>
Safe HaskellSafe-Inferred

Data.ByteString.Lens

Description

 

Synopsis

Documentation

class IsByteString t whereSource

Traversals for ByteStrings.

Methods

packedBytes :: Simple Iso [Word8] tSource

pack (or unpack) a list of bytes into a strict or lazy ByteString

pack x = x ^. packedBytes
unpack x = x ^. from packedBytes

packedChars :: Simple Iso String tSource

pack (or unpack) a list of characters into a strict or lazy ByteString

When writing back to the ByteString it is assumed that every Char lies between '\x00' and '\xff'.

pack x = x ^. packedChars
unpack x = x ^. from packedChars

bytes :: SimpleIndexedTraversal Int t Word8Source

Traverse each Word8 in a strict or lazy ByteString

bytes = from packedBytes .> traverseList
anyOf bytes (== 0x80) :: ByteString -> Bool

chars :: SimpleIndexedTraversal Int t CharSource

Traverse the individual bytes in a strict or lazy ByteString as characters.

When writing back to the ByteString it is assumed that every Char lies between '\x00' and '\xff'.

chars = from packedChars . traverse
anyOf chars (== 'c') :: ByteString -> Bool