ob:      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~portable experimentalEdward Kmett <ekmett@gmail.com> Safe-InferredTags used by the     combinator.      non-portable provisionalekmett@gmail.com Safe-Inferred The type Permutation m a$ denotes a permutation parser that,  when converted by the   function, parses  using the base parsing monad m and returns a value of  type a on success. ENormally, a permutation parser is first build with special operators  like (,) and than transformed into a normal parser  using  . The expression perm <||> p adds parser p to the permutation  parser perm . The parser p( is not allowed to accept empty input -  use the optional combinator () instead. Returns a & new permutation parser that includes p. The expression f <$$> p$ creates a fresh permutation parser  consisting of parser p*. The the final result of the permutation  parser is the function f applied to the return value of p. The  parser p9 is not allowed to accept empty input - use the optional  combinator ( ) instead. If the function f2 takes more than one parameter, the type variable  bA is instantiated to a functional type which combines nicely with  the adds parser p to the () combinator. This C results in stylized code where a permutation parser starts with a  combining function f' followed by the parsers. The function f F gets its parameters in the order in which the parsers are specified, ' but actual input can be in any order. The expression perm < ||> (x,p) adds parser p to the  permutation parser perm . The parser p is optional - if it can # not be applied, the default value x will be used instead. Returns < a new permutation parser that includes the optional parser p. The expression f < $?> (x,p)$ creates a fresh permutation parser  consisting of parser p*. The the final result of the permutation  parser is the function f applied to the return value of p. The  parser p; is optional - if it can not be applied, the default value  x will be used instead.  The parser  permute perm* parses a permutation of parser described  by perm:. For example, suppose we want to parse a permutation of:  an optional string of a's, the character b and an optional c.  This can be described by: 3 test = permute (tuple <$?> ("",some (char 'a')) ' <||> char 'b' . <|?> ('_',char 'c'))  where ! tuple a b c = (a,b,c)       non-portable experimentalekmett@gmail.com Safe-Inferred!OAdditional functionality needed to describe parsers independent of input type. "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. #Give a parser a name $BA version of many that discards its input. Specialized because it ( can often be implemented more cheaply. % skipSome p applies the parser p one or more times, skipping ' its result. (aka skipMany1 in parsec) &-Used to emit an error on an unexpected token 'AThis parser only succeeds at the end of the input. This is not a * primitive parser but it is defined using (. 2 eof = notFollowedBy anyChar <?> "end of input" (notFollowedBy p only succeeds when parser p fails. This parser F does not consume any input. This parser can be used to implement the  ' longest match'3 rule. For example, when recognizing keywords (for  example let7), 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 example lets). We can program this  behaviour as follows: = keywordLet = try $ string "let" <* notFollowedBy alphaNum ) choice ps( tries to apply the parsers in the list ps in order, A until one of them succeeds. Returns the value of the succeeding  parser. * option x p tries to apply parser p. If p fails without ' consuming input, it returns the value x, otherwise the value  returned by p. - priority = option 0 (digitToInt <$> digit) +skipOptional p tries to apply parser p. It will parse p or nothing.  It only fails if p5 fails after consuming input. It discards the result  of p. (Plays the role of parsec',s optional, which conflicts with Applicative' s optional) ,between open close p parses open, followed by p and close.  Returns the value returned by p. . braces = between (symbol "{") (symbol "}") - sepBy p sep parses zero or more occurrences of p , separated  by sep'. Returns a list of values returned by p. ' commaSep p = p `sepBy` (symbol ",") . sepBy1 p sep parses one or more occurrences of p , separated  by sep'. Returns a list of values returned by p. /sepEndBy1 p sep parses one or more occurrences of p, # separated and optionally ended by sep. Returns a list of values  returned by p. 0sepEndBy p sep parses zero or more occurrences of p, # separated and optionally ended by sep, ie. haskell style 2 statements. Returns a list of values returned by p. 8 haskellStatements = haskellStatement `sepEndBy` semi 1 endBy1 p sep parses one or more occurrences of p , seperated  and ended by sep'. Returns a list of values returned by p. 2 endBy p sep parses zero or more occurrences of p , seperated  and ended by sep'. Returns a list of values returned by p. * cStatements = cStatement `endBy` semi 3 count n p parses n occurrences of p. If n is smaller or % equal to zero, the parser equals to return []. Returns a list of  n values returned by p. 4 chainr p op x parser zero or more occurrences of p,  separated by op Returns a value obtained by a right associative * application of all functions returned by op to the values returned  by p!. If there are no occurrences of p , the value x is  returned. 5 chainl p op x parser zero or more occurrences of p,  separated by op . Returns a value obtained by a left associative * application of all functions returned by op to the values returned  by p#. If there are zero occurrences of p , the value x is  returned. 6chainl1 p op x parser one or more occurrences of p,  separated by op Returns a value obtained by a left associative * application of all functions returned by op to the values returned  by p:. . This parser can for example be used to eliminate left : recursion which typically occurs in expression grammars. " expr = term `chainl1` addop " term = factor `chainl1` mulop # factor = parens expr <|> integer   mulop = (*) <$ symbol "*"  <|> div <$ symbol "/"   addop = (+) <$ symbol "+"  <|> (-) <$ symbol "-" 7chainr1 p op x parser one or more occurrences of |p|,  separated by op Returns a value obtained by a right associative * application of all functions returned by op to the values returned  by p. 8manyTill p end applies parser p zero or more times until  parser end2 succeeds. Returns the list of values returned by p. + This parser can be used to scan comments:  & simpleComment = do{ string "<!--" > ; manyTill anyChar (try (string "-->"))  } Note the overlapping parsers anyChar and string "-->", and  therefore the use of the " combinator. "!"#$%&'()*+,-./012345678!"#$%&'()*+,-./012345678)*+,-./012354678!"#$%&'(!"#$%&'()*+,-./012345678 non-portable experimentalekmett@gmail.com Safe-Inferred9OAdditional functionality needed to describe parsers independent of input type. : lookAhead p parses p without consuming any input. 9:9:9: 9: non-portable experimentalekmett@gmail.com Safe-Inferred;An OperatorTable m a is a list of  Operator m a * lists. The list is ordered in descending E precedence. All operators in one list have the same precedence (but & may have a different associativity). <?This data type specifies operators that work on values of type a. B An operator is either binary infix or unary prefix or postfix. A 7 binary operator has also an associated associativity. @EThis data type specifies the associativity of operators: left, right  or none. D buildExpressionParser table term! builds an expression parser for  terms term with operators from table, taking the associativity  and precedence specified in table" into account. Prefix and postfix < operators of the same precedence can only occur once (i.e. --2 is  not allowed if -1 is prefix negate). Prefix and postfix operators 7 of the same precedence associate to the left (i.e. if ++ is  postfix increment, than -2++ equals -1, not -3). The buildExpressionParser" takes care of all the complexity B involved in building expression parser. Here is an example of an D expression parser that handles prefix signs, postfix increment and  basic arithmetic. - expr = buildExpressionParser table term  <?> "expression"   term = parens expr  <|> natural " <?> "simple expression"  2 table = [ [prefix "-" negate, prefix "+" id ] " , [postfix "++" (+1)] F , [binary "*" (*) AssocLeft, binary "/" (div) AssocLeft ] F , [binary "+" (+) AssocLeft, binary "-" (-) AssocLeft ]  ]  @ binary name fun assoc = Infix (fun <* reservedOp name) assoc ; prefix name fun = Prefix (fun <* reservedOp name) < postfix name fun = Postfix (fun <* reservedOp name) ;<=>?@ABCD ;<=>?@ABCD @CBA<?>=;D;<?>=@CBAD non-portable experimentalekmett@gmail.comNoneE<Additional functionality needed to parse character streams. F;Parse a single character of the input, with UTF-8 decoding Gchar c parses a single character c. Returns the parsed  character (i.e. c). e.g.  semiColon = G ';'H notChar c( parses any single character other than c. Returns the parsed  character. IFThis parser succeeds for any character. Returns the parsed character. Jstring s* parses a sequence of characters given by s . Returns  the parsed string (i.e. s).  divOrMod = string "div"  <|> string "mod" Ktext t8 parses a sequence of characters determined by the text t Returns  the parsed text fragment (i.e. t). Using OverloadedStrings:  divOrMod = text "div"  <|> text "mod" LoneOf cs6 succeeds if the current character is in the supplied  list of characters cs). Returns the parsed character. See also  F.  vowel = oneOf "aeiou" MAs the dual of L,  noneOf cs succeeds if the current  character not$ in the supplied list of characters cs. Returns the  parsed character.  consonant = noneOf "aeiou" N oneOfSet cs6 succeeds if the current character is in the supplied  set of characters cs). Returns the parsed character. See also  F.  vowel = oneOf "aeiou" OAs the dual of L,  noneOf cs succeeds if the current  character not$ in the supplied list of characters cs. Returns the  parsed character.  consonant = noneOf "aeiou" PSkips zero* or more white space characters. See also $. Q>Parses a white space character (any character which satisfies )  Returns the parsed character. RParses a newline character ('\n' ). Returns a newline character. SParses a tab character ('\t'). Returns a tab character. T1Parses an upper case letter (a character between 'A' and 'Z').  Returns the parsed character. U3Parses a lower case character (a character between 'a' and 'z').  Returns the parsed character. V.Parses a letter or digit (a character between '0' and '9').  Returns the parsed character. WEParses a letter (an upper case or lower case character). Returns the  parsed character. X.Parses a digit. Returns the parsed character. Y8Parses a hexadecimal digit (a digit or a letter between 'a' and  'f' or 'A' and 'F'!). Returns the parsed character. Z+Parses an octal digit (a character between '0' and '7' ). Returns  the parsed character. EFGHIJKLMNOPQRSTUVWXYZEFGHIJKLMNOPQRSTUVWXYZLMNOPQRSTUVWXYZEFGHIJKEFGHIJKLMNOPQRSTUVWXYZ non-portable experimentalekmett@gmail.com Trustworthy4[KThis is a parser transformer you can use to disable the automatic trailing H newline (but not whitespace-in-general) consumption of a Token parser. ^KThis is a parser transformer you can use to disable the automatic trailing & space consumption of a Token parser. aHThis is a parser transformer you can use to disable syntax highlighting ' over a range of text you are parsing. dJUsed to describe an input style for constructors, values, operators, etc. lUAdditional functionality that is needed to tokenize input while ignoring whitespace. mUsually, someSpace consists of one or more occurrences of a Q. J Some parsers may choose to recognize line comments or block (multi line) " comments as white space as well. n/Called when we enter a nested pair of symbols. ) Overloadable to enable disabling layout o-The token parser |semi| parses the character ';' and skips 1 any trailing white space. Returns the character ';'. Overloadable to ? permit automatic semicolon insertion or Haskell-style layout. p@Tag a region of parsed text with a bit of semantic information.  Most parsers won'6t use this, but it is indispensible for highlighters. qtoken p first applies parser p and then the r  parser, returning the value of p. Every lexical  token (token) is defined using token, this way every parse 9 starts at a point without white space. Parsers that use token are  called token parsers in this document. The only point where the r parser should be D called explicitly is the start of the main parser in order to skip  any leading white space.  Alternatively, one might define q as first parsing r  and then parser p3. By parsing whiteSpace first, the parser is able E to return before parsing additional whiteSpace, improving laziness. ? mainParser = sum <$ whiteSpace <*> many (token digit) <* eof rGSkip zero or more bytes worth of white space. More complex parsers are + free to consider comments as white space. sAThis token parser parses a single literal character. Returns the C literal character value. This parsers deals correctly with escape E sequences. The literal character is parsed according to the grammar E rules defined in the Haskell report (which matches most programming  languages quite closely). t?This token parser parses a literal string. Returns the literal F string value. This parsers deals correctly with escape sequences and C gaps. The literal string is parsed according to the grammar rules ? defined in the Haskell report (which matches most programming  languages quite closely). uThis token parser behaves as t, but for single-quoted  strings. v<This token parser parses a natural number (a positive whole = number). Returns the value of the number. The number can be  specified in ,  or  0. The number is parsed according to the grammar  rules in the Haskell report. wBThis token parser parses an integer (a whole number). This parser  is like v% except that it can be prefixed with  sign (i.e. '-' or '+'(). Returns the value of the number. The  number can be specified in ,   or !. The number is parsed according - to the grammar rules in the Haskell report. xCThis token parser parses a floating point value. Returns the value D of the number. The number is parsed according to the grammar rules  defined in the Haskell report. y This token parser parses either v or a float. : Returns the value of the number. This parsers deals with F any overlap in the grammar rules for naturals and floats. The number I is parsed according to the grammar rules defined in the Haskell report. zThis token parser is like y, but handles  leading - or +. { Token parser symbol s parses J s and skips  trailing white space. | Token parser  textSymbol t parses K s and skips  trailing white space. } Token parser  symbolic s parses G s and skips  trailing white space. ~ Token parser parens p parses p enclosed in parenthesis,  returning the value of p.  Token parser braces p parses p enclosed in braces ('{' and  '}'), returning the value of p.  Token parser angles p parses p enclosed in angle brackets ('<'  and '>'), returning the value of p.  Token parser  brackets p parses p enclosed in brackets ('['  and ']'), returning the value of p.  Token parser comma parses the character ',' and skips any * trailing white space. Returns the string ",".  Token parser colon parses the character ':' and skips any * trailing white space. Returns the string ":".  Token parser dot parses the character '.' and skips any * trailing white space. Returns the string ".".  Token parser  semiSep p parses zero or more occurrences of p  separated by o'. Returns a list of values returned by p.  Token parser  semiSep1 p parses one or more occurrences of p  separated by o'. Returns a list of values returned by p.  Token parser  commaSep p parses zero or more occurrences of  p separated by $. Returns a list of values returned  by p.  Token parser  commaSep1 p parses one or more occurrences of  p separated by $. Returns a list of values returned  by p. GThis lens can be used to update the name for this style of identifier.  :: Lens' (d m) `This lens can be used to update the action used to recognize the first letter in an identifier.  :: Lens' (d m) (m )bThis lens can be used to update the action used to recognize subsequent letters in an identifier.  :: Lens' (d m) (m )7This is a traversal of both actions in contained in an d.  :: Traversal (d m) (d n) (m ) (n )GThis is a lens that can be used to modify the reserved identifier set.  :: Lens' (d m) ( )VThis is a lens that can be used to modify the highlight used for this identifier set.  :: Lens' (d m) nThis is a lens that can be used to modify the highlight used for reserved identifiers in this identifier set.  :: Lens' (d m) This is a traversal that can be used to modify the highlights used for both non-reserved and reserved identifiers in this identifier set.  :: Traversal' (d m) 2Lift an identifier style into a monad transformer Using over from the lens package:  = over  <parse a reserved operator or identifier using a given style Bparse a reserved operator or identifier using a given style given . *Parse a non-reserved identifier or symbol PThis parser parses a character literal without the surrounding quotation marks. 1This parser does NOT swallow trailing whitespace 9This parser parses a literal string. Returns the literal F string value. This parsers deals correctly with escape sequences and C gaps. The literal string is parsed according to the grammar rules ? defined in the Haskell report (which matches most programming  languages quite closely). 1This parser does NOT swallow trailing whitespace 6This parser parses a natural number (a positive whole = number). Returns the value of the number. The number can be  specified in ,  or  0. The number is parsed according to the grammar  rules in the Haskell report. 2This parser does NOT swallow trailing whitespace. <This parser parses an integer (a whole number). This parser  is like v% except that it can be prefixed with  sign (i.e. '-' or '+'(). Returns the value of the number. The  number can be specified in ,   or !. The number is parsed according - to the grammar rules in the Haskell report. 2This parser does NOT swallow trailing whitespace. Also, unlike the w+ parser, this parser does not admit spaces " between the sign and the number. BParses a positive whole number in the decimal system. Returns the  value of the number. 1This parser does NOT swallow trailing whitespace EParses a positive whole number in the hexadecimal system. The number  should be prefixed with "x" or "X". Returns the value of the  number. 1This parser does NOT swallow trailing whitespace ?Parses a positive whole number in the octal system. The number  should be prefixed with "o" or "O". Returns the value of the  number. 1This parser does NOT swallow trailing whitespace ^[\]^_`abcdefghijklmnopqrstuvwxyz{|}~?[\]^_`abcdefghijklmnopqrstuvwxyz{|}~?rstuvwxyz{|}~lmnopq^_`[\]abcdefghijkL[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ non-portable provisionalekmett@gmail.com TrustworthyHow to deal with comments. 'String that starts a multiline comment %String that ends a multiline comment )String that starts a single line comment  Can we nest multiline comments? IThis is a lens that can edit the string that starts a multiline comment.  :: Lens'  GThis is a lens that can edit the string that ends a multiline comment.  :: Lens'  KThis is a lens that can edit the string that starts a single line comment.  :: Lens'  EThis is a lens that can edit whether we can nest multiline comments.  :: Lens'  No comments at all Use java-style comments Use scala-style comments Use haskell-style comments KUse this to easily build the definition of whiteSpace for your MonadParser A given a comment style and an underlying someWhiteSpace parser DA simple operator style based on haskell with no reserved operators MA simple operator style based on haskell with the operators from Haskell 98. MA simple operator style based on haskell with the operators from Haskell 98. AA simple identifier style based on haskell with no reserve words YA simple identifier style based on haskell with only the reserved words from Haskell 98. oA simple identifier style based on haskell with the reserved words from Haskell 98 and some common extensions.    !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefgghiijkklmmnopqrs tuv wxyz{|}~(    parsers-0.10Text.Parser.CombinatorsText.Parser.Token.HighlightText.Parser.PermutationText.Parser.LookAheadText.Parser.ExpressionText.Parser.CharText.Parser.TokenText.Parser.Token.Style TokenParsing highlightbaseControl.Applicativeoptionalmanysome HighlightLiterateSyntaxLiterateCommentMatchedSymbolsLayoutUnboundBadInputReservedConstructorOperatorConstructorOperatorReservedConstructor ConstructorReservedOperatorOperatorReservedIdentifier IdentifierSymbolSpecial StatementConstant StringLiteral CharLiteralCommentNumber EscapeCode Permutation<||><$$><|?><$?>permuteParsingtryskipManyskipSome unexpectedeof notFollowedBychoiceoption skipOptionalbetweensepBysepBy1 sepEndBy1sepEndByendBy1endBycountchainrchainlchainl1chainr1manyTillLookAheadParsing lookAhead OperatorTablePostfixPrefixInfixAssoc AssocRight AssocLeft AssocNonebuildExpressionParser CharParsingsatisfycharnotCharanyCharstringtextoneOfnoneOfoneOfSet noneOfSetspacesspacenewlinetabupperloweralphaNumletterdigithexDigitoctDigitUnlined runUnlinedUnspaced runUnspaced UnhighlightedrunUnhighlightedIdentifierStyle _styleName _styleStart _styleLetter_styleReserved_styleHighlight_styleReservedHighlight someSpacenestingsemitoken whiteSpace charLiteral stringLiteralstringLiteral'naturalintegerdoublenaturalOrDoubleintegerOrDoublesymbol textSymbolsymbolicparensbracesanglesbracketscommacolondotsemiSepsemiSep1commaSep commaSep1 styleName styleStart styleLetter styleChars styleReservedstyleHighlightstyleReservedHighlightstyleHighlightsliftIdentifierStylereserve reserveTextident characterCharinteger'decimal hexadecimaloctal CommentStyle _commentStart _commentEnd _commentLine_commentNesting commentStart commentEnd commentLinecommentNestingemptyCommentStylejavaCommentStylescalaCommentStylehaskellCommentStylebuildSomeSpaceParseremptyOps haskell98Ops haskellOps emptyIdentshaskell98Idents haskellIdentsBranchnewPermutationaddaddOpt$fFunctorBranch$fFunctorPermutation$fParsingReadP$fParsingParsecT$fParsingIdentityT $fParsingRWST$fParsingRWST0$fParsingWriterT$fParsingWriterT0$fParsingReaderT$fParsingStateT$fParsingStateT0$fLookAheadParsingReadP$fLookAheadParsingParsecT$fLookAheadParsingIdentityT$fLookAheadParsingRWST$fLookAheadParsingRWST0$fLookAheadParsingWriterT$fLookAheadParsingWriterT0$fLookAheadParsingReaderT$fLookAheadParsingStateT$fLookAheadParsingStateT0 GHC.UnicodeisSpace$fCharParsingReadP$fCharParsingParsecT$fCharParsingIdentityT$fCharParsingRWST$fCharParsingRWST0$fCharParsingWriterT$fCharParsingWriterT0$fCharParsingReaderT$fCharParsingStateT$fCharParsingStateT0GHC.BaseStringghc-prim GHC.TypesCharunordered-containers-0.2.3.3 Data.HashSetHashSettransformers-0.3.0.0Control.Monad.Trans.Classlift text-0.11.2.3Data.Text.InternalText escapeCodenatural' charEscape charLetternumbersignintnat zeroNumberfloating fractExponent natDouble zeroNumFloat decimalFloat fractFloat$fTokenParsingReadP$fTokenParsingParsecT$fTokenParsingUnlined$fMonadTransUnlined$fTokenParsingUnspaced$fMonadTransUnspaced$fTokenParsingUnhighlighted$fMonadTransUnhighlighted$fTokenParsingIdentityT$fTokenParsingRWST$fTokenParsingRWST0$fTokenParsingWriterT$fTokenParsingWriterT0$fTokenParsingReaderT$fTokenParsingStateT$fTokenParsingStateT0Boolsethaskell98ReservedIdents