polysoup-0.6.4: 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 # 
Instance details

Defined in Text.XML.PolySoup.Parser

Methods

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

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

return :: a0 -> P a a0 #

fail :: String -> P a a0 #

Functor (P a) Source # 
Instance details

Defined in Text.XML.PolySoup.Parser

Methods

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

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

Applicative (P a) Source # 
Instance details

Defined in Text.XML.PolySoup.Parser

Methods

pure :: a0 -> P a a0 #

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

liftA2 :: (a0 -> b -> c) -> P a a0 -> P a b -> P a c #

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

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

Alternative (P a) Source # 
Instance details

Defined in Text.XML.PolySoup.Parser

Methods

empty :: P a a0 #

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

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

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

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.