Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- type XmlParser s a = Parser (Tag s) a
- type TagParser s a = Parser (Tag s) a
- data TagPred s a
- satisfyPred :: TagPred s a -> TagParser s a
- true :: TagPred s ()
- getTag :: TagPred s (Tag s)
- isTagOpen :: TagPred s ()
- isTagOpenName :: Eq s => s -> TagPred s ()
- isTagClose :: TagPred s ()
- isTagCloseName :: Eq s => s -> TagPred s ()
- isTagText :: TagPred s ()
- isTagComment :: TagPred s ()
- tagOpenName :: TagPred s s
- tagText :: TagPred s s
- tag :: Eq s => s -> TagPred s ()
- hasAttr :: (Show s, Eq s, StringLike s) => s -> s -> TagPred s ()
- getAttr :: (Show s, Eq s, StringLike s) => s -> TagPred s s
- maybeAttr :: (Show s, Eq s, StringLike s) => s -> TagPred s (Maybe s)
- ignore :: Eq s => XmlParser s ()
- ignoreAny :: Eq s => XmlParser s ()
- ignoreText :: XmlParser s ()
- ignoreTag :: Eq s => XmlParser s ()
- ignoreAnyM :: (Eq s, Monoid m) => XmlParser s m
- cut :: Eq s => TagPred s a -> XmlParser s a
- findAll :: Eq s => XmlParser s a -> XmlParser s [a]
- findIgnore :: Eq s => XmlParser s a -> XmlParser s (Maybe a)
- findFirst :: Eq s => XmlParser s a -> XmlParser s a
- text :: Eq s => XmlParser s s
- join :: Eq s => TagPred s a -> (a -> XmlParser s b) -> XmlParser s b
- joinP :: Eq s => TagPred s a -> XmlParser s b -> XmlParser s (a, b)
- joinR :: Eq s => TagPred s a -> XmlParser s b -> XmlParser s b
- joinL :: Eq s => TagPred s a -> XmlParser s b -> XmlParser s a
- (>^>) :: Eq s => TagPred s a -> (a -> XmlParser s b) -> XmlParser s b
- (<^>) :: Eq s => TagPred s a -> XmlParser s b -> XmlParser s (a, b)
- (^>) :: Eq s => TagPred s a -> XmlParser s b -> XmlParser s b
- (<^) :: Eq s => TagPred s a -> XmlParser s b -> XmlParser s a
- (>/>) :: Eq s => TagPred s a -> (a -> XmlParser s b) -> XmlParser s [b]
- (</>) :: Eq s => TagPred s a -> XmlParser s b -> XmlParser s (a, [b])
- (/>) :: Eq s => TagPred s a -> XmlParser s b -> XmlParser s [b]
- (</) :: Eq s => TagPred s a -> XmlParser s b -> XmlParser s a
- (//>) :: Eq s => TagPred s a -> TagParser s b -> TagParser s [b]
- (<#>) :: (Eq s, Monoid m) => TagPred s a -> XmlParser s m -> XmlParser s (a, m)
- (#>) :: (Eq s, Monoid m) => TagPred s a -> XmlParser s m -> XmlParser s m
- (##>) :: (Eq s, Monoid m) => TagPred s a -> TagParser s m -> TagParser s m
- parseTags :: StringLike s => s -> [Tag s]
- tagsParseXml :: StringLike s => XmlParser s b -> [Tag s] -> b
- parseXml :: StringLike s => XmlParser s b -> s -> b
- elemTags :: Eq s => XmlParser s [Tag s]
- collTags :: Eq s => XmlParser s [Tag s]
- many_ :: Alternative f => f a -> f ()
- escapeXml :: StringLike str => str -> str
- module Text.ParserCombinators.Poly.Lazy
Types
A tag predicate checks if the tag (HTML element) satisfies some
properties and extracts attribute values. You can compose tag predicates
using Applicative and Alternative operators: *>
, <*
, <|>
etc.
Tag predicates
satisfyPred :: TagPred s a -> TagParser s a Source #
Make a tag parser from the tag predicate.
isTagOpenName :: Eq s => s -> TagPred s () Source #
Check if the tag is an open tag and matches the given name.
isTagClose :: TagPred s () Source #
Check if the HTML element is a closing tag.
isTagCloseName :: Eq s => s -> TagPred s () Source #
Check if the tag is a closing tag and matches the given name.
isTagComment :: TagPred s () Source #
Test if the tag is a text node.
tagOpenName :: TagPred s s Source #
Get name of the open tag.
hasAttr :: (Show s, Eq s, StringLike s) => s -> s -> TagPred s () Source #
Check if the tag has the given attribute with the given value.
getAttr :: (Show s, Eq s, StringLike s) => s -> TagPred s s Source #
Get attribute value from the open tag.
maybeAttr :: (Show s, Eq s, StringLike s) => s -> TagPred s (Maybe s) Source #
Get attribute value from the open tag or Nothing, if the attribute is not present.
XML parsing combinators
ignoreText :: XmlParser s () Source #
Ignore text element.
ignoreAnyM :: (Eq s, Monoid m) => XmlParser s m Source #
Version of the ignoreAny function with a monoid result type.
cut :: Eq s => TagPred s a -> XmlParser s a Source #
Parse XML element using the given tag predicate and ignore contents of the element.
findAll :: Eq s => XmlParser s a -> XmlParser s [a] Source #
Parse a list of XML elements and collect all values retrieved with a given parser.
findIgnore :: Eq s => XmlParser s a -> XmlParser s (Maybe a) Source #
Find first XML element accepted be the given parser and ignore the rest of elements in the collection.
findFirst :: Eq s => XmlParser s a -> XmlParser s a Source #
Find fist XML element accepted by the given parser. TODO: Change type to XmlParser s (Maybe a)?
join :: Eq s => TagPred s a -> (a -> XmlParser s b) -> XmlParser s b Source #
Combine the tag parser with the XML parser which will be used to parse contents of the tag element.
joinP :: Eq s => TagPred s a -> XmlParser s b -> XmlParser s (a, b) Source #
Combine the tag parser with the XML parser which will be used to parse contents of the tag element. Parsing results will be returned in a form of a pair.
joinR :: Eq s => TagPred s a -> XmlParser s b -> XmlParser s b Source #
Combine the tag parser with the XML parser which will be used to parse contents of the tag element. Only results of the XML parser will be returned.
joinL :: Eq s => TagPred s a -> XmlParser s b -> XmlParser s a Source #
Combine the tag parser with the XML parser which will be used to parse contents of the tag element. Only results of the tag parser will be returned.
(>^>) :: Eq s => TagPred s a -> (a -> XmlParser s b) -> XmlParser s b infixr 2 Source #
Infix version of the join combinators.
(<^>) :: Eq s => TagPred s a -> XmlParser s b -> XmlParser s (a, b) infixr 2 Source #
Infix version of the joinP combinators.
(^>) :: Eq s => TagPred s a -> XmlParser s b -> XmlParser s b infixr 2 Source #
Infix version of the joinR combinators.
(<^) :: Eq s => TagPred s a -> XmlParser s b -> XmlParser s a infixr 2 Source #
Infix version of the joinL combinators.
XPath-like combinators
(>/>) :: Eq s => TagPred s a -> (a -> XmlParser s b) -> XmlParser s [b] infixr 2 Source #
Combine the tag parser with the XML parser. The XML parser can depend on the value of tag parser and will be called multiple times for tag children elements.
(</>) :: Eq s => TagPred s a -> XmlParser s b -> XmlParser s (a, [b]) infixr 2 Source #
Combine the tag parser with the XML parser. The XML parser will be called multiple times for tag children elements.
(/>) :: Eq s => TagPred s a -> XmlParser s b -> XmlParser s [b] infixr 2 Source #
Combine the tag parser with the XML parser. The XML parser will be called multiple times for tag children elements. Only results of XML parsing will be returned.
(</) :: Eq s => TagPred s a -> XmlParser s b -> XmlParser s a infixr 2 Source #
Combine the tag parser with the XML parser. The XML parser will be called multiple times for tag children elements. Only results of the tag parser will be returned.
(//>) :: Eq s => TagPred s a -> TagParser s b -> TagParser s [b] infixr 2 Source #
Similar to />
combinator but runs the XML parser for all
descendant XML elements, not only for its children.
(<#>) :: (Eq s, Monoid m) => TagPred s a -> XmlParser s m -> XmlParser s (a, m) infixr 2 Source #
Combinators with results concatenation.
Similar to </>
combinator but additionaly concatenates XML
parser results.
(#>) :: (Eq s, Monoid m) => TagPred s a -> XmlParser s m -> XmlParser s m infixr 2 Source #
Similar to />
combinator but additionaly concatenates XML
parser results.
(##>) :: (Eq s, Monoid m) => TagPred s a -> TagParser s m -> TagParser s m infixr 2 Source #
Similar to //>
combinator but additionaly concatenates XML
parser results.
Parsing
parseTags :: StringLike s => s -> [Tag s] Source #
Parser the given string to the list of tags.
tagsParseXml :: StringLike s => XmlParser s b -> [Tag s] -> b Source #
Parser the given tag list with the given XML parser.
parseXml :: StringLike s => XmlParser s b -> s -> b Source #
Parser the given string with the given XML parser.
collTags :: Eq s => XmlParser s [Tag s] Source #
Retrieve tags related to a collection of XML elements.
Utilities
many_ :: Alternative f => f a -> f () Source #
Many combinator which ignores parsing results.
escapeXml :: StringLike str => str -> str Source #
Escape XML string.