hextream-0.2.0.0: Streaming-friendly XML parsers

Safe HaskellNone
LanguageHaskell2010

Data.XML.Parser.High.AttrParser

Description

All documentation examples assume the following setup:

:set -XOverloadedStrings
import Data.Attoparsec.ByteString
import Data.XML.Parser.High
Synopsis

Documentation

newtype AttrParser a Source #

How to parse tag attributes.

Constructors

AttrParser 
Instances
Monad AttrParser Source #

Can be combined with >>=. Attributes map is forwarded without change.

Instance details

Defined in Data.XML.Parser.High.AttrParser

Methods

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

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

return :: a -> AttrParser a #

fail :: String -> AttrParser a #

Functor AttrParser Source # 
Instance details

Defined in Data.XML.Parser.High.AttrParser

Methods

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

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

MonadFail AttrParser Source # 
Instance details

Defined in Data.XML.Parser.High.AttrParser

Methods

fail :: String -> AttrParser a #

Applicative AttrParser Source # 
Instance details

Defined in Data.XML.Parser.High.AttrParser

Methods

pure :: a -> AttrParser a #

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

liftA2 :: (a -> b -> c) -> AttrParser a -> AttrParser b -> AttrParser c #

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

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

Alternative AttrParser Source #

Can be combined with <|>

Instance details

Defined in Data.XML.Parser.High.AttrParser

anyAttr :: AttrParser () Source #

Parse any set of attributes.

>>> parseOnly (runTokenParser $ tag' anyName anyAttr noContent) "<tag></tag>"
Right ()
>>> parseOnly (runTokenParser $ tag' anyName anyAttr noContent) "<tag key='value'></tag>"
Right ()

noAttr :: AttrParser () Source #

Assert that no attributes exist.

>>> parseOnly (runTokenParser $ tag' anyName noAttr noContent) "<tag></tag>"
Right ()
>>> parseOnly (runTokenParser $ tag' anyName noAttr noContent) "<tag key='value'></tag>"
Left ...

attrValue :: QName -> AttrParser Text Source #

Parse attribute by name, and return its value.

>>> parseOnly (runTokenParser $ tag' anyName (attrValue "foo") noContent) "<tag></tag>"
Left ...
>>> parseOnly (runTokenParser $ tag' anyName (attrValue "foo") noContent) "<tag foo='bar'></tag>"
Right ()

hasAttr :: QName -> Text -> AttrParser () Source #

Assert that an attribute exists, with given name and value.

>>> parseOnly (runTokenParser $ tag' anyName (hasAttr "foo" "bar") noContent) "<tag></tag>"
Left ...
>>> parseOnly (runTokenParser $ tag' anyName (hasAttr "foo" "bar") noContent) "<tag foo='baz'></tag>"
Left ...
>>> parseOnly (runTokenParser $ tag' anyName (hasAttr "foo" "bar") noContent) "<tag foo='bar'></tag>"
Right ()