Safe Haskell | None |
---|---|
Language | Haskell2010 |
- data ParserError
- = PENotFound { }
- | PEWrongFormat {
- _peDetails :: Text
- _pePath :: [Text]
- | PEContentNotFound { }
- | PEOther {
- _peDetails :: Text
- _pePath :: [Text]
- pePath :: Lens' ParserError [Text]
- peDetails :: Traversal' ParserError Text
- newtype ParserErrors = ParserErrors {}
- _ParserErrors :: Iso' ParserErrors [ParserError]
- data ParserData f = ParserData {
- _pdElements :: f Element
- _pdPath :: [Text]
- pdElements :: forall f f. Lens (ParserData f) (ParserData f) (f Element) (f Element)
- pdPath :: forall f. Lens' (ParserData f) [Text]
- 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
- class Traversable f => DomTraversable f where
- throwParserError :: (MonadError ParserErrors m, MonadReader (ParserData f) m) => ([Text] -> ParserError) -> m a
- throwWrongFormat :: (MonadError ParserErrors m, MonadReader (ParserData f) m) => Text -> m a
Parser internals
data ParserError Source #
DOM parser error description.
PENotFound | Tag not found which should be. |
PEWrongFormat | Tag contents has wrong format, (could not read text to value) |
| |
PEContentNotFound | Node should have text content, but it does not. |
PEOther | Some other error |
|
newtype ParserErrors Source #
data ParserData f Source #
Parser scope parser runs in. 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 #
Parser type
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
class Traversable f => DomTraversable f where Source #
Class of traversable functors which may be constructed from list. Or may not.
buildDomTraversable :: [a] -> Maybe (f a) Source #
If method return Nothing this means we can not build traversable from given list. In this case combinator should fail traversing.
throwParserError :: (MonadError ParserErrors m, MonadReader (ParserData f) m) => ([Text] -> ParserError) -> m a Source #
throwWrongFormat :: (MonadError ParserErrors m, MonadReader (ParserData f) m) => Text -> m a Source #
Throw PEWrongFormat
as very common case