Safe Haskell | None |
---|---|
Language | Haskell2010 |
- data ElemMatcher = ElemMatcher {}
- emMatch :: Lens' ElemMatcher (Element -> Bool)
- emShow :: Lens' ElemMatcher Text
- matchElemName :: NameMatcher -> ElemMatcher
- elMatch :: ElemMatcher -> Traversal' Element Element
- data NameMatcher = NameMatcher {}
- nmMatch :: Lens' NameMatcher (Name -> Bool)
- nmShow :: Lens' NameMatcher Text
- matchName :: Name -> NameMatcher
- matchLocalName :: Text -> NameMatcher
- matchCILocalName :: Text -> NameMatcher
- newtype DomPath = DomPath {}
- data ParserError
- = PENotFound { }
- | PEAttributeNotFound { }
- | PEAttributeWrongFormat { }
- | PEContentNotFound { }
- | PEContentWrongFormat {
- _peDetails :: Text
- _pePath :: DomPath
- | PEOther {
- _peDetails :: Text
- _pePath :: DomPath
- pePath :: Lens' ParserError DomPath
- peDetails :: Traversal' ParserError Text
- peAttributeName :: Traversal' ParserError NameMatcher
- newtype ParserErrors = ParserErrors {}
- _ParserErrors :: Iso' ParserErrors [ParserError]
- data ParserData f = ParserData {
- _pdElements :: f Element
- _pdPath :: DomPath
- pdElements :: forall f f. Lens (ParserData f) (ParserData f) (f Element) (f Element)
- pdPath :: forall f. Lens' (ParserData f) DomPath
- type DomParserT f m = ReaderT (ParserData f) (ExceptT ParserErrors m)
- type DomParser f = DomParserT f Identity
- runDomParserT :: Monad m => Document -> DomParserT Identity m a -> m (Either ParserErrors a)
- runDomParser :: Document -> DomParser Identity a -> Either ParserErrors a
- throwParserError :: (MonadError ParserErrors m, MonadReader (ParserData f) m) => (DomPath -> ParserError) -> m a
Element matching
data ElemMatcher Source #
Arbitrary element matcher
Since: 2.0.0
Show ElemMatcher Source # | |
IsString ElemMatcher Source # | Instance using instance of |
matchElemName :: NameMatcher -> ElemMatcher Source #
Match element by name
Since: 2.0.0
elMatch :: ElemMatcher -> Traversal' Element Element Source #
Match over elements
Since: 2.0.0
Name matching
data NameMatcher Source #
Arbitrary name matcher. Match name any way you want, but considered to be used as comparator with some name with some rules
Since: 2.0.0
Show NameMatcher Source # | |
IsString NameMatcher Source # | Instance use Since: 2.0.0 |
matchName :: Name -> NameMatcher Source #
Makes matcher which match name by Eq
with given
Since: 2.0.0
matchLocalName :: Text -> NameMatcher Source #
Makes matcher which matches only local part of name igoring namespace and prefix. Local name matching is case sensitive.
Since: 2.0.0
matchCILocalName :: Text -> NameMatcher Source #
Makes matcher which matches only local part of name igoring namespace and prefix. Local name matching is case insensitive. This is the most common case.
Since: 2.0.0
Parser internals
Path some element should be found at. Path starts from the root element of the document. Errors are much more usefull with path.
data ParserError Source #
DOM parser error description.
PENotFound | Tag not found which should be. |
PEAttributeNotFound | Expected attribute but not found Since: 1.0.0 |
| |
PEAttributeWrongFormat | Could not parse attribute Since: 1.0.0 |
| |
PEContentNotFound | Node should have text content, but it does not. |
PEContentWrongFormat | Tag contents has wrong format, (could not read text to value) |
| |
PEOther | Some other error |
|
newtype ParserErrors Source #
data ParserData f Source #
Parser scope.
Functor argument is usually Identity
or []
.
If functor is Identity
then parser expects exactly ONE current element. This
is common behavior for content parsers, or parsers expecting strict XML
structure.
If functor is []
then parser expects arbitrary current elements count. This is
the case when you use combinators divePath
or diveElem
(posible other
variants of similar combinators). This kind of combinators performs search for
elements somewhere in descendants and result have arbitrary length in common
case.
ParserData | |
|
pdElements :: forall f f. Lens (ParserData f) (ParserData f) (f Element) (f Element) Source #
type DomParserT f m = ReaderT (ParserData f) (ExceptT ParserErrors m) Source #
type DomParser f = DomParserT f Identity Source #
runDomParserT :: Monad m => Document -> DomParserT Identity m a -> m (Either ParserErrors a) Source #
Run parser on root element of Document.
runDomParser :: Document -> DomParser Identity a -> Either ParserErrors a Source #
Auxiliary
throwParserError :: (MonadError ParserErrors m, MonadReader (ParserData f) m) => (DomPath -> ParserError) -> m a Source #