foldl-1.3.0: Composable, streaming, and efficient left folds

Safe Haskell | None
Language | Haskell98

Control.Foldl.ByteString

Contents

- Folding
- Folds
- Re-exports

Description

Folds for byte streams

Synopsis

- fold :: Fold ByteString a -> ByteString -> a
- foldM :: Monad m => FoldM m ByteString a -> ByteString -> m a
- head :: Fold ByteString (Maybe Word8)
- last :: Fold ByteString (Maybe Word8)
- null :: Fold ByteString Bool
- length :: Num n => Fold ByteString n
- any :: (Word8 -> Bool) -> Fold ByteString Bool
- all :: (Word8 -> Bool) -> Fold ByteString Bool
- maximum :: Fold ByteString (Maybe Word8)
- minimum :: Fold ByteString (Maybe Word8)
- elem :: Word8 -> Fold ByteString Bool
- notElem :: Word8 -> Fold ByteString Bool
- find :: (Word8 -> Bool) -> Fold ByteString (Maybe Word8)
- index :: Integral n => n -> Fold ByteString (Maybe Word8)
- elemIndex :: Num n => Word8 -> Fold ByteString (Maybe n)
- findIndex :: Num n => (Word8 -> Bool) -> Fold ByteString (Maybe n)
- count :: Num n => Word8 -> Fold ByteString n
- lazy :: Fold ByteString ByteString
- module Control.Foldl
- module Data.ByteString
- module Data.Word

# Folding

fold :: Fold ByteString a -> ByteString -> a #

Apply a strict left `Fold` to a lazy bytestring

foldM :: Monad m => FoldM m ByteString a -> ByteString -> m a #

Apply a strict monadic left `FoldM` to a lazy bytestring

# Folds

head :: Fold ByteString (Maybe Word8) #

Get the first byte of a byte stream or return `Nothing` if the stream is empty

last :: Fold ByteString (Maybe Word8) #

Get the last byte of a byte stream or return `Nothing` if the byte stream is empty

null :: Fold ByteString Bool #

Returns `True` if the byte stream is empty, `False` otherwise

length :: Num n => Fold ByteString n #

Return the length of the byte stream in bytes

any :: (Word8 -> Bool) -> Fold ByteString Bool #

`(any predicate)` returns `True` if any byte satisfies the predicate, `False` otherwise

all :: (Word8 -> Bool) -> Fold ByteString Bool #

`(all predicate)` returns `True` if all bytes satisfy the predicate, `False` otherwise

maximum :: Fold ByteString (Maybe Word8) #

Computes the maximum byte

minimum :: Fold ByteString (Maybe Word8) #

Computes the minimum byte

elem :: Word8 -> Fold ByteString Bool #

`(elem w8)` returns `True` if the byte stream has a byte equal to `w8`, `False` otherwise

notElem :: Word8 -> Fold ByteString Bool #

`(notElem w8)` returns `False` if the byte stream has a byte equal to `w8`, `True` otherwise

find :: (Word8 -> Bool) -> Fold ByteString (Maybe Word8) #

`(find predicate)` returns the first byte that satisfies the predicate or `Nothing` if no byte satisfies the predicate

index :: Integral n => n -> Fold ByteString (Maybe Word8) #

`(index n)` returns the `n`th byte of the byte stream, or `Nothing` if the stream has an insufficient number of bytes

elemIndex :: Num n => Word8 -> Fold ByteString (Maybe n) #

`(elemIndex w8)` returns the index of the first byte that equals `w8`, or `Nothing` if no byte matches

findIndex :: Num n => (Word8 -> Bool) -> Fold ByteString (Maybe n) #

`(findIndex predicate)` returns the index of the first byte that satisfies the predicate, or `Nothing` if no byte satisfies the predicate

count :: Num n => Word8 -> Fold ByteString n #

`count w8` returns the number of times `w8` appears

lazy :: Fold ByteString ByteString #

Combine all the strict `ByteString` chunks to build a lazy `ByteString`

# Re-exports

Control.Foldl re-exports the `Fold` type

`Data.ByteString` re-exports the `ByteString` type

`Data.Word` re-exports the `Word8` type

module Control.Foldl

module Data.ByteString

module Data.Word