rio-0.1.22.0: A standard library for Haskell

Safe Haskell | Safe-Inferred
Language | Haskell2010

RIO.ByteString.Lazy

Contents

- The `ByteString` type
- Introducing and eliminating `ByteString`s
- Basic interface
- Transforming ByteStrings
- Reducing `ByteString`s (folds)
  - Special folds
- Building ByteStrings
  - Scans
  - Accumulating maps
  - Infinite ByteStrings
  - Unfolding ByteStrings
- Substrings
  - Breaking strings
  - Breaking into many substrings
- Predicates
- Search ByteStrings
  - Searching by equality
  - Searching with a predicate
- Indexing ByteStrings
- Zipping and unzipping ByteStrings
- Low level conversions
  - Copying ByteStrings
- I/O with `ByteString`s
  - Standard input and output
  - Files
  - I/O with Handles

Description

Lazy `ByteString`. Import as:

    import qualified RIO.ByteString.Lazy as BL

This module does not export any partial functions. For those, see RIO.ByteString.Lazy.Partial

Synopsis

- data ByteString
- empty :: ByteString
- singleton :: Word8 -> ByteString
- pack :: [Word8] -> ByteString
- unpack :: ByteString -> [Word8]
- fromStrict :: ByteString -> ByteString
- toStrict :: ByteString -> ByteString
- fromChunks :: [ByteString] -> ByteString
- toChunks :: ByteString -> [ByteString]
- foldrChunks :: (ByteString -> a -> a) -> a -> ByteString -> a
- foldlChunks :: (a -> ByteString -> a) -> a -> ByteString -> a
- cons :: Word8 -> ByteString -> ByteString
- cons' :: Word8 -> ByteString -> ByteString
- snoc :: ByteString -> Word8 -> ByteString
- append :: ByteString -> ByteString -> ByteString
- uncons :: ByteString -> Maybe (Word8, ByteString)
- unsnoc :: ByteString -> Maybe (ByteString, Word8)
- null :: ByteString -> Bool
- length :: ByteString -> Int64
- map :: (Word8 -> Word8) -> ByteString -> ByteString
- reverse :: ByteString -> ByteString
- intersperse :: Word8 -> ByteString -> ByteString
- intercalate :: ByteString -> [ByteString] -> ByteString
- transpose :: [ByteString] -> [ByteString]
- foldl :: (a -> Word8 -> a) -> a -> ByteString -> a
- foldl' :: (a -> Word8 -> a) -> a -> ByteString -> a
- foldr :: (Word8 -> a -> a) -> a -> ByteString -> a
- concat :: [ByteString] -> ByteString
- concatMap :: (Word8 -> ByteString) -> ByteString -> ByteString
- any :: (Word8 -> Bool) -> ByteString -> Bool
- all :: (Word8 -> Bool) -> ByteString -> Bool
- scanl :: (Word8 -> Word8 -> Word8) -> Word8 -> ByteString -> ByteString
- mapAccumL :: (acc -> Word8 -> (acc, Word8)) -> acc -> ByteString -> (acc, ByteString)
- mapAccumR :: (acc -> Word8 -> (acc, Word8)) -> acc -> ByteString -> (acc, ByteString)
- repeat :: Word8 -> ByteString
- replicate :: Int64 -> Word8 -> ByteString
- cycle :: HasCallStack => ByteString -> ByteString
- iterate :: (Word8 -> Word8) -> Word8 -> ByteString
- unfoldr :: (a -> Maybe (Word8, a)) -> a -> ByteString
- take :: Int64 -> ByteString -> ByteString
- drop :: Int64 -> ByteString -> ByteString
- splitAt :: Int64 -> ByteString -> (ByteString, ByteString)
- takeWhile :: (Word8 -> Bool) -> ByteString -> ByteString
- dropWhile :: (Word8 -> Bool) -> ByteString -> ByteString
- span :: (Word8 -> Bool) -> ByteString -> (ByteString, ByteString)
- break :: (Word8 -> Bool) -> ByteString -> (ByteString, ByteString)
- group :: ByteString -> [ByteString]
- groupBy :: (Word8 -> Word8 -> Bool) -> ByteString -> [ByteString]
- inits :: ByteString -> [ByteString]
- tails :: ByteString -> [ByteString]
- stripPrefix :: ByteString -> ByteString -> Maybe ByteString
- stripSuffix :: ByteString -> ByteString -> Maybe ByteString
- split :: Word8 -> ByteString -> [ByteString]
- splitWith :: (Word8 -> Bool) -> ByteString -> [ByteString]
- isPrefixOf :: ByteString -> ByteString -> Bool
- isSuffixOf :: ByteString -> ByteString -> Bool
- elem :: Word8 -> ByteString -> Bool
- notElem :: Word8 -> ByteString -> Bool
- find :: (Word8 -> Bool) -> ByteString -> Maybe Word8
- filter :: (Word8 -> Bool) -> ByteString -> ByteString
- partition :: (Word8 -> Bool) -> ByteString -> (ByteString, ByteString)
- index :: HasCallStack => ByteString -> Int64 -> Word8
- elemIndex :: Word8 -> ByteString -> Maybe Int64
- elemIndexEnd :: Word8 -> ByteString -> Maybe Int64
- elemIndices :: Word8 -> ByteString -> [Int64]
- findIndex :: (Word8 -> Bool) -> ByteString -> Maybe Int64
- findIndices :: (Word8 -> Bool) -> ByteString -> [Int64]
- count :: Word8 -> ByteString -> Int64
- zip :: ByteString -> ByteString -> [(Word8, Word8)]
- zipWith :: (Word8 -> Word8 -> a) -> ByteString -> ByteString -> [a]
- unzip :: [(Word8, Word8)] -> (ByteString, ByteString)
- copy :: ByteString -> ByteString
- getContents :: MonadIO m => m LByteString
- putStr :: MonadIO m => LByteString -> m ()
- putStrLn :: MonadIO m => LByteString -> m ()
- interact :: MonadIO m => (LByteString -> LByteString) -> m ()
- readFile :: MonadIO m => FilePath -> m LByteString
- writeFile :: MonadIO m => FilePath -> LByteString -> m ()
- appendFile :: MonadIO m => FilePath -> LByteString -> m ()
- hGetContents :: MonadIO m => Handle -> m LByteString
- hGet :: MonadIO m => Handle -> Int -> m LByteString
- hGetNonBlocking :: MonadIO m => Handle -> Int -> m LByteString
- hPut :: MonadIO m => Handle -> LByteString -> m ()
- hPutNonBlocking :: MonadIO m => Handle -> LByteString -> m LByteString
- hPutStr :: MonadIO m => Handle -> LByteString -> m ()

