Safe Haskell | Safe |
---|---|

Language | Haskell98 |

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.

- pReturn :: Applicative p => a -> p a
- pFail :: Alternative p => p a
- pMaybe :: IsParser p => p a -> p (Maybe a)
- pEither :: IsParser p => p a -> p b -> p (Either a b)
- (<$$>) :: IsParser p => (a -> b -> c) -> p b -> p (a -> c)
- (<??>) :: IsParser p => p a -> p (a -> a) -> p a
- (<.>) :: IsParser p => p (b -> c) -> p (a -> b) -> p (a -> c)
- (<..>) :: IsParser p => p (a -> b) -> p (b -> c) -> p (a -> c)
- pMany :: IsParser p => p a -> p [a]
- pSome :: IsParser f => f a -> f [a]
- pPacked :: IsParser p => p b1 -> p b2 -> p a -> p a
- pFoldr :: IsParser p => (a -> a1 -> a1, a1) -> p a -> p a1
- pFoldr_ng :: IsParser p => (a -> a1 -> a1, a1) -> p a -> p a1
- pFoldr1 :: IsParser p => (v -> b -> b, b) -> p v -> p b
- pFoldr1_ng :: IsParser p => (v -> b -> b, b) -> p v -> p b
- list_alg :: (a -> [a] -> [a], [a1])
- pList :: IsParser p => p a -> p [a]
- pList_ng :: IsParser p => p a -> p [a]
- pList1 :: IsParser p => p a -> p [a]
- pList1_ng :: IsParser p => p a -> p [a]
- pFoldrSep :: IsParser p => (v -> b -> b, b) -> p a -> p v -> p b
- pFoldrSep_ng :: IsParser p => (v -> b -> b, b) -> p a -> p v -> p b
- pFoldr1Sep :: IsParser p => (a -> b -> b, b) -> p a1 -> p a -> p b
- pFoldr1Sep_ng :: IsParser p => (a -> b -> b, b) -> p a1 -> p a -> p b
- pListSep :: IsParser p => p a1 -> p a -> p [a]
- pListSep_ng :: IsParser p => p a1 -> p a -> p [a]
- pList1Sep :: IsParser p => p a1 -> p a -> p [a]
- pList1Sep_ng :: IsParser p => p a1 -> p a -> p [a]
- pChainr :: IsParser p => p (c -> c -> c) -> p c -> p c
- pChainr_ng :: IsParser p => p (c -> c -> c) -> p c -> p c
- pChainl :: IsParser p => p (c -> c -> c) -> p c -> p c
- pChainl_ng :: IsParser p => p (c -> c -> c) -> p c -> p c
- pExact :: IsParser f => Int -> f a -> f [a]
- pBetween :: IsParser f => Int -> Int -> f a -> f [a]
- pAtLeast :: IsParser f => Int -> f a -> f [a]
- pAtMost :: IsParser f => Int -> f a -> f [a]
- pCount :: (IsParser p, Num b) => p a -> p b
- pAny :: IsParser p => (a -> p a1) -> [a] -> p a1

# Some aliases for oft occurring constructs

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

is defined for upwards compatibility`pReturn`

pFail :: Alternative p => p a Source

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

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

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

) variant

## Recognising list like structures

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

# Recognising list structures with separators

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_ng :: 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_ng :: IsParser p => p (c -> c -> c) -> p c -> p c Source

## Treating the operator as left associative

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