cassette-0.1.0: A combinator library for simultaneously defining parsers and pretty printers.

Safe HaskellSafe-Infered

Text.Cassette.Combinator

Synopsis

Documentation

choice :: [PP a] -> PP aSource

Applies each cassette in the supplied list in order, until one of them succeeds.

count :: Int -> PP a -> PP [a]Source

count n p matches n occurrences of p.

option :: a -> PP a -> PP aSource

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 -> PP0Source

Tries to match the given cassette and discards the result, otherwise does nothing in case of failure.

many :: PP a -> PP [a]Source

Apply the given cassette zero or more times.

many1 :: PP a -> PP [a]Source

Apply the given cassette one or more times.

skipMany :: PP a -> PP0Source

Apply the given cassette zero or more times, discarding the result.

skipMany1 :: PP a -> PP0Source

Apply the given cassette one or more times, discarding the result.

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 aSource

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 aSource

Match a a left-associative chain of infix operators.

chainr :: PP0 -> BinL a a a -> PP a -> a -> PP aSource

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 aSource

Match a a right-associative chain of infix operators.

notFollowedBy :: PP0 -> PP0Source

notFollowedBy p only succeeds when p fails. This combinator does not consume/produce any input.

manyTill :: PP a -> PP0 -> PP [a]Source

Applies first argument zero or more times until second argument succeeds.