lens-4.19.2: Lenses, Folds and Traversals
Copyright(C) 2012-16 Edward Kmett
LicenseBSD-style (see the file LICENSE)
MaintainerEdward Kmett <ekmett@gmail.com>
Stabilityexperimental
Portabilitynon-portable
Safe HaskellNone
LanguageHaskell2010

Data.ByteString.Lens

Description

 
Synopsis

Documentation

class IsByteString t where #

Traversals for ByteStrings.

Minimal complete definition

packedBytes, packedChars

Methods

packedBytes :: Iso' [Word8] t #

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

pack x ≡ x ^. packedBytes
unpack x ≡ x ^. from packedBytes
packedBytesfrom unpackedBytes

packedChars :: Iso' String t #

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
packedCharsfrom unpackedChars

bytes :: IndexedTraversal' Int t Word8 #

Traverse each Word8 in a strict or lazy ByteString

This Traversal walks each strict ByteString chunk in a tree-like fashion enable zippers to seek to locations more quickly and accelerate many monoidal queries, but up to associativity (and constant factors) it is equivalent to the much slower:

bytesunpackedBytes . traversed
anyOf bytes (== 0x80) :: ByteString -> Bool

chars :: IndexedTraversal' Int t Char #

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'.

This Traversal walks each strict ByteString chunk in a tree-like fashion enable zippers to seek to locations more quickly and accelerate many monoidal queries, but up to associativity (and constant factors) it is equivalent to the much slower:

charsunpackedChars . traversed
anyOf chars (== 'c') :: ByteString -> Bool

unpackedChars :: IsByteString t => Iso' t String #

unpack (or pack) 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'.

unpackedCharsfrom packedChars
unpack x ≡ x ^. unpackedChars
pack x ≡ x ^. from unpackedChars
unpackedChars :: Iso' ByteString String
unpackedChars :: Iso' ByteString String

pattern Bytes :: IsByteString s => [Word8] -> s #

pattern Chars :: IsByteString s => [Char] -> s #