{-# LANGUAGE NoImplicitPrelude #-}

-- | 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"
module RIO.ByteString.Lazy
  (
  -- * The @ByteString@ type
    Data.ByteString.Lazy.ByteString

  -- * Introducing and eliminating 'ByteString's
  , Data.ByteString.Lazy.empty
  , Data.ByteString.Lazy.singleton
  , Data.ByteString.Lazy.pack
  , Data.ByteString.Lazy.unpack
  , Data.ByteString.Lazy.fromStrict
  , Data.ByteString.Lazy.toStrict
  , Data.ByteString.Lazy.fromChunks
  , Data.ByteString.Lazy.toChunks
  , Data.ByteString.Lazy.foldrChunks
  , Data.ByteString.Lazy.foldlChunks

  -- * Basic interface
  , Data.ByteString.Lazy.cons
  , Data.ByteString.Lazy.cons'
  , Data.ByteString.Lazy.snoc
  , Data.ByteString.Lazy.append
  , Data.ByteString.Lazy.uncons
  , Data.ByteString.Lazy.unsnoc
  , Data.ByteString.Lazy.null
  , Data.ByteString.Lazy.length

  -- * Transforming ByteStrings
  , Data.ByteString.Lazy.map
  , Data.ByteString.Lazy.reverse
  , Data.ByteString.Lazy.intersperse
  , Data.ByteString.Lazy.intercalate
  , Data.ByteString.Lazy.transpose

  -- * Reducing 'ByteString's (folds)
  , Data.ByteString.Lazy.foldl
  , Data.ByteString.Lazy.foldl'
  , Data.ByteString.Lazy.foldr

  -- ** Special folds
  , Data.ByteString.Lazy.concat
  , Data.ByteString.Lazy.concatMap
  , Data.ByteString.Lazy.any
  , Data.ByteString.Lazy.all

  -- * Building ByteStrings
  -- ** Scans
  , Data.ByteString.Lazy.scanl

  -- ** Accumulating maps
  , Data.ByteString.Lazy.mapAccumL
  , Data.ByteString.Lazy.mapAccumR

  -- ** Infinite ByteStrings
  , Data.ByteString.Lazy.repeat
  , Data.ByteString.Lazy.replicate
  , Data.ByteString.Lazy.cycle
  , Data.ByteString.Lazy.iterate

  -- ** Unfolding ByteStrings
  , Data.ByteString.Lazy.unfoldr

  -- * Substrings
  -- ** Breaking strings
  , Data.ByteString.Lazy.take
  , Data.ByteString.Lazy.drop
  , Data.ByteString.Lazy.splitAt
  , Data.ByteString.Lazy.takeWhile
  , Data.ByteString.Lazy.dropWhile
  , Data.ByteString.Lazy.span
  , Data.ByteString.Lazy.break
  , Data.ByteString.Lazy.group
  , Data.ByteString.Lazy.groupBy
  , Data.ByteString.Lazy.inits
  , Data.ByteString.Lazy.tails
  , Data.ByteString.Lazy.stripPrefix
  , Data.ByteString.Lazy.stripSuffix

  -- ** Breaking into many substrings
  , Data.ByteString.Lazy.split
  , Data.ByteString.Lazy.splitWith

  -- * Predicates
  , Data.ByteString.Lazy.isPrefixOf
  , Data.ByteString.Lazy.isSuffixOf

  -- * Search ByteStrings
  -- ** Searching by equality
  , Data.ByteString.Lazy.elem
  , Data.ByteString.Lazy.notElem

  -- ** Searching with a predicate
  , Data.ByteString.Lazy.find
  , Data.ByteString.Lazy.filter
  , Data.ByteString.Lazy.partition

  -- * Indexing ByteStrings
  , Data.ByteString.Lazy.index
  , Data.ByteString.Lazy.elemIndex
  , Data.ByteString.Lazy.elemIndexEnd
  , Data.ByteString.Lazy.elemIndices
  , Data.ByteString.Lazy.findIndex
  , Data.ByteString.Lazy.findIndices
  , Data.ByteString.Lazy.count

  -- * Zipping and unzipping ByteStrings
  , Data.ByteString.Lazy.zip
  , Data.ByteString.Lazy.zipWith
  , Data.ByteString.Lazy.unzip

  -- * Low level conversions
  -- ** Copying ByteStrings
  , Data.ByteString.Lazy.copy

  -- * I\/O with 'ByteString's
  -- ** Standard input and output
  , getContents
  , putStr
  , putStrLn
  , interact

  -- ** Files
  , readFile
  , writeFile
  , appendFile

  -- ** I\/O with Handles
  , hGetContents
  , hGet
  , hGetNonBlocking
  , hPut
  , hPutNonBlocking
  , hPutStr
  ) where

import Data.ByteString.Lazy hiding
  (
    getContents
  , putStr
  , putStrLn
  , interact
  , readFile
  , writeFile
  , appendFile
  , hGetContents
  , hGet
  , hGetNonBlocking
  , hPut
  , hPutNonBlocking
  , hPutStr
  )
import qualified Data.ByteString.Lazy
import qualified Data.ByteString.Lazy.Char8
import RIO

-- | Lifted 'Data.ByteString.Lazy.getContents'
getContents :: MonadIO m => m LByteString
getContents :: m LByteString
getContents = IO LByteString -> m LByteString
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO IO LByteString
Data.ByteString.Lazy.getContents

-- | Lifted 'Data.ByteString.Lazy.putStr'
putStr :: MonadIO m => LByteString -> m ()
putStr :: LByteString -> m ()
putStr = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> (LByteString -> IO ()) -> LByteString -> m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. LByteString -> IO ()
Data.ByteString.Lazy.putStr

-- | Lifted 'Data.ByteString.Lazy.putStrLn'
putStrLn :: MonadIO m => LByteString -> m ()
putStrLn :: LByteString -> m ()
putStrLn = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> (LByteString -> IO ()) -> LByteString -> m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. LByteString -> IO ()
Data.ByteString.Lazy.Char8.putStrLn

-- | Lifted 'Data.ByteString.Lazy.interact'
interact :: MonadIO m => (LByteString -> LByteString) -> m ()
interact :: (LByteString -> LByteString) -> m ()
interact = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ())
-> ((LByteString -> LByteString) -> IO ())
-> (LByteString -> LByteString)
-> m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (LByteString -> LByteString) -> IO ()
Data.ByteString.Lazy.interact

-- | Lifted 'Data.ByteString.Lazy.readFile'
readFile :: MonadIO m => FilePath -> m LByteString
readFile :: FilePath -> m LByteString
readFile = IO LByteString -> m LByteString
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO LByteString -> m LByteString)
-> (FilePath -> IO LByteString) -> FilePath -> m LByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. FilePath -> IO LByteString
Data.ByteString.Lazy.readFile

-- | Lifted 'Data.ByteString.Lazy.writeFile'
writeFile :: MonadIO m => FilePath -> LByteString -> m ()
writeFile :: FilePath -> LByteString -> m ()
writeFile FilePath
fp LByteString
contents =
  IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ FilePath -> LByteString -> IO ()
Data.ByteString.Lazy.writeFile FilePath
fp LByteString
contents

-- | Lifted 'Data.ByteString.Lazy.appendFile'
appendFile :: MonadIO m => FilePath -> LByteString -> m ()
appendFile :: FilePath -> LByteString -> m ()
appendFile FilePath
fp = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> (LByteString -> IO ()) -> LByteString -> m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. FilePath -> LByteString -> IO ()
Data.ByteString.Lazy.appendFile FilePath
fp

-- | Lifted 'Data.ByteString.Lazy.hGet'
hGet :: MonadIO m => Handle -> Int -> m LByteString
hGet :: Handle -> Int -> m LByteString
hGet Handle
handle' Int
count' = IO LByteString -> m LByteString
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO LByteString -> m LByteString)
-> IO LByteString -> m LByteString
forall a b. (a -> b) -> a -> b
$ Handle -> Int -> IO LByteString
Data.ByteString.Lazy.hGet Handle
handle' Int
count'

-- | Lifted 'Data.ByteString.Lazy.hGetContents'
hGetContents :: MonadIO m => Handle -> m LByteString
hGetContents :: Handle -> m LByteString
hGetContents = IO LByteString -> m LByteString
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO LByteString -> m LByteString)
-> (Handle -> IO LByteString) -> Handle -> m LByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Handle -> IO LByteString
Data.ByteString.Lazy.hGetContents

-- | Lifted 'Data.ByteString.Lazy.hGetNonBlocking'
hGetNonBlocking :: MonadIO m => Handle -> Int -> m LByteString
hGetNonBlocking :: Handle -> Int -> m LByteString
hGetNonBlocking Handle
h = IO LByteString -> m LByteString
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO LByteString -> m LByteString)
-> (Int -> IO LByteString) -> Int -> m LByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Handle -> Int -> IO LByteString
Data.ByteString.Lazy.hGetNonBlocking Handle
h

-- | Lifted 'Data.ByteString.Lazy.hPut'
hPut :: MonadIO m => Handle -> LByteString -> m ()
hPut :: Handle -> LByteString -> m ()
hPut Handle
h = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> (LByteString -> IO ()) -> LByteString -> m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Handle -> LByteString -> IO ()
Data.ByteString.Lazy.hPut Handle
h

-- | Lifted 'Data.ByteString.Lazy.hPutNonBlocking'
hPutNonBlocking :: MonadIO m => Handle -> LByteString -> m LByteString
hPutNonBlocking :: Handle -> LByteString -> m LByteString
hPutNonBlocking Handle
h = IO LByteString -> m LByteString
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO LByteString -> m LByteString)
-> (LByteString -> IO LByteString) -> LByteString -> m LByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Handle -> LByteString -> IO LByteString
Data.ByteString.Lazy.hPutNonBlocking Handle
h

-- | Lifted 'Data.ByteString.Lazy.hPutStr'
hPutStr :: MonadIO m => Handle -> LByteString -> m ()
hPutStr :: Handle -> LByteString -> m ()
hPutStr Handle
h = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> (LByteString -> IO ()) -> LByteString -> m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Handle -> LByteString -> IO ()
Data.ByteString.Lazy.hPutStr Handle
h