module Data.ByteString.Lazy.Char8.Util ( previous , subBS ) where import Data.ByteString.Lazy.Char8 (ByteString) import qualified Data.ByteString.Lazy.Char8 as BS (drop, index, take) import Data.Int (Int64) import Prelude hiding (length) previous :: Char -> Int64 -> ByteString -> Int64 previous char position byteString | BS.index byteString position == char = position | otherwise = previous char (position - 1) byteString subBS :: Int64 -> Int64 -> ByteString -> ByteString subBS offset length = BS.take length . BS.drop offset