This module defines our parsing monad. In the past there have been lazy and strict parsers in this module. Currently we have only the strict variant and it is used for parsing patch files.
- class (Functor m, Applicative m, Alternative m, Monad m, MonadPlus m) => ParserM m where
- take :: ParserM m => Int -> m ByteString
- parseStrictly :: SM a -> ByteString -> Maybe (a, ByteString)
- char :: ParserM m => Char -> m ()
- int :: ParserM m => m Int
- option :: Alternative f => a -> f a -> f a
- choice :: Alternative f => [f a] -> f a
- skipSpace :: ParserM m => m ()
- skipWhile :: ParserM m => (Char -> Bool) -> m ()
- string :: ParserM m => ByteString -> m ()
- lexChar :: ParserM m => Char -> m ()
- lexString :: ParserM m => ByteString -> m ()
- lexEof :: ParserM m => m ()
- takeTillChar :: ParserM m => Char -> m ByteString
- myLex' :: ParserM m => m ByteString
- anyChar :: ParserM m => m Char
- endOfInput :: ParserM m => m ()
- takeTill :: ParserM m => (Char -> Bool) -> m ByteString
- checkConsumes :: ParserM m => m a -> m a
- linesStartingWith :: ParserM m => Char -> m [ByteString]
- linesStartingWithEndingWith :: ParserM m => Char -> Char -> m [ByteString]
Accepts only the specified character. Consumes a character, if available.
Parse an integer and return it. Skips leading whitespaces and | uses the efficient ByteString readInt.
p fails it returns
x, otherwise it returns the result of
Discards spaces until a non-space character is encountered. Always succeeds.
Discards any characters as long as
p returns True. Always
Only succeeds if the characters in the input exactly match
takeTill (==c), except that it is optimized for
| the equality case.
Accepts the next character and returns it. Only fails at end of input.
Takes characters while
p returns True. Always succeeds.
Ensure that a parser consumes input when producing a result Causes the initial state of the input stream to be held on to while the parser runs, so use with caution.
This is a highly optimized way to read lines that start with a
particular character. To implement this efficiently we need access
to the parser's internal state. If this is implemented in terms of
the other primitives for the parser it requires us to consume one
character at a time. That leads to
(>>=) wasting significant