lens-1.4.1: Lenses, Folds and Traversals

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

Data.ByteString.Lens

Description

 

Synopsis

Documentation

packedBytes :: Simple Iso [Word8] ByteStringSource

Pack (or unpack) a list of bytes into a ByteString

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

bytes :: Simple Traversal ByteString Word8Source

Traverse the individual bytes in a ByteString

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

packedChars :: Simple Iso String ByteStringSource

Pack (or unpack) a list of characters into a ByteString

When writing back to the byteString it is assumed that all characters lie between '\x00' and '\xff'.

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

chars :: Simple Traversal ByteString CharSource

Traverse the individual bytes in a ByteString as characters.

When writing back to the byteString it is assumed that all characters lie between '\x00' and '\xff'.

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