parsley-2.0.0.0: A fast parser combinator library backed by Typed Template Haskell
LicenseBSD-3-Clause
MaintainerJamie Willis
Stabilitystable
Safe HaskellNone
LanguageHaskell2010

Parsley.Fold

Description

This module contains the combinator concerned with some form of iteration or input folding. Notably, this includes the traditional many and some combinators.

Since: 0.1.0.0

Synopsis

Documentation

many :: Parser a -> Parser [a] Source #

Attempts to parse the given parser zero or more times, collecting all of the successful results into a list. Same as manyN 0

Since: 0.1.0.0

some :: Parser a -> Parser [a] Source #

Attempts to parse the given parser one or more times, collecting all of the successful results into a list. Same as manyN 1

Since: 0.1.0.0

manyN :: Int -> Parser a -> Parser [a] Source #

Attempts to parse the given parser n or more times, collecting all of the successful results into a list.

Since: 0.1.0.0

skipMany :: Parser a -> Parser () Source #

Like many, excepts discards its results.

Since: 0.1.0.0

skipSome :: Parser a -> Parser () Source #

Like some, excepts discards its results.

Since: 0.1.0.0

skipManyN :: Int -> Parser a -> Parser () Source #

Like manyN, excepts discards its results.

Since: 0.1.0.0

sepBy :: Parser a -> Parser b -> Parser [a] Source #

sepBy p sep parses zero or more occurrences of p, separated by sep. Returns a list of values returned by p.

Since: 0.1.0.0

sepBy1 :: Parser a -> Parser b -> Parser [a] Source #

sepBy1 p sep parses one or more occurrences of p, separated by sep. Returns a list of values returned by p.

Since: 0.1.0.0

endBy :: Parser a -> Parser b -> Parser [a] Source #

endBy p sep parses zero or more occurrences of p, separated and ended by sep. Returns a list of values returned by p.

Since: 0.1.0.0

endBy1 :: Parser a -> Parser b -> Parser [a] Source #

endBy1 p sep parses one or more occurrences of p, separated and ended by sep. Returns a list of values returned by p.

Since: 0.1.0.0

sepEndBy :: Parser a -> Parser b -> Parser [a] Source #

sepEndBy p sep parses zero or more occurrences of p, separated and optionally ended by sep. Returns a list of values returned by p.

Since: 0.1.0.0

sepEndBy1 :: Parser a -> Parser b -> Parser [a] Source #

sepEndBy1 p sep parses one or more occurrences of p, separated and optionally ended by sep. Returns a list of values returned by p.

Since: 0.1.0.0

chainl1 :: Parser a -> Parser (a -> a -> a) -> Parser a Source #

The classic version of the left-associative chain combinator. See infixl1.

chainl1 p op = infixl1 ID p op

Since: 0.1.0.0

chainr1 :: Parser a -> Parser (a -> a -> a) -> Parser a Source #

The classic version of the right-associative chain combinator. See infixr1.

chainr1 p op = infixr1 ID p op

Since: 0.1.0.0

chainl :: ParserOps rep => Parser a -> Parser (a -> a -> a) -> rep a -> Parser a Source #

Like chainl1, but may parse zero occurences of p in which case the value is returned.

Since: 0.1.0.0

chainr :: ParserOps rep => Parser a -> Parser (a -> a -> a) -> rep a -> Parser a Source #

Like chainr1, but may parse zero occurences of p in which case the value is returned.

Since: 0.1.0.0

infixl1 :: ParserOps rep => rep (a -> b) -> Parser a -> Parser (b -> a -> b) -> Parser b Source #

infixl1 wrap p op parses 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. The function wrap is used to transform the initial value from p into the correct form.

Since: 2.0.0.0

infixr1 :: ParserOps rep => rep (a -> b) -> Parser a -> Parser (a -> b -> b) -> Parser b Source #

infixr1 wrap p op parses 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. The function wrap is used to transform the final value from p into the correct form.

Since: 2.0.0.0

prefix :: Parser (a -> a) -> Parser a -> Parser a Source #

This combinator parses repeated applications of an operator to a single final operand. This is primarily used to parse prefix operators in expressions.

Since: 2.0.0.0

postfix :: Parser a -> Parser (a -> a) -> Parser a Source #

This combinator parses repeated applications of an operator to a single initial operand. This is primarily used to parse postfix operators in expressions.

Since: 2.0.0.0

manyr :: (ParserOps repf, ParserOps repk) => repf (a -> b -> b) -> repk b -> Parser a -> Parser b Source #

manyr f k p parses zero or more ps and combines the results using the function f. When p fails without consuming input, the terminal result k is returned.

many = manyr CONS EMPTY

Since: 2.0.0.0

manyl :: (ParserOps repf, ParserOps repk) => repf (b -> a -> b) -> repk b -> Parser a -> Parser b Source #

manyl f k p parses zero or more ps and combines the results using the function f. The accumulator is initialised with the value k.

Since: 2.0.0.0

somer :: (ParserOps repf, ParserOps repk) => repf (a -> b -> b) -> repk b -> Parser a -> Parser b Source #

somer f k p parses one or more ps and combines the results using the function f. When p fails without consuming input, the terminal result k is returned.

some = somer CONS EMPTY

Since: 2.0.0.0

somel :: (ParserOps repf, ParserOps repk) => repf (b -> a -> b) -> repk b -> Parser a -> Parser b Source #

somel f k p parses one or more ps and combines the results using the function f. The accumulator is initialised with the value k.

Since: 2.0.0.0