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