Additional functionality needed to describe parsers independent of input type.
Methods
try :: m a -> m aTake a parser that may consume input, and on failure, go back to where we started and fail as if we didn't consume input.
(<?>) :: m a -> String -> m ainfixr 0Give a parser a name
skipMany :: m a -> m ()A version of many that discards its input. Specialized because it can often be implemented more cheaply.
skipSome :: m a -> m ()skipSome papplies the parserpone or more times, skipping its result. (aka skipMany1 in parsec)unexpected :: String -> m aUsed to emit an error on an unexpected token
eof :: m ()This parser only succeeds at the end of the input. This is not a primitive parser but it is defined using notFollowedBy.
eof = notFollowedBy anyChar <?> "end of input"notFollowedBy :: Show a => m a -> m ()notFollowedBy ponly succeeds when parserpfails. This parser does not consume any input. This parser can be used to implement the 'longest match' rule. For example, when recognizing keywords (for examplelet), we want to make sure that a keyword is not followed by a legal identifier character, in which case the keyword is actually an identifier (for examplelets). We can program this behaviour as follows:keywordLet = try $ string "let" <* notFollowedBy alphaNum
Instances16Parsing, …
Parsing GetDefined in parsers-0.12.12 · Text.Parser.CombinatorsParsing ReadPDefined in parsers-0.12.12 · Text.Parser.CombinatorsChunk t => Parsing (Parser t)Defined in parsers-0.12.12 · Text.Parser.CombinatorsParsing m => Parsing (Unhighlighted m)Defined in parsers-0.12.12 · Text.Parser.TokenParsing m => Parsing (Unlined m)Defined in parsers-0.12.12 · Text.Parser.TokenParsing m => Parsing (Unspaced m)Defined in parsers-0.12.12 · Text.Parser.Token(Parsing m, Monad m) => Parsing (IdentityT m)Defined in parsers-0.12.12 · Text.Parser.Combinators(Parsing m, MonadPlus m) => Parsing (ReaderT e m)Defined in parsers-0.12.12 · Text.Parser.Combinators(Parsing m, MonadPlus m) => Parsing (StateT s m)Defined in parsers-0.12.12 · Text.Parser.Combinators(Parsing m, MonadPlus m) => Parsing (StateT s m)Defined in parsers-0.12.12 · Text.Parser.Combinators(Parsing m, MonadPlus m, Monoid w) => Parsing (WriterT w m)Defined in parsers-0.12.12 · Text.Parser.Combinators(Parsing m, MonadPlus m, Monoid w) => Parsing (WriterT w m)Defined in parsers-0.12.12 · Text.Parser.Combinators(Ord e, Stream s) => Parsing (ParsecT e s m)Defined in parsers-megaparsec-0.1.0.2 · Text.Megaparsec.ParsersNote: unexpected requires a non-empty string
(Stream s m t, Show t) => Parsing (ParsecT s u m)Defined in parsers-0.12.12 · Text.Parser.Combinators(Parsing m, MonadPlus m, Monoid w) => Parsing (RWST r w s m)Defined in parsers-0.12.12 · Text.Parser.Combinators(Parsing m, MonadPlus m, Monoid w) => Parsing (RWST r w s m)Defined in parsers-0.12.12 · Text.Parser.Combinators