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

Safe HaskellSafe
LanguageHaskell98

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 a Source

pReturn is defined for upwards compatibility

pFail :: Alternative p => p a Source

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 a infixl 4 Source

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

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

<.> functional composition of two parsers

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

<..> functional composition of two parsers with the arguments reversed

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 a Source

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 a1 Source

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

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

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

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 b Source

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

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

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

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 c Source

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

Treating the operator as left associative

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

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

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 b Source

Count the number of times p has succeeded

Miscelleneous

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

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