!ӾA      !"#$%&'()*+,-./0123456789:;<=>?@ 2017 2019 Mark Karpov BSD 3 clause$Mark Karpov <markkarpov92@gmail.com> experimentalportableSafe5}parser-combinators open close p parses open, followed by p and close!. Returns the value returned by p. *braces = between (symbol "{") (symbol "}")parser-combinators ps( tries to apply the parsers in the list psS in order, until one of them succeeds. Returns the value of the succeeding parser.  choice = asumparser-combinators n p parses n occurrences of p. If n4 is smaller or equal to zero, the parser equals to A []. Returns a list of n parsed values. count = replicateM See also: , .parser-combinators m n p parses from m to n occurrences of p. If n is not positive or m > n, the parser equals to A []#. Returns a list of parsed values.Please note that m mayK be negative, in this case effect is the same as if it were equal to zero. See also: , . parser-combinatorsCombine two alternatives. ,eitherP a b = (Left <$> a) <|> (Right <$> b) parser-combinators  p sep parses zero or more occurrences of p, separated and ended by sep'. Returns a list of values returned by p. *cStatements = cStatement `endBy` semicolon parser-combinators  p sep parses one or more occurrences of p, separated and ended by sep'. Returns a list of values returned by p. parser-combinators  p end applies parser p zero or more times until parser end2 succeeds. Returns the list of values returned by p. See also: , . parser-combinators  p end works similarly to   p end, but p should succeed at least once. See also: , .parser-combinators x p tries to apply the parser p. If p6 fails without consuming input, it returns the value x#, otherwise the value returned by p. option x p = p <|> pure x See also: .parser-combinators p sep parses zero or more occurrences of p, separated by sep'. Returns a list of values returned by p. commaSep p = p `sepBy` commaparser-combinators p sep parses one or more occurrences of p, separated by sep'. Returns a list of values returned by p.parser-combinators p sep parses zero or more occurrences of p%, separated and optionally ended by sep'. Returns a list of values returned by p.parser-combinators p sep parses one or more occurrences of p%, separated and optionally ended by sep'. Returns a list of values returned by p.parser-combinators p applies the parser p zero% or more times, skipping its result. See also:  , .parser-combinators p applies the parser p one% or more times, skipping its result. See also:  , .parser-combinators n p parses n occurrences of p, skipping its result. If n' is not positive, the parser equals to A []. Returns a list of n values. skipCount = replicateM_ See also: , .parser-combinators p end applies the parser p zero. or more times skipping results until parser end succeeds. Result parsed by end is then returned. See also:  , .parser-combinators p end applies the parser p one. or more times skipping results until parser end succeeds. Result parsed by end is then returned. See also:  , .   2017 2019 Mark Karpov BSD 3 clause$Mark Karpov <markkarpov92@gmail.com> experimentalportableSafeCparser-combinators p applies the parser p one= or more times and returns a list of the values returned by p. word = some letterparser-combinators p sep parses one or more occurrences of p, separated and ended by sep1. Returns a non-empty list of values returned by p.parser-combinators p end works similarly to   p end, but p should succeed at least once. See also: , .parser-combinators p sep parses one or more occurrences of p, separated by sep1. Returns a non-empty list of values returned by p.parser-combinators p sep parses one or more occurrences of p%, separated and optionally ended by sep2. Returns a non-empty list of values returned by p. 2017 2019 Alex Washburn BSD 3 clause$Mark Karpov <markkarpov92@gmail.com> experimentalportableSafedXparser-combinatorsAn B3 wrapper-type for constructing permutation parsers.parser-combinators="Unlifts" a permutation parser into a parser to be evaluated.parser-combinators"Unlifts" a permutation parser into a parser to be evaluated with an intercalated effect. Useful for separators between permutation elements.eFor example, suppose that similar to above we want to parse a permutation of: an optional string of a's, the character b and an optional c. Howeverx, we also want each element of the permutation to be separated by a colon. Using a standard parsing library combinator char#, this can be described using the B instance by: test = intercalateEffect (char ':') $ (,,) <$> toPermutationWithDefault "" (some (char 'a')) <*> toPermutation (char 'b') <*> toPermutationWithDefault '_' (char 'c')FThis will accept strings such as: "a:b:c", "b:c:a", "b:aa", "b", etc.%Note that the effect is intercalated between" permutation components and that:YThere is never an effect parsed preceeding the first component of the permutation.WThere is never an effect parsed following the last component of the permutation.SNo effects are intercalated between missing components with a default value. parser-combinators)"Lifts" a parser to a permutation parser.!parser-combinators>"Lifts" a parser with a default value to a permutation parser.If no permutation containing the supplied parser can be parsed from the input, then the supplied default value is returned in lieu of a parse result.parser-combinatorsPermutation specificationparser-combinators8Resulting base monad capable of handling the permutationparser-combinators8Effect to be intercalated between permutation componentsparser-combinatorsPermutation specificationparser-combinators8Resulting base monad capable of handling the permutation parser-combinatorsPermutation component!parser-combinators Default Valueparser-combinatorsPermutation component ! ! 2017 2019 Mark Karpov BSD 3 clause$Mark Karpov <markkarpov92@gmail.com> experimentalportableSafeS$parser-combinators$ n p parses n occurrences of p. If n4 is smaller or equal to zero, the parser equals to C []. Returns a list of n values. See also: 2, %.%parser-combinators% m n p parses from m to n occurrences of p. If n is not positive or m > n, the parser equals to C []#. Returns a list of parsed values.Please note that m mayK be negative, in this case effect is the same as if it were equal to zero. See also: 2, $.&parser-combinators& p sep parses zero or more occurrences of p, separated and ended by sep'. Returns a list of values returned by p. *cStatements = cStatement `endBy` semicolon'parser-combinators' p sep parses one or more occurrences of p, separated and ended by sep'. Returns a list of values returned by p.(parser-combinators( p applies the parser p zero= or more times and returns a list of the values returned by p. @identifier = (:) <$> letter <*> many (alphaNumChar <|> char '_'))parser-combinators) p end applies parser p zero or more times until parser end2 succeeds. Returns the list of values returned by p. See also: 0, 3.*parser-combinators* p applies the parser p one= or more times and returns a list of the values returned by p. word = some letter+parser-combinators+ p end works similarly to ) p end, but p should succeed at least once. See also: 1, 4.,parser-combinators, p sep parses zero or more occurrences of p, separated by sep'. Returns a list of values returned by p. commaSep p = p `sepBy` comma-parser-combinators- p sep parses one or more occurrences of p, separated by sep'. Returns a list of values returned by p..parser-combinators. p sep parses zero or more occurrences of p%, separated and optionally ended by sep'. Returns a list of values returned by p./parser-combinators/ p sep parses one or more occurrences of p%, separated and optionally ended by sep'. Returns a list of values returned by p.0parser-combinators0 p applies the parser p zero% or more times, skipping its result. See also: ), 3.1parser-combinators1 p applies the parser p one% or more times, skipping its result. See also: +, 4.2parser-combinators2 n p parses n occurrences of p, skipping its result. If n3 is smaller or equal to zero, the parser equals to C []. Returns a list of n values. See also: $, %.3parser-combinators3 p end applies the parser p zero. or more times skipping results until parser end succeeds. Result parsed by end is then returned. See also: ), 0.4parser-combinators4 p end applies the parser p one. or more times skipping results until parser end succeeds. Result parsed by end is then returned. See also: +, 1. $%&'()*+,-./01234$% &'()*+,-./01234 2017 2019 Mark Karpov BSD 3 clause$Mark Karpov <markkarpov92@gmail.com> experimental non-portableSafeƔ 5parser-combinators?This data type specifies operators that work on values of type az. An operator is either binary infix or unary prefix or postfix. A binary operator has also an associated associativity.6parser-combinatorsNon-associative infix7parser-combinatorsLeft-associative infix8parser-combinatorsRight-associative infix9parser-combinatorsPrefix:parser-combinatorsPostfix;parser-combinators; term table( builds an expression parser for terms term with operators from table<, taking the associativity and precedence specified in the table into account.table is a list of [Operator m a] lists. The list is ordered in descending precedence. All operators in one list have the same precedence (but may have different associativity).TPrefix and postfix operators of the same precedence associate to the left (i.e. if ++ is postfix increment, than -2++ equals -1, not -3).AUnary operators of the same precedence can only occur once (i.e. --2 is not allowed if -i is prefix negate). If you need to parse several prefix or postfix operators in a row, (like C pointers **i) you can use this approach: /manyUnaryOp = foldr1 (.) <$> some singleUnaryOpsThis is not done by default because in some cases allowing repeating prefix or postfix operators is not desirable.If you want to have an operator that is a prefix of another operator in the table, use the following (or similar) wrapper (Megaparsec example): Aop n = (lexeme . try) (string n <* notFollowedBy punctuationChar); takes care of all the complexity involved in building an expression parser. Here is an example of an expression parser that handles prefix signs, postfix increment and basic arithmetic: expr = makeExprParser term table <?> "expression" term = parens expr <|> integer <?> "term" table = [ [ prefix "-" negate , prefix "+" id ] , [ postfix "++" (+1) ] , [ binary "*" (*) , binary "/" div ] , [ binary "+" (+) , binary "-" (-) ] ] binary name f = InfixL (f <$ symbol name) prefix name f = Prefix (f <$ symbol name) postfix name f = Postfix (f <$ symbol name)Dparser-combinatorsaddPrecLevel p ops. adds the ability to parse operators in table ops to parser p.Eparser-combinatorspTerm prefix term postfix parses a termE surrounded by optional prefix and postfix unary operators. Parsers prefix and postfix$ are allowed to fail, in this case F is used.Gparser-combinatorspInfixN op p x' parses non-associative infix operator op, then term with parser p5, then returns result of the operator application on x and the term.Hparser-combinatorspInfixL op p x( parses left-associative infix operator op, then term with parser p5, then returns result of the operator application on x and the term.Iparser-combinatorspInfixR op p x) parses right-associative infix operator op, then term with parser p6, then returns result of the operator application on x and the term.Jparser-combinatorssA helper to separate various operators (binary, unary, and according to associativity) and return them in a tuple.;parser-combinators Term parserparser-combinatorsOperator table, see 5parser-combinatorsResulting expression parser59678:;59678:; 2017 2019 Mark Karpov BSD 3 clause$Mark Karpov <markkarpov92@gmail.com> experimentalportableSafeӒ<parser-combinators< p applies the parser p one= or more times and returns a list of the values returned by p. word = some letter=parser-combinators= p sep parses one or more occurrences of p, separated and ended by sep1. Returns a non-empty list of values returned by p.>parser-combinators> p end works similarly to ) p end, but p should succeed at least once. See also: 1, 4.?parser-combinators? p sep parses one or more occurrences of p, separated by sep1. Returns a non-empty list of values returned by p.@parser-combinators@ p sep parses one or more occurrences of p%, separated and optionally ended by sep2. Returns a non-empty list of values returned by p.<=>?@<=>?@K      ! "#$%&'(   !)*+,-./  0 1 234 56789:.parser-combinators-1.0.1-7zsJEGONwOhyiaqHOncKZControl.Applicative.Combinators(Control.Applicative.Combinators.NonEmpty Control.Applicative.PermutationsControl.Monad.CombinatorsControl.Monad.Combinators.Expr"Control.Monad.Combinators.NonEmptybaseControl.ApplicativeoptionalGHC.Basemanysome<|>emptybetweenchoicecountcount'eitherPendByendBy1manyTillsomeTilloptionsepBysepBy1sepEndBy sepEndBy1skipManyskipSome skipCount skipManyTill skipSomeTill PermutationrunPermutationintercalateEffect toPermutationtoPermutationWithDefault$fApplicativePermutation$fFunctorPermutationOperatorInfixNInfixLInfixRPrefixPostfixmakeExprParserpure Applicativereturn addPrecLevelpTermidpInfixNpInfixLpInfixRsplitOp