| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Text.Cassette.Combinator
Description
Commonly used generic combinators.
Synopsis
- choice :: [PP a] -> PP a
- count :: Int -> PP a -> PP [a]
- option :: a -> PP a -> PP a
- optionMaybe :: PP a -> PP (Maybe a)
- optional :: PP a -> PP0
- many :: PP a -> PP [a]
- some :: PP a -> PP [a]
- skipMany :: PP a -> PP0
- skipSome :: PP a -> PP0
- sepBy :: PP a -> PP0 -> PP [a]
- sepBy1 :: PP a -> PP0 -> PP [a]
- chainl :: PP0 -> BinL a a a -> PP a -> a -> PP a
- chainl1 :: PP0 -> BinL a a a -> PP a -> PP a
- chainr :: PP0 -> BinL a a a -> PP a -> a -> PP a
- chainr1 :: PP0 -> BinL a a a -> PP a -> PP a
- notFollowedBy :: PP0 -> PP0
- manyTill :: PP a -> PP0 -> PP [a]
Documentation
choice :: [PP a] -> PP a Source #
Applies each cassette in the supplied list in order, until one of them succeeds.
option :: a -> PP a -> PP a Source #
Tries to apply the given cassette. It returns the value of the cassette on success, the first argument otherwise.
optionMaybe :: PP a -> PP (Maybe a) Source #
Tries to apply the given cassette. It returns a value of the form Just x on success, Nothing otherwise.
optional :: PP a -> PP0 Source #
Tries to match the given cassette and discards the result, otherwise does nothing in case of failure.
sepBy :: PP a -> PP0 -> PP [a] Source #
Apply the first argument zero or more times, separated by the second argument.
sepBy1 :: PP a -> PP0 -> PP [a] Source #
Apply the first argument one or more times, separated by the second argument.
chainl :: PP0 -> BinL a a a -> PP a -> a -> PP a Source #
chainl p op x matches 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.
chainl1 :: PP0 -> BinL a a a -> PP a -> PP a Source #
Match a left-associative chain of infix operators.
chainr :: PP0 -> BinL a a a -> PP a -> a -> PP a Source #
chainr p op x matches 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 zero occurrences of p, the value x is returned.
chainr1 :: PP0 -> BinL a a a -> PP a -> PP a Source #
Match a right-associative chain of infix operators.
notFollowedBy :: PP0 -> PP0 Source #
notFollowedBy p only succeeds when p fails. This combinator does not consume/produce any input.