rc      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKL M N O P Q R S T U V W X Y Z [ \ ] ^ _ ` a b c d e f g h i j k l m n o p q r s t u v w x y z { | } ~   Safe-Inferred=A return type like Either, that distinguishes not only between right and wrong answers, but also has commitment, so that a failure cannot be undone. This should only be used for writing very primitive parsers - really it is an internal detail of the library. The z type is the remaining unconsumed input.JConvert a Result to an Either, paired with the remaining unconsumed input. Safe-InferredThe  PolyParse class is an abstraction gathering all of the common features that a two-level error-handling parser requires: the applicative parsing interface, the monadic interface, and commitment.There are two additional basic combinators that we expect to be implemented afresh for every concrete type, but which (for technical reasons) cannot be class methods. They are next and satisfy.The  Commitment class is an abstraction over all the current concrete representations of monadic/applicative parser combinators in this package. The common feature is two-level error-handling. Some primitives must be implemented specific to each parser type (e.g. depending on whether the parser has a running state, or whether it is lazy). But given those primitives, large numbers of combinators do not depend any further on the internal structure of the particular parser.Commit is a way of raising the severity of any errors found within its argument. Used in the middle of a parser definition, it means that 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. Parse the first alternative that succeeds, but if none succeed, report only the severe errors, and if none of those, then report all the soft errors. lApply a parsed function to a parsed value. Rather like ordinary function application lifted into parsers. x   yC parses both x and y, but discards the result of y. Rather like const lifted into parsers. When a simple fail is not strong enough, use failBad for emphasis. An emphasised (severe) error cannot be overridden by choice operators.  adjustErrBad is just like  adjustErr4 except it also raises the severity of the error.6Parse the first alternative in the list that succeeds.JHelper for formatting error messages: indents all lines by a fixed amount.H'exactly n p' parses precisely n items, using the parser p, in sequence.D'upto n p' parses n or fewer items, using the parser p, in sequence. Parse a non-empty list of items.2Parse a list of items separated by discarded junk.<Parse a non-empty list of items separated by discarded junk.IParse a list of items, discarding the start, end, and separator items.JParse a bracketed item, discarding the brackets. If everything matches except the closing bracket, the whole parse fails soft, which can give less-than-satisfying error messages. If you want better error messages, try calling with e.g.  bracket open (commit close) itemmanyFinally e t% parses a possibly-empty sequence of e's, terminated by a t . The final t is discarded. Any parse failures could be due either to a badly-formed terminator or a badly-formed element, so it raises both possible errors. manyFinally' is like  manyFinallyM, except when the terminator parser overlaps with the element parser. In manyFinally e t, the parser t is tried only when parser e fails, whereas in manyFinally' e t , the parser t' is always tried first, then parser e8 only if the terminator is not found. For instance, &manyFinally (accept "01") (accept "0") on input  "0101010" returns ["01","01","01"] , whereas  manyFinally'. with the same arguments and input returns [].        Safe-InferredThis Parser datatype is a fairly generic parsing monad with error reporting. It can be used for arbitrary token types, not just String input. (If you require a running state, use module Poly.State instead)p  qE means parse p, unless p fails, in which case parse q instead. Can be chained together to give multiple attempts to parse something. (Note that q could itself be a failing parser, e.g. to change the error message from that defined in p to something different.) However, a severe failure in p cannot be ignored.6Simply return the next token in the input tokenstream.BSucceed if the end of file/input has been reached, fail otherwise.:Return the next token if it satisfies the given predicate.Return the next token if it satisfies the given predicate. The String argument describes the function, for better error messages. 3Push some tokens back onto the front of the input stream and reparse. 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.    NoneB!The only differences between a Plain and a Lazy parser are the instance of Applicative, and the type (and implementation) of runParser. We therefore need to newtypeG the original Parser type, to allow it to have a different instance.#*Apply a parser to an input token sequence.$6Simply return the next token in the input tokenstream.%BSucceed if the end of file/input has been reached, fail otherwise.&:Return the next token if it satisfies the given predicate.'Return the next token if it satisfies the given predicate. The String argument describes the predicate for better error messages.(p ( qE means parse p, unless p fails, in which case parse q instead. Can be chained together to give multiple attempts to parse something. (Note that q could itself be a failing parser, e.g. to change the error message from that defined in p to something different.) However, a severe failure in p cannot be ignored.)3Push some tokens back onto the front of the input stream and reparse. 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. !"#$%&'()>      !"#$%&'() !"#$%&'() !"#$%&'() Safe-Inferred *This Parser datatype is a fairly generic parsing monad with error reporting, and running state. It can be used for arbitrary token types, not just String input. (If you do not require a running state, use module Poly.Plain instead),p , qE means parse p, unless p fails, in which case parse q instead. Can be chained together to give multiple attempts to parse something. (Note that q could itself be a failing parser, e.g. to change the error message from that defined in p to something different.) However, a severe failure in p cannot be ignored.-6Simply return the next token in the input tokenstream..BSucceed if the end of file/input has been reached, fail otherwise./:Return the next token if it satisfies the given predicate.0Update the internal state.1Query the internal state.2"Deliver the entire internal state.33Push some tokens back onto the front of the input stream and reparse. 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.*+,-./0123*+,-./0123*+-./,0123*+,-./0123, Safe-Inferred4*Apply a parser to an input token sequence.4@      *+,-./01234*+4-./,01234NoneB 5The only differences between a State and a StateLazy parser are the instance of Applicative, and the type (and implementation) of runParser. We therefore need to newtypeG the original Parser type, to allow it to have a different instance.7*Apply a parser to an input token sequence.86Simply return the next token in the input tokenstream.9BSucceed if the end of file/input has been reached, fail otherwise.::Return the next token if it satisfies the given predicate.;p ; qE means parse p, unless p fails, in which case parse q instead. Can be chained together to give multiple attempts to parse something. (Note that q could itself be a failing parser, e.g. to change the error message from that defined in p to something different.) However, a severe failure in p cannot be ignored.<3Push some tokens back onto the front of the input stream and reparse. 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.=Update the internal state.>Query the internal state.?"Deliver the entire internal state.56789:;<=>?@@      56789:;<=>?@56789:;@=>?<56789:;<=>?@ Safe-InferredAThis Parser datatype is a specialised parsing monad with error reporting. This version is specialised to pre-lexed String input, where the lexer has been written to yield a  LexReturn.CIn a strict language, where creating the entire input list of tokens in one shot may be infeasible, we can use a lazy "callback" kind of architecture instead. The lexer returns a single token at a time, together with a continuation. The nextf parser is responsible for pulling on the token stream, applying the continuation where necessary.F*Apply a parser to an input token sequence.Gp G qE means parse p, unless p fails, in which case parse q instead. Can be chained together to give multiple attempts to parse something. (Note that q could itself be a failing parser, e.g. to change the error message from that defined in p to something different.) However, a severe failure in p cannot be ignored.H6Simply return the next token in the input tokenstream.IBSucceed if the end of file/input has been reached, fail otherwise.J:Return the next token if it satisfies the given predicate.K3Push some tokens back onto the front of the input stream and reparse. 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.ABCDEFGHIJK@      ABCDEFGHIJKCEDABFHIJGKABCEDFGHIJKG  Safe-Inferred LThis Parser datatype is a specialised parsing monad with error reporting. Whereas the standard version can be used for arbitrary token types, this version is specialised to ByteString input only.N*Apply a parser to an input token sequence.O6Simply return the next token in the input tokenstream.PBSucceed if the end of file/input has been reached, fail otherwise.Q:Return the next token if it satisfies the given predicate.Rp R qE means parse p, unless p fails, in which case parse q instead. Can be chained together to give multiple attempts to parse something. (Note that q could itself be a failing parser, e.g. to change the error message from that defined in p to something different.) However, a severe failure in p cannot be ignored.S manySatisfy p& is a more efficient fused version of many (satisfy p)Tmany1Satisfy p& is a more efficient fused version of many1 (satisfy p)U3Push some tokens back onto the front of the input stream and reparse. 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.LMNOPQRSTU !"#$" LMNOPQRSTULMNOPQRSTULMNOPQRSTU !"#$  Safe-Inferred VThis Parser datatype is a specialised parsing monad with error reporting. Whereas the standard version can be used for arbitrary token types, this version is specialised to ByteString input only.X*Apply a parser to an input token sequence.Y6Simply return the next token in the input tokenstream.ZBSucceed if the end of file/input has been reached, fail otherwise.[:Return the next token if it satisfies the given predicate.\p \ qE means parse p, unless p fails, in which case parse q instead. Can be chained together to give multiple attempts to parse something. (Note that q could itself be a failing parser, e.g. to change the error message from that defined in p to something different.) However, a severe failure in p cannot be ignored.] manySatisfy p& is a more efficient fused version of many (satisfy p)^many1Satisfy p& is a more efficient fused version of many1 (satisfy p)_3Push some tokens back onto the front of the input stream and reparse. 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.VWXYZ[\]^_%&'()*" VWXYZ[\]^_VWXYZ[\]^_VWXYZ[\]^_%&'()*  Safe-Inferred` The class Parse is a replacement for Read, operating over String input. Essentially, it permits better error messages for why something failed to parse. It is rather important that parseM can read back exactly what is generated by the corresponding instance of show*. To apply a parser to some text, use  runParser.aA straightforward parser for an item. (A minimal definition of a class instance requires either |parse| or |parsePrec|. In general, for a type that never needs parens, you should define |parse|, but for a type that _may_ need parens, you should define |parsePrec|.)bA straightforward parser for an item, given the precedence of any surrounding expression. (Precedence determines whether parentheses are mandatory or optional.)cParsing a list of items by default accepts the [] and comma syntax, except when the list is really a character string using "".dCA synonym for a ByteString Parser, i.e. bytestring input (no state)eeIf there already exists a Read instance for a type, then we can make a Parser for it, but with only poor error-reporting. The string argument is the expected type or value (for error-reporting only). Use of this wrapper function is NOT recommended with ByteString, because there is a lot of inefficiency in repeated conversions to/from String.fIf you have a TextParser for a type, you can easily make it into a Read instance, by throwing away any error messages. Use of this wrapper function is NOT recommended with ByteString, because there is a lot of inefficiency in conversions to/from String.gIf you have a TextParser for a type, you can easily make it into a Read instance, by throwing away any error messages. Use of this wrapper function is NOT recommended with ByteString, because there is a lot of inefficiency in conversions to/from String.h)One lexical chunk (Haskell-style lexing).iEnsure that the next input word is the given string. (Note the input is lexed as haskell, so wordbreaks at spaces, symbols, etc.)jmEnsure that the next input word is the given string. (No lexing, so mixed spaces, symbols, are accepted.)k3Allow optional nested string parens around an item.lHAllow nested parens around an item (one set required when Bool is True).mwDeal with named field syntax. The string argument is the field name, and the parser returns the value of the field.nParse one of a bunch of alternative constructors. In the list argument, the first element of the pair is the constructor name, and the second is the parser for the rest of the value. The first matching parse is returned.oParse one of the given nullary constructors (an enumeration). The string argument is the name of the type, and the list argument should contain all of the possible enumeration values.p>For any numeric parser, permit a negation sign in front of it.qParse any (unsigned) Integral numeric literal. Needs a base, radix, isDigit predicate, and digitToInt converter, appropriate to the result type.rKParse a decimal, octal, or hexadecimal (unsigned) Integral numeric literal.sKParse a decimal, octal, or hexadecimal (unsigned) Integral numeric literal.tKParse a decimal, octal, or hexadecimal (unsigned) Integral numeric literal.uparseUnsignedInteger uses the underlying ByteString readInteger, so will be a lot faster than the generic character-by-character parseInt.vDParse any (unsigned) Floating numeric literal, e.g. Float or Double.w"Parse a Haskell character literal.x-Simply return the remaining input ByteString.y.Simply return the remaining input as a String.'`abcdefghijklmnopqrstuvwxy+,-./01234567< VWXYZ[\]^_`abcdefghijklmnopqrstuvwxyd`abcefghijklmnopqrstuvwxy$`abcdefghijklmnopqrstuvwxy+,-./01234567  Safe-Inferred zThis Parser datatype is a specialised parsing monad with error reporting. Whereas the standard version can be used for arbitrary token types, this version is specialised to Text input only.|*Apply a parser to an input token sequence.}6Simply return the next token in the input tokenstream.~BSucceed if the end of file/input has been reached, fail otherwise.:Return the next token if it satisfies the given predicate.p  qE means parse p, unless p fails, in which case parse q instead. Can be chained together to give multiple attempts to parse something. (Note that q could itself be a failing parser, e.g. to change the error message from that defined in p to something different.) However, a severe failure in p cannot be ignored. manySatisfy p& is a more efficient fused version of many (satisfy p)many1Satisfy p& is a more efficient fused version of many1 (satisfy p)3Push some tokens back onto the front of the input stream and reparse. 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.z{|}~89:;<=?      z{|}~z{|}~z{|}~89:;<=  Safe-Inferred This Parser datatype is a specialised parsing monad with error reporting. Whereas the standard version can be used for arbitrary token types, this version is specialised to Text input only.*Apply a parser to an input token sequence.6Simply return the next token in the input tokenstream.BSucceed if the end of file/input has been reached, fail otherwise.:Return the next token if it satisfies the given predicate.p  qE means parse p, unless p fails, in which case parse q instead. Can be chained together to give multiple attempts to parse something. (Note that q could itself be a failing parser, e.g. to change the error message from that defined in p to something different.) However, a severe failure in p cannot be ignored. manySatisfy p& is a more efficient fused version of many (satisfy p)many1Satisfy p& is a more efficient fused version of many1 (satisfy p)Update the internal state.Query the internal state."Deliver the entire internal state.3Push some tokens back onto the front of the input stream and reparse. 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.>?@ABCB      >?@ABC Safe-Inferred*Apply a parser to an input token sequence.>         Safe-Inferred>        Safe-Inferred The class Parse is a replacement for Read, operating over String input. Essentially, it permits better error messages for why something failed to parse. It is rather important that parseM can read back exactly what 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.)Parsing a list of items by default accepts the [] and comma syntax, except when the list is really a character string using "".7A synonym for Parser Char, i.e. string input (no state)If there already exists a Read instance for a type, then we can make a Parser for it, but with only poor error-reporting. The string argument is the expected type or value (for error-reporting only).yIf you have a TextParser for a type, you can easily make it into a Read instance, by throwing away any error messages.yIf you have a TextParser for a type, you can easily make it into 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.DpOne lexical chunk (Haskell'98-style lexing - the result should match Prelude.lex apart from error-reporting).Ensure that the next input word is the given string. (Note the input is lexed as haskell, so wordbreaks at spaces, symbols, etc.)mEnsure that the next input word is the given string. (No lexing, so mixed spaces, symbols, are accepted.)#Allow nested parens around an item.HAllow nested parens around an item (one set required when Bool is True).wDeal with named field syntax. The string argument is the field name, and the parser returns the value of the field.Parse one of a bunch of alternative constructors. In the list argument, the first element of the pair is the constructor name, and 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). The string argument is the name of the type, and the list argument should contain all of the possible enumeration values.0Simply return the entire remaining input String.&DEFGHIJKLMNOPQV       #DEFGHIJKLMNOPQ Safe-Inferred:The parser type is parametrised on the types of the state s, the input tokens t , error-type e, and the result value aB. The state and remaining input are threaded through the monad."Deliver the first remaining token.#Fail if end of input is not reachedRBDeliver the first parse result only, eliminating any backtracking.aApply the parser to some real input, given an initial state value. If the parser fails, raise S to halt the program. (This is the original exported behaviour - to allow the caller to deal with the error differently, see papply'.)Apply the parser to some real input, given an initial state value. If the parser fails, return a diagnostic message to the caller.7A choice between parsers. Keep only the first success.T4Deliver the first token if it satisfies a predicate.2Deliver 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.UnReturn an error using the supplied diagnostic string, and a token type which includes position information./If 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.#VWRTUXYZ[\"VWRTUXYZ[\MGraham Hutton (University of Nottingham), Erik Meijer (University of Utrecht)BSD/Malcolm Wallace <Malcolm.Wallace@cs.york.ac.uk>StableAll A LIBRARY OF MONADIC PARSER COMBINATORS 29th July 1996 Graham Hutton Erik Meijer University of Nottingham University of Utrecht Safe-InferredThe parser monad*]^_`ab$$)]^_`abc !"#$%&'()*+,-./0123,-4/012.3,-./0156734,-4/01.3567*,-8984./013 , - 4 / 0 1 . : ; 3 , - 4 / 0 1 . : ; 3 < = > ? @ A B C D E F G H I J K L M N O P Q R S T U , - 4 / 0 1 . : ; 3 , - 4 / 0 1 . : ; 5 6 7 34<=>?@ABCDEFGHIJKLMNOPRSU,-V0WXYZ[\%]^_`abc)defgh3,-ViWYj\%]^_`abc)klmnopqrstuvwxyz{|}~\     ijpolyparse-1.11"Text.ParserCombinators.Poly.Result Text.ParserCombinators.Poly.Base"Text.ParserCombinators.Poly.Parser Text.ParserCombinators.Poly.Lazy'Text.ParserCombinators.Poly.StateParser!Text.ParserCombinators.Poly.State%Text.ParserCombinators.Poly.StateLazyText.ParserCombinators.Poly.Lex&Text.ParserCombinators.Poly.ByteString*Text.ParserCombinators.Poly.ByteStringCharText.Parse.ByteString Text.ParserCombinators.Poly.Text%Text.ParserCombinators.Poly.StateText!Text.ParserCombinators.Poly.Plain Text.Parse*Text.ParserCombinators.HuttonMeijerWallace#Text.ParserCombinators.HuttonMeijerText.ParserCombinators.PolyResult CommittedFailureSuccessresultToEither PolyParse Commitmentcommit adjustErroneOf'applydiscardfailBad adjustErrBadoneOfindentexactlyuptomany1sepBysepBy1 bracketSepbracket manyFinally manyFinally'ParserPonFailnexteofsatisfy satisfyMsgreparse runParserstUpdatestQuerystGet LexReturn LexFinish manySatisfy many1SatisfyParseparse parsePrec parseList TextParser parseByRead readByParsereadsPrecByParsePrecwordisWordliteraloptionalParensparensfield constructors enumeration parseSignedparseIntparseDecparseOctparseHexparseUnsignedInteger parseFloat parseLitCharallAsByteString allAsStringitempapplypapply'+++toknottokmanysepbysepby1chainlchainl1chainrchainr1opstoEOFelserrorstupdstquerystgetfirstsatchardigitlowerupperletteralphanumstringidentnatintspacescommentjunkskiptokennaturalintegersymbol identifier$fFunctorResult$fCommitmentParser$fPolyParseParser$fAlternativeParser $fMonadParser$fApplicativeParser$fFunctorParserthrowEbaseControl.Applicative<*>pure Alternative ApplicativeoptionalliftA3liftA2liftA<**><**>some<|>emptygetConstConst unwrapMonad WrapMonad WrappedMonad unwrapArrow WrapArrow WrappedArrow getZipListZipList Data.Functor<$>GHC.Base<$ $fParse[] $fParseEither $fParseMaybe $fParse(,,) $fParse(,) $fParse()$fParseOrdering $fParseBool $fParseChar $fParseDouble $fParseFloat$fParseInteger $fParseIntoldwordGHC.Errerror parseerror ParseResult joinresults$fMonadPlusParserToken