| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Data.ByteString.Lazy.Optics
Description
Lazy ByteString lenses.
Synopsis
- packedBytes :: Iso' [Word8] ByteString
- unpackedBytes :: Iso' ByteString [Word8]
- bytes :: IxTraversal' Int64 ByteString Word8
- packedChars :: Iso' String ByteString
- unpackedChars :: Iso' ByteString String
- chars :: IxTraversal' Int64 ByteString Char
- pattern Bytes :: [Word8] -> ByteString
- pattern Chars :: [Char] -> ByteString
Documentation
packedBytes :: Iso' [Word8] ByteString Source #
pack (or unpack) a list of
bytes into a ByteString.
packedBytes≡reunpackedBytespackx ≡ x^.packedBytesunpackx ≡ x^.repackedBytes
>>>[104,101,108,108,111] ^. packedBytes == Char8.pack "hello"True
unpackedBytes :: Iso' ByteString [Word8] Source #
unpack (or pack) a
ByteString into a list of bytes.
unpackedBytes≡repackedBytesunpackx ≡ x^.unpackedBytespackx ≡ x^.reunpackedBytes
>>>"hello" ^. packedChars % unpackedBytes[104,101,108,108,111]
bytes :: IxTraversal' Int64 ByteString Word8 Source #
Traverse the individual bytes in a 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:
bytes≡unpackedBytes%traversed
>>>anyOf bytes (== 0x80) (Char8.pack "hello")False
Note that when just using this as a Setter, can be more efficient.sets
map
packedChars :: Iso' String ByteString Source #
pack (or unpack)
a list of characters into a ByteString.
When writing back to the ByteString it is assumed that every Char lies
between '\x00' and '\xff'.
packedChars≡reunpackedCharspackx ≡ x^.packedCharsunpackx ≡ x^.repackedChars
>>>foldOf (packedChars % each % to (\w -> let x = showHex w "" in if Prelude.length x == 1 then '0':x else x)) "hello""68656c6c6f"
unpackedChars :: Iso' ByteString String Source #
unpack (or pack)
a list of characters into a ByteString
When writing back to the ByteString it is assumed that every Char lies
between '\x00' and '\xff'.
unpackedChars≡repackedCharsunpackx ≡ x^.unpackedCharspackx ≡ x^.reunpackedChars
>>>[104,101,108,108,111] ^. packedBytes % unpackedChars"hello"
chars :: IxTraversal' Int64 ByteString Char Source #
Traverse the individual bytes in a 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:
chars=unpackedChars%traversed
>>>anyOf chars (== 'h') $ Char8.pack "hello"True
pattern Bytes :: [Word8] -> ByteString Source #
pattern Chars :: [Char] -> ByteString Source #