polysoup-0.6.3: Online XML parsing with polyparse and tagsoup

Safe HaskellSafe
LanguageHaskell98

Text.XML.PolySoup.Parser

Contents

Description

The module defines a generic parser which can be used, in particular, to parse XML forests. The main characteristic of the parser is that it can be used in a sequential (sub-trees are processed in order) and a selective (subtrees are process regardless of their position) way.

Synopsis

Core

newtype P a b Source #

An XML forest parser.

Constructors

P 

Fields

Instances

Monad (P a) Source # 

Methods

(>>=) :: P a a -> (a -> P a b) -> P a b #

(>>) :: P a a -> P a b -> P a b #

return :: a -> P a a #

fail :: String -> P a a #

Functor (P a) Source # 

Methods

fmap :: (a -> b) -> P a a -> P a b #

(<$) :: a -> P a b -> P a a #

Applicative (P a) Source # 

Methods

pure :: a -> P a a #

(<*>) :: P a (a -> b) -> P a a -> P a b #

(*>) :: P a a -> P a b -> P a b #

(<*) :: P a a -> P a b -> P a a #

Alternative (P a) Source # 

Methods

empty :: P a a #

(<|>) :: P a a -> P a a -> P a a #

some :: P a a -> P a [a] #

many :: P a a -> P a [a] #

evalP :: P a b -> [a] -> Maybe b Source #

Evaluate parser on the given XML forest.

Parsing

Selective

first :: Q a b -> P a b Source #

Find the first tree satisfying the given predicate.

every :: Q a b -> P a [b] Source #

Select every tree satisfying the given predicate.

every' :: Q a b -> P a [b] Source #

A lazy version of every which "forgets" non-matching subtrees along the way.

Sequential

pop :: Q a b -> P a b Source #

Check, if the first tree satisfies the given predicate.

Peek

peek :: Q a b -> P a b Source #

Like pop, but doesn't consume the tree.

spy :: Q a b -> P a b Source #

Like first, but doesn't consume the tree.

Utilities

many_ :: Alternative f => f a -> f () Source #

Many combinator which ignores parsing results.