moduleParseLib.Abstract.Core(-- * The type of parsersParser(),-- * Elementary parsersanySymbol,satisfy,empty,failp,succeed,pure,-- * Parser combinators(<|>),(<<|>),(<*>),(<$>),(>>=),-- * Lookaheadlook,-- * Running parsersparse)whereimportData.CharimportData.TraversableimportData.MaybeimportControl.MonadimportControl.ApplicativeimportqualifiedParseLib.Simple.CoreasSP-- | An input string is mapped to a list of successful parses.-- For each succesful parse, we return the result of type 'r',-- and the remaining input string. The input must be a list of-- symbols.newtypeParsersr=Parser{runParser::[s]->[(r,[s])]}instanceFunctor(Parsers)wherefmapfp=Parser(fSP.<$>runParserp)instanceApplicative(Parsers)wherepurex=Parser(SP.succeedx)p<*>q=Parser(runParserpSP.<*>runParserq)instanceAlternative(Parsers)whereempty=ParserSP.emptyp<|>q=Parser(runParserpSP.<|>runParserq)infixr3<<|>-- | Biased choice. If the left hand side parser succeeds,-- the right hand side is not considered. Use with care!(<<|>)::Parsersa->Parsersa->Parsersap<<|>q=Parser(runParserpSP.<<|>runParserq)instanceMonad(Parsers)wherereturn=purep>>=f=Parser(runParserpSP.>>=(runParser.f))instanceMonadPlus(Parsers)wheremzero=emptymplus=(<|>)-- | Parses any single symbol.anySymbol::ParserssanySymbol=Parser(SP.anySymbol)-- | Takes a predicate and returns a parser that parses a-- single symbol satisfying that predicate.satisfy::(s->Bool)->Parsersssatisfyp=Parser(SP.satisfyp)-- | Parser that always succeeds, i.e., for epsilon.succeed::a->Parsersasucceed=pure-- | Same as 'empty'; provided for compatibility with the lecture notes.failp::Parsersafailp=empty-- | Returns the rest of the input without consuming anything.look::Parsers[s]look=Parser(\xs->[(xs,xs)])-- | Runs a parser on a given string.parse::Parsersa->[s]->[(a,[s])]parse=runParser