# The `ByteString` type

data ByteString #

#### Instances

Instances details

Data ByteString |
Instance details Defined in Data.ByteString.Lazy.Internal Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> ByteString -> c ByteString # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c ByteString # toConstr :: ByteString -> Constr # dataTypeOf :: ByteString -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c ByteString) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c ByteString) # gmapT :: (forall b. Data b => b -> b) -> ByteString -> ByteString # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> ByteString -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> ByteString -> r # gmapQ :: (forall d. Data d => d -> u) -> ByteString -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> ByteString -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> ByteString -> m ByteString # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> ByteString -> m ByteString # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> ByteString -> m ByteString #
IsString ByteString |
Instance details Defined in Data.ByteString.Lazy.Internal Methods fromString :: String -> ByteString #
Monoid ByteString |
Instance details Defined in Data.ByteString.Lazy.Internal Methods mempty :: ByteString # mappend :: ByteString -> ByteString -> ByteString # mconcat :: [ByteString] -> ByteString #
Semigroup ByteString |
Instance details Defined in Data.ByteString.Lazy.Internal Methods (<>) :: ByteString -> ByteString -> ByteString # sconcat :: NonEmpty ByteString -> ByteString stimes :: Integral b => b -> ByteString -> ByteString
IsList ByteString |
Instance details Defined in Data.ByteString.Lazy.Internal Associated Types type Item ByteString Methods fromList :: [Item ByteString] -> ByteString fromListN :: Int -> [Item ByteString] -> ByteString toList :: ByteString -> [Item ByteString]
Read ByteString |
Instance details Defined in Data.ByteString.Lazy.Internal Methods readsPrec :: Int -> ReadS ByteString readList :: ReadS [ByteString] readPrec :: ReadPrec ByteString readListPrec :: ReadPrec [ByteString]
Show ByteString |
Instance details Defined in Data.ByteString.Lazy.Internal Methods showsPrec :: Int -> ByteString -> ShowS show :: ByteString -> String # showList :: [ByteString] -> ShowS
NFData ByteString |
Instance details Defined in Data.ByteString.Lazy.Internal Methods rnf :: ByteString -> () #
Eq ByteString |
Instance details Defined in Data.ByteString.Lazy.Internal Methods (==) :: ByteString -> ByteString -> Bool # (/=) :: ByteString -> ByteString -> Bool #
Ord ByteString |
Instance details Defined in Data.ByteString.Lazy.Internal Methods compare :: ByteString -> ByteString -> Ordering # (<) :: ByteString -> ByteString -> Bool # (<=) :: ByteString -> ByteString -> Bool # (>) :: ByteString -> ByteString -> Bool # (>=) :: ByteString -> ByteString -> Bool # max :: ByteString -> ByteString -> ByteString # min :: ByteString -> ByteString -> ByteString #
Hashable ByteString |
Instance details Defined in Data.Hashable.Class Methods hashWithSalt :: Int -> ByteString -> Int # hash :: ByteString -> Int #
Lift ByteString |
Instance details Defined in Data.ByteString.Lazy.Internal Methods lift :: Quote m => ByteString -> m Exp liftTyped :: forall (m :: Type -> Type). Quote m => ByteString -> Code m ByteString
type Item ByteString |
Instance details Defined in Data.ByteString.Lazy.Internal type Item ByteString = Word8

# Introducing and eliminating `ByteString`s

empty :: ByteString #

singleton :: Word8 -> ByteString #

pack :: [Word8] -> ByteString #

unpack :: ByteString -> [Word8] #

fromStrict :: ByteString -> ByteString #

toStrict :: ByteString -> ByteString #

fromChunks :: [ByteString] -> ByteString #

toChunks :: ByteString -> [ByteString] #

foldrChunks :: (ByteString -> a -> a) -> a -> ByteString -> a #

foldlChunks :: (a -> ByteString -> a) -> a -> ByteString -> a #

# Basic interface

cons :: Word8 -> ByteString -> ByteString #

cons' :: Word8 -> ByteString -> ByteString #

snoc :: ByteString -> Word8 -> ByteString #

append :: ByteString -> ByteString -> ByteString #

uncons :: ByteString -> Maybe (Word8, ByteString) #

unsnoc :: ByteString -> Maybe (ByteString, Word8) #

null :: ByteString -> Bool #

length :: ByteString -> Int64 #

# Transforming ByteStrings

map :: (Word8 -> Word8) -> ByteString -> ByteString #

reverse :: ByteString -> ByteString #

intersperse :: Word8 -> ByteString -> ByteString #

intercalate :: ByteString -> [ByteString] -> ByteString #

transpose :: [ByteString] -> [ByteString] #

# Reducing `ByteString`s (folds)

foldl :: (a -> Word8 -> a) -> a -> ByteString -> a #

foldl' :: (a -> Word8 -> a) -> a -> ByteString -> a #

foldr :: (Word8 -> a -> a) -> a -> ByteString -> a #

## Special folds

concat :: [ByteString] -> ByteString #

concatMap :: (Word8 -> ByteString) -> ByteString -> ByteString #

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

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

# Building ByteStrings

## Scans

scanl :: (Word8 -> Word8 -> Word8) -> Word8 -> ByteString -> ByteString #

## Accumulating maps

mapAccumL :: (acc -> Word8 -> (acc, Word8)) -> acc -> ByteString -> (acc, ByteString) #

mapAccumR :: (acc -> Word8 -> (acc, Word8)) -> acc -> ByteString -> (acc, ByteString) #

## Infinite ByteStrings

repeat :: Word8 -> ByteString #

replicate :: Int64 -> Word8 -> ByteString #

cycle :: HasCallStack => ByteString -> ByteString #

iterate :: (Word8 -> Word8) -> Word8 -> ByteString #

## Unfolding ByteStrings

unfoldr :: (a -> Maybe (Word8, a)) -> a -> ByteString #

# Substrings

## Breaking strings

take :: Int64 -> ByteString -> ByteString #

drop :: Int64 -> ByteString -> ByteString #

splitAt :: Int64 -> ByteString -> (ByteString, ByteString) #

takeWhile :: (Word8 -> Bool) -> ByteString -> ByteString #

dropWhile :: (Word8 -> Bool) -> ByteString -> ByteString #

span :: (Word8 -> Bool) -> ByteString -> (ByteString, ByteString) #

break :: (Word8 -> Bool) -> ByteString -> (ByteString, ByteString) #

group :: ByteString -> [ByteString] #

groupBy :: (Word8 -> Word8 -> Bool) -> ByteString -> [ByteString] #

inits :: ByteString -> [ByteString] #

tails :: ByteString -> [ByteString] #

stripPrefix :: ByteString -> ByteString -> Maybe ByteString #

stripSuffix :: ByteString -> ByteString -> Maybe ByteString #

## Breaking into many substrings

split :: Word8 -> ByteString -> [ByteString] #

splitWith :: (Word8 -> Bool) -> ByteString -> [ByteString] #

# Predicates

isPrefixOf :: ByteString -> ByteString -> Bool #

isSuffixOf :: ByteString -> ByteString -> Bool #

# Search ByteStrings

## Searching by equality

elem :: Word8 -> ByteString -> Bool #

notElem :: Word8 -> ByteString -> Bool #

## Searching with a predicate

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

filter :: (Word8 -> Bool) -> ByteString -> ByteString #

partition :: (Word8 -> Bool) -> ByteString -> (ByteString, ByteString) #

# Indexing ByteStrings

index :: HasCallStack => ByteString -> Int64 -> Word8 #

elemIndex :: Word8 -> ByteString -> Maybe Int64 #

elemIndexEnd :: Word8 -> ByteString -> Maybe Int64 #

elemIndices :: Word8 -> ByteString -> [Int64] #

findIndex :: (Word8 -> Bool) -> ByteString -> Maybe Int64 #

findIndices :: (Word8 -> Bool) -> ByteString -> [Int64] #

count :: Word8 -> ByteString -> Int64 #

# Zipping and unzipping ByteStrings

zip :: ByteString -> ByteString -> [(Word8, Word8)] #

zipWith :: (Word8 -> Word8 -> a) -> ByteString -> ByteString -> [a] #

unzip :: [(Word8, Word8)] -> (ByteString, ByteString) #

# Low level conversions

## Copying ByteStrings

copy :: ByteString -> ByteString #

# I/O with `ByteString`s

## Standard input and output

getContents :: MonadIO m => m LByteString #

Lifted `getContents`

putStr :: MonadIO m => LByteString -> m () #

Lifted `putStr`

putStrLn :: MonadIO m => LByteString -> m () #

Lifted `putStrLn`

interact :: MonadIO m => (LByteString -> LByteString) -> m () #

Lifted `interact`

## Files

readFile :: MonadIO m => FilePath -> m LByteString #

Lifted `readFile`

writeFile :: MonadIO m => FilePath -> LByteString -> m () #

Lifted `writeFile`

appendFile :: MonadIO m => FilePath -> LByteString -> m () #

Lifted `appendFile`

## I/O with Handles

hGetContents :: MonadIO m => Handle -> m LByteString #

Lifted `hGetContents`

hGet :: MonadIO m => Handle -> Int -> m LByteString #

Lifted `hGet`

hGetNonBlocking :: MonadIO m => Handle -> Int -> m LByteString #

Lifted `hGetNonBlocking`

hPut :: MonadIO m => Handle -> LByteString -> m () #

Lifted `hPut`

hPutNonBlocking :: MonadIO m => Handle -> LByteString -> m LByteString #

Lifted `hPutNonBlocking`

hPutStr :: MonadIO m => Handle -> LByteString -> m () #

Lifted `hPutStr`