uu-parsinglib-2.8.1.1: Fast, online, error-correcting, monadic, applicative, merging, permuting, idiomatic parser combinators.

Safe HaskellNone

Text.ParserCombinators.UU.Derived

Contents

Description

This module contains a large variety of combinators for list-like structures. the extension _ng indicates that that variant is the non-greedy variant. See the Text.ParserCombinators.UU.Demo.Examples module for some examples of their use.

Synopsis

Some aliases for oft occurring constructs

pReturn :: Applicative p => a -> p aSource

pReturn is defined for upwards compatibility

pFail :: Alternative p => p aSource

pFail is defined for upwards compatibility, and is the unit for |

pMaybe :: IsParser p => p a -> p (Maybe a)Source

pMaybe greedily recognises its argument. If not Nothing is returned.

pEither :: IsParser p => p a -> p b -> p (Either a b)Source

pEither recognises either one of its arguments.

(<$$>) :: IsParser p => (a -> b -> c) -> p b -> p (a -> c)Source

<$$> is the version of <$> which flips the function argument

(<??>) :: IsParser p => p a -> p (a -> a) -> p aSource

<??> parses an optional postfix element and applies its result to its left hand result

pMany :: IsParser p => p a -> p [a]Source

pMany is equivalent to the many from Control.Applicative. We want however all our parsers to start with a lower case p.

pSome :: IsParser f => f a -> f [a]Source

pSome is equivalent to the some from Control.Applicative. We want however all our parsers to start with a lower case p.

pPacked :: IsParser p => p b1 -> p b2 -> p a -> p aSource

pPacked surrounds its third parser with the first and the second one, returning only the middle result

Iterating combinators, all in a greedy (default) and a non-greedy (ending with _ng) variant

Recognising list like structures

pFoldr :: IsParser p => (a -> a1 -> a1, a1) -> p a -> p a1Source

pFoldr_ng :: IsParser p => (a -> a1 -> a1, a1) -> p a -> p a1Source

pFoldr1 :: IsParser p => (v -> b -> b, b) -> p v -> p bSource

pFoldr1_ng :: IsParser p => (v -> b -> b, b) -> p v -> p bSource

list_alg :: (a -> [a] -> [a], [a1])Source

pList :: IsParser p => p a -> p [a]Source

pList_ng :: IsParser p => p a -> p [a]Source

pList1 :: IsParser p => p a -> p [a]Source

pList1_ng :: IsParser p => p a -> p [a]Source

Recognising list structures with separators

pFoldrSep :: IsParser p => (v -> b -> b, b) -> p a -> p v -> p bSource

pFoldrSep_ng :: IsParser p => (v -> b -> b, b) -> p a -> p v -> p bSource

pFoldr1Sep :: IsParser p => (a -> b -> b, b) -> p a1 -> p a -> p bSource

pFoldr1Sep_ng :: IsParser p => (a -> b -> b, b) -> p a1 -> p a -> p bSource

pListSep :: IsParser p => p a1 -> p a -> p [a]Source

pListSep_ng :: IsParser p => p a1 -> p a -> p [a]Source

pList1Sep :: IsParser p => p a1 -> p a -> p [a]Source

pList1Sep_ng :: IsParser p => p a1 -> p a -> p [a]Source

Combinators for chained structures

Treating the operator as right associative

pChainr :: IsParser p => p (c -> c -> c) -> p c -> p cSource

pChainr_ng :: IsParser p => p (c -> c -> c) -> p c -> p cSource

Treating the operator as left associative

pChainl :: IsParser p => p (c -> c -> c) -> p c -> p cSource

pChainl_ng :: IsParser p => p (c -> c -> c) -> p c -> p cSource

Repeating parsers

pExact :: IsParser f => Int -> f a -> f [a]Source

pExact recognises a specified number of elements

pBetween :: IsParser f => Int -> Int -> f a -> f [a]Source

pAtLeast :: IsParser f => Int -> f a -> f [a]Source

pAtMost :: IsParser f => Int -> f a -> f [a]Source

Counting Parser

pCount :: (IsParser p, Num b) => p a -> p bSource

Count the number of times p has succeeded

Miscelleneous

pAny :: IsParser p => (a -> p a1) -> [a] -> p a1Source

Build a parser for each element in the argument list and try them all.