-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | A simple unassuming parser for bytestring
--
@package bsparse
@version 0.0.2
-- | A very simple bytestring parser related to Parsec and Attoparsec
--
-- Simple example:
--
--
-- > parse ((,) <$> take 2 <*> byte 0x20 <*> (bytes "abc" *> anyByte)) "xx abctest"
-- ParseOK "est" ("xx", 116)
--
module Data.ByteString.Parse
-- | Simple ByteString parser structure
data Parser a
-- | Simple parsing result, that represent respectively:
--
--
-- - failure: with the error message
-- - continuation: that need for more input data
-- - success: the remaining unparsed data and the parser value
--
data Result a
ParseFail :: String -> Result a
ParseMore :: (ByteString -> Result a) -> Result a
ParseOK :: ByteString -> a -> Result a
-- | Run a Parser on a ByteString and return a Result
parse :: Parser a -> ByteString -> Result a
-- | Run a parser on an @initial ByteString.
--
-- If the Parser need more data than available, the @feeder function is
-- automatically called and fed to the More continuation.
parseFeed :: Monad m => m ByteString -> Parser a -> ByteString -> m (Result a)
-- | Parse a specific byte at current position
--
-- if the byte is different than the expected on, this parser will raise
-- a failure.
byte :: Word8 -> Parser ()
-- | Get the next byte from the parser
anyByte :: Parser Word8
-- | Parse a sequence of bytes from current position
--
-- if the following bytes don't match the expected bytestring completely,
-- the parser will raise a failure
bytes :: ByteString -> Parser ()
-- | Take @n bytes from the current position in the stream
take :: Int -> Parser ByteString
-- | Take bytes while the @predicate hold from the current position in the
-- stream
takeWhile :: (Word8 -> Bool) -> Parser ByteString
-- | Skip @n bytes from the current position in the stream
skip :: Int -> Parser ()
-- | Skip bytes while the @predicate hold from the current position in the
-- stream
skipWhile :: (Word8 -> Bool) -> Parser ()
instance Alternative Parser
instance Applicative Parser
instance Functor Parser
instance MonadPlus Parser
instance Monad Parser
instance Show a => Show (Result a)