!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ :The parser type is parametrised on the types of the state s,  the input tokens t , error-type e, and the result value a. A The state and remaining input are threaded through the monad. #Deliver the first remaining token. $Fail if end of input is not reached CDeliver the first parse result only, eliminating any backtracking. CApply the parser to some real input, given an initial state value.  If the parser fails, raise  to halt the program. E (This is the original exported behaviour - to allow the caller to ( deal with the error differently, see papply'.) CApply the parser to some real input, given an initial state value. C If the parser fails, return a diagnostic message to the caller. 8A choice between parsers. Keep only the first success. 5Deliver the first token if it satisfies a predicate. 3Deliver the first token if it equals the argument. ;Deliver the first token if it does not equal the argument. Deliver zero or more values of a. Deliver one or more values of a. Deliver zero or more values of a separated by b's. Deliver one or more values of a separated by b's. >Accept a complete parse of the input only, no partial parses. GReturn an error using the supplied diagnostic string, and a token type ( which includes position information. 0If the parser fails, generate an error message. Update the internal state. Query the internal state. #Deliver the entire internal state. ;This is useful for recursively expanding macros. When the ? user-parser recognises a macro use, it can lookup the macro > expansion from the parse state, lex it, and then stuff the . lexed expansion back down into the parser.    All A LIBRARY OF MONADIC PARSER COMBINATORS 29th July 1996 Graham Hutton Erik Meijer University of Nottingham University of UtrechtStable/Malcolm Wallace <Malcolm.Wallace@cs.york.ac.uk>%The parser monad  !"#$%&'()*+,-./0123456789:;<$ !"#$%&'()*+,-./0123456789:;<$ !"#$%&'()*+,-./0123456789:;<$ !"#$%&'()*+,-./0123456789:;<=The  PolyParse. class is an abstraction over all the current B concrete representations of monadic parser combinators in this = package. The common feature is two-level error-handling. D Some primitives must be implemented specific to each parser type A (e.g. depending on whether the parser has a running state, or F whether it is lazy). But given those primitives, large numbers of F combinators do not depend any further on the internal structure of  the particular parser. LThere are two additional basic combinators that we expect to be implemented E afresh for every concrete type, but which (for technical reasons) & cannot be class methods. They are next and satisfy. >CCommit is a way of raising the severity of any errors found within K its argument. Used in the middle of a parser definition, it means that I any operations prior to commitment fail softly, but after commitment,  they fail hard. ?p ? f applies the transformation f to any error message  generated in p, having no effect if p succeeds. @p @ q. means parse p, unless p fails, in which case  parse q instead. I Can be chained together to give multiple attempts to parse something. K (Note that q could itself be a failing parser, e.g. to change the error ; message from that defined in p to something different.) 5 However, a severe failure in p cannot be ignored. A@Parse the first alternative that succeeds, but if none succeed, D report only the severe errors, and if none of those, then report  all the soft errors. B+Apply a parsed function to a parsed value. B Rather like ordinary function application lifted into parsers. CCWhen a simple fail is not strong enough, use failBad for emphasis. ? An emphasised (severe) error cannot be overridden by choice  operators. Dx D y4 parses both x and y, but discards the result of y.  Rather like const lifted into parsers. E adjustErrBad is just like  adjustErr except it also raises the  severity of the error. F7Parse the first alternative in the list that succeeds. GKHelper for formatting error messages: indents all lines by a fixed amount. HH@ indicates whether the parser succeeded through the Maybe type. I' exactly n p'< parses precisely n items, using the parser p, in sequence. J'many p'5 parses a list of elements with individual parser p. = Cannot fail, since an empty list is a valid return value. K!Parse a non-empty list of items. L3Parse a list of items separated by discarded junk. M=Parse a non-empty list of items separated by discarded junk. N@Parse a list of items, discarding the start, end, and separator  items. O1Parse a bracketed item, discarding the brackets. P'manyFinally e t'& parses a possibly-empty sequence of e's, E terminated by a t. The final t is discarded. Any parse failures F could be due either to a badly-formed terminator or a badly-formed / element, so it raises both possible errors. =>?@ABCDEFGHIJKLMNOP=>?@ABDCEGFHIJKLMNOP=>?@AB>?@ABCDEFGHIJKLMNOP Q?A return type like Either, that distinguishes not only between G right and wrong answers, but also has commitment, so that a failure J cannot be undone. This should only be used for writing very primitive = parsers - really it is an internal detail of the library. RSTUThis Parser7 datatype is a fairly generic parsing monad with error B reporting. It can be used for arbitrary token types, not just H String input. (If you require a running state, use module PolyState  instead) VW+Apply a parser to an input token sequence. XYZ[FPush some tokens back onto the front of the input stream and reparse. C This is useful e.g. for recursively expanding macros. When the ? user-parser recognises a macro use, it can lookup the macro > expansion from the parse state, lex it, and then stuff the . lexed expansion back down into the parser. =>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[ UVQTSRWXYZ[ QTSRRSTUVVWXYZ[ \?A return type like Either, that distinguishes not only between B right and wrong answers, but also has gradations of wrongness. 7 This should only be used for writing very primitive = parsers - really it is an internal detail of the library. ]^_`This Parser7 datatype is a fairly generic parsing monad with error B reporting. It can be used for arbitrary token types, not just H String input. (If you require a running state, use module PolyState  instead) ab+Apply a parser to an input token sequence. cdefFPush some tokens back onto the front of the input stream and reparse. C This is useful e.g. for recursively expanding macros. When the ? user-parser recognises a macro use, it can lookup the macro > expansion from the parse state, lex it, and then stuff the . lexed expansion back down into the parser. =>?@ABCDEFGHIJKLMNOP\]^_`abcdef `a\_^]bcdef \_^]]^_`aabcdefg?A return type like Either, that distinguishes not only between B right and wrong answers, but also has gradations of wrongness. 7 This should only be used for writing very primitive = parsers - really it is an internal detail of the library. hijkThis Parser7 datatype is a fairly generic parsing monad with error B reporting. It can be used for arbitrary token types, not just H String input. (If you require a running state, use module PolyState  instead) lm+Apply a parser to an input token sequence. nopqUpdate the internal state. rQuery the internal state. s#Deliver the entire internal state. tFPush some tokens back onto the front of the input stream and reparse. C This is useful e.g. for recursively expanding macros. When the ? user-parser recognises a macro use, it can lookup the macro > expansion from the parse state, lex it, and then stuff the . lexed expansion back down into the parser. "=>?@ABCDEFGHIJKLMNOPghijklmnopqrstklgjihmnopqrstgjihhijkllmnopqrstu?A return type like Either, that distinguishes not only between B right and wrong answers, but also has gradations of wrongness. 7 This should only be used for writing very primitive = parsers - really it is an internal detail of the library. vwxyThis Parser7 datatype is a fairly generic parsing monad with error B reporting. It can be used for arbitrary token types, not just H String input. (If you require a running state, use module PolyState  instead) z{+Apply a parser to an input token sequence. |}~Update the internal state. Query the internal state. #Deliver the entire internal state. FPush some tokens back onto the front of the input stream and reparse. C This is useful e.g. for recursively expanding macros. When the ? user-parser recognises a macro use, it can lookup the macro > expansion from the parse state, lex it, and then stuff the . lexed expansion back down into the parser. "=>?@ABCDEFGHIJKLMNOuvwxyz{|}~yzuxwv{}~|uxwvvwxyzz{|}~ ?A return type like Either, that distinguishes not only between G right and wrong answers, but also has commitment, so that a failure J cannot be undone. This should only be used for writing very primitive = parsers - really it is an internal detail of the library. This Parser4 datatype is a specialised parsing monad with error F reporting. Whereas the standard version can be used for arbitrary F token types, this version is specialised to ByteString input only. +Apply a parser to an input token sequence. FPush some tokens back onto the front of the input stream and reparse. C This is useful e.g. for recursively expanding macros. When the ? user-parser recognises a macro use, it can lookup the macro > expansion from the parse state, lex it, and then stuff the . lexed expansion back down into the parser. =>?@ABCDEFGHIJKLMNOP   The class Parse is a replacement for Read, operating over String input. M Essentially, it permits better error messages for why something failed to ' parse. It is rather important that parse can read back exactly what 1 is generated by the corresponding instance of show. To apply a parser  to some text, use  runParser. @A straightforward parser for an item. (A minimal definition of = a class instance requires either |parse| or |parsePrec|.) >A straightforward parser for an item, given the precedence of ? any surrounding expression. (Precedence determines whether + parentheses are mandatory or optional.) 0Parsing a list of items by default accepts the [] and comma syntax, ; except when the list is really a character string using "". DA synonym for a ByteString Parser, i.e. bytestring input (no state) EIf there already exists a Read instance for a type, then we can make M a Parser for it, but with only poor error-reporting. The string argument J is the expected type or value (for error-reporting only). Use of this F wrapper function is NOT recommended with ByteString, because there 6 is a lot of inefficiency in repeated conversions to/ from String. AIf you have a TextParser for a type, you can easily make it into F a Read instance, by throwing away any error messages. Use of this F wrapper function is NOT recommended with ByteString, because there - is a lot of inefficiency in conversions to/ from String. AIf you have a TextParser for a type, you can easily make it into F a Read instance, by throwing away any error messages. Use of this F wrapper function is NOT recommended with ByteString, because there - is a lot of inefficiency in conversions to/ from String. *One lexical chunk (Haskell-style lexing). FEnsure that the next input word is the given string. (Note the input @ is lexed as haskell, so wordbreaks at spaces, symbols, etc.) 4Allow optional nested string parens around an item. IAllow nested parens around an item (one set required when Bool is True). FDeal with named field syntax. The string argument is the field name, 2 and the parser returns the value of the field. IParse one of a bunch of alternative constructors. In the list argument, > the first element of the pair is the constructor name, and K the second is the parser for the rest of the value. The first matching  parse is returned. >Parse one of the given nullary constructors (an enumeration). F The string argument is the name of the type, and the list argument : should contain all of the possible enumeration values. DparseUnsignedInteger uses the underlying ByteString readInteger, so J will be a lot faster than the generic character-by-character parseInt. .Simply return the remaining input ByteString. /Simply return the remaining input as a String. 8=>?@ABCDEFGHIJKLMNOP =>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[  The class Parse is a replacement for Read, operating over String input. M Essentially, it permits better error messages for why something failed to ' parse. It is rather important that parse can read back exactly what 1 is generated by the corresponding instance of show. To apply a parser  to some text, use  runParser. @A straightforward parser for an item. (A minimal definition of = a class instance requires either |parse| or |parsePrec|.) >A straightforward parser for an item, given the precedence of ? any surrounding expression. (Precedence determines whether + parentheses are mandatory or optional.) 0Parsing a list of items by default accepts the [] and comma syntax, ; except when the list is really a character string using "". 8A synonym for Parser Char, i.e. string input (no state) EIf there already exists a Read instance for a type, then we can make M a Parser for it, but with only poor error-reporting. The string argument = is the expected type or value (for error-reporting only). AIf you have a TextParser for a type, you can easily make it into 9 a Read instance, by throwing away any error messages. AIf you have a TextParser for a type, you can easily make it into 9 a Read instance, by throwing away any error messages. #One lexical chunk. This is Haskell'98-style lexing - the result ? should match Prelude.lex apart from better error-reporting. One lexical chunk (Haskell'*98-style lexing - the result should match , Prelude.lex apart from error-reporting). FEnsure that the next input word is the given string. (Note the input @ is lexed as haskell, so wordbreaks at spaces, symbols, etc.) $Allow nested parens around an item. IAllow nested parens around an item (one set required when Bool is True). FDeal with named field syntax. The string argument is the field name, 2 and the parser returns the value of the field. IParse one of a bunch of alternative constructors. In the list argument, > the first element of the pair is the constructor name, and K the second is the parser for the rest of the value. The first matching  parse is returned. >Parse one of the given nullary constructors (an enumeration). F The string argument is the name of the type, and the list argument : should contain all of the possible enumeration values. 5=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[   !"#$  %&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMN  OPQ$KLMN  OPQ$KLMN  OPQRST$KLMN  OJPQRST$KLMN  OPQ$ U V W X Y Z [ \ ] ^ _ ` a b c d e f g h i j k l m U V W X Y Z [ \ ] ^ _ ` a b c d e f g h j kno%pqr&stuu vwpolyparse-1.4.1*Text.ParserCombinators.HuttonMeijerWallace#Text.ParserCombinators.HuttonMeijer Text.ParserCombinators.Poly.Base!Text.ParserCombinators.Poly.Plain Text.ParserCombinators.Poly.Lazy!Text.ParserCombinators.Poly.State%Text.ParserCombinators.Poly.StateLazy&Text.ParserCombinators.Poly.ByteStringText.Parse.ByteString Text.ParseText.ParserCombinators.PolyParserPitemeofpapplypapply'+++toknottokmanymany1sepbysepby1chainlchainl1chainrchainr1opsbrackettoEOFelserrorstupdstquerystgetreparsefirstsatchardigitlowerupperletteralphanumstringidentnatintspacescommentjunkskiptokennaturalintegersymbol identifier PolyParsecommit adjustErronFailoneOf'applyfailBaddiscard adjustErrBadoneOfindentoptionalexactlysepBysepBy1 bracketSep manyFinallyResult CommittedFailureSuccess runParsernextsatisfystUpdatestQuerystGetParseparse parsePrec parseList TextParser parseByRead readByParsereadsPrecByParsePrecwordisWordoptionalParensparensfield constructors enumeration parseSignedparseIntparseDecparseOctparseHexparseUnsignedInteger parseFloat parseLitCharallAsByteString allAsString ParseResult joinresultsbaseGHC.Errerror parseerrorTokenthrowEoldword