-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Simple monad for parsing DOM -- -- Simple monad for parsing DOM @package dom-parser @version 0.0.1 module Text.XML.DOM.Parser data ParserData ParserData :: !Cursor -> !Axis -> ![Text] -> ParserData -- | Cursor to current parser's environment [_pdCursor] :: ParserData -> !Cursor -- | Context axis to follow deeper [_pdAxis] :: ParserData -> !Axis -- | Path for errors [_pdPath] :: ParserData -> ![Text] pdCursor :: Lens' ParserData Cursor pdAxis :: Lens' ParserData Axis pdPath :: Lens' ParserData [Text] -- | DOM parser error description. data ParserError -- | Tag not found which should be. PENotFound :: ![Text] -> ParserError -- | path of element [_pePath] :: ParserError -> ![Text] -- | Tag contents has wrong format, (could not read text to value) PEWrongFormat :: ![Text] -> Text -> ParserError -- | path of element [_pePath] :: ParserError -> ![Text] [_peDetails] :: ParserError -> Text -- | Such tag name is not expected in this place PEWrongTagName :: ![Text] -> !Text -> ParserError -- | path of element [_pePath] :: ParserError -> ![Text] [_peDetails] :: ParserError -> !Text -- | Node is not an element but should be PENotElement :: ![Text] -> ParserError -- | path of element [_pePath] :: ParserError -> ![Text] -- | Node should have text content, but it does not. PEContentNotFound :: ![Text] -> ParserError -- | path of element [_pePath] :: ParserError -> ![Text] -- | Any other error PEOther :: ![Text] -> !Text -> ParserError -- | path of element [_pePath] :: ParserError -> ![Text] [_peDetails] :: ParserError -> !Text pePath :: Lens' ParserError [Text] peDetails :: Traversal' ParserError Text newtype ParserErrors ParserErrors :: [ParserError] -> ParserErrors [unParserErrors] :: ParserErrors -> [ParserError] throwParserError :: ([Text] -> ParserError) -> DomParser a -- | Render path for showing error renderPath :: [Text] -> String -- | Parser monad where all parsing actions live type DomParser = ExceptT [ParserError] (Reader ParserData) -- | Run parser on root element of Document. runDomParser :: Document -> DomParser a -> Either [ParserError] a -- | Content parser type. Parser is just a function taking Text and -- returning either error description or successfully parsed value. type ContentParser a = Text -> Either Text a -- | Always successfully parses any DOM to () unitFromDom :: DomParser () -- | Never parses successfully. It is just mzero voidFromDom :: DomParser Void -- | Does not strip content. Returns content unmodified. textFromContent :: ContentParser Text -- | Does not strip content. Returns content unmodified. stringFromContent :: ContentParser String -- | Expects content to be a singe non-blank character. Blank characters -- are stripped to parse pretty-printed XML files. charFromContent :: ContentParser Char intFromContent :: ContentParser Int integerFromContent :: ContentParser Integer doubleFromContent :: ContentParser Double fixedFromContent :: (HasResolution a, Typeable a) => ContentParser (Fixed a) -- | Expects content to be y, yes, t, true or 1 for True value. n, no, f, -- false or 0 for False value. Case is not significant, blank characters -- are striped. boolFromContent :: ContentParser Bool -- | Typeclass for structures which may be parsed from XML DOM. Usually you -- should pass parsing function explicitly to combinators like -- inElem, maybeInElem or inTags , but sometimes you -- need term search. Especially when you try to parse polymorphic types. -- Or you maybe generate parser with TH for your types, so typeclass -- would be convenient also. class FromDom a fromDom :: FromDom a => DomParser a -- | Usually you should pass ContentParser to combinators like -- elemContent or maybeElemContent explicitly. But -- sometimes you need term search. Especially for code generated with TH. class FromContent a -- | Should return either error message (what was wrong) or parsed value fromContent :: FromContent a => ContentParser a -- | Find first element with given name in current element and run parser -- inside of found element. Throws PENotFound error if element not found. inElem :: Text -> DomParser a -> DomParser a -- | Find all elements with gievn name in current element and run parser -- inside of this elements. inElems :: Text -> DomParser a -> DomParser [a] nonEmptyInElems :: Text -> DomParser a -> DomParser (NonEmpty a) -- | Try to find element with given name and run parser inside of it. If -- not found return Nothing maybeInElem :: Text -> DomParser a -> DomParser (Maybe a) -- | Generic elements combinator. Takes predicate filtering/converting list -- of cursors to some traversable (with posible filtering and/or -- reordering) inElemsPred :: (Traversable f) => ([Cursor] -> f Cursor) -> Text -> DomParser a -> DomParser (f a) -- | Run parser within axis context. Expected to not use directly. inAxis :: [Text] -> Axis -> DomParser a -> DomParser a -- | Given parser will match tag in arbitrary deepness inDescendants :: DomParser a -> DomParser a -- | Given parser will match inside specific inTags :: [Text] -> DomParser a -> DomParser a tryCurrentContent :: ContentParser a -> DomParser (Maybe a) -- | Get concatenated text from current parser's node(s). If current -- context have no Content nodes then return Nothing. tryCurrentContentText :: DomParser (Maybe Text) currentContent :: ContentParser a -> DomParser a -- | Return the name of current cursor we staying in. Return Nothing -- if we are not staying on element node tryCurrentName :: DomParser (Maybe Name) -- | Return name of current element the parser in. currentName :: DomParser Name tryCurrentAttr :: Text -> DomParser (Maybe Text) -- | Take attribute from current node (if it is an element). Throws -- PENotFound or PENotElement currentAttr :: Text -> DomParser Text elemContent :: Text -> ContentParser a -> DomParser a nonEmptyElemsContent :: Text -> ContentParser a -> DomParser (NonEmpty a) elemsContent :: Text -> ContentParser a -> DomParser [a] maybeElemContent :: Text -> ContentParser a -> DomParser (Maybe a) fromContentR :: (Read a, Typeable a) => Text -> Either Text a -- | Helper newtype returning currentContent for any type with -- instance FromContent newtype CurrentContent a CurrentContent :: a -> CurrentContent a [unCurrentContent] :: CurrentContent a -> a -- | Get children nodes from current parser's node. currentNodes :: DomParser [Node] -- | Throw PEWrongTagName if name of current element does not match -- with given. checkCurrentLaxName :: Text -> DomParser () -- | Run predicate with current tag name. Parser fails if predicate -- returned (Just msg) or node is not an element. checkCurrentName :: (Name -> Maybe Text) -> DomParser () instance GHC.Generics.Selector Text.XML.DOM.Parser.S1_0_0CurrentContent instance GHC.Generics.Constructor Text.XML.DOM.Parser.C1_0CurrentContent instance GHC.Generics.Datatype Text.XML.DOM.Parser.D1CurrentContent instance GHC.Generics.Generic (Text.XML.DOM.Parser.CurrentContent a) instance GHC.Show.Show a => GHC.Show.Show (Text.XML.DOM.Parser.CurrentContent a) instance GHC.Classes.Eq a => GHC.Classes.Eq (Text.XML.DOM.Parser.CurrentContent a) instance GHC.Classes.Ord a => GHC.Classes.Ord (Text.XML.DOM.Parser.CurrentContent a) instance (Text.XML.DOM.Parser.ParserErrors ~ t0) => Control.Lens.Wrapped.Rewrapped Text.XML.DOM.Parser.ParserErrors t0 instance Control.Lens.Wrapped.Wrapped Text.XML.DOM.Parser.ParserErrors instance GHC.Exception.Exception Text.XML.DOM.Parser.ParserErrors instance Text.XML.DOM.Parser.FromDom () instance Text.XML.DOM.Parser.FromContent Data.Text.Internal.Text instance Text.XML.DOM.Parser.FromContent GHC.Base.String instance Text.XML.DOM.Parser.FromContent GHC.Types.Char instance Text.XML.DOM.Parser.FromContent GHC.Types.Int instance Text.XML.DOM.Parser.FromContent GHC.Integer.Type.Integer instance Text.XML.DOM.Parser.FromContent GHC.Types.Double instance (Data.Fixed.HasResolution a, Data.Typeable.Internal.Typeable a) => Text.XML.DOM.Parser.FromContent (Data.Fixed.Fixed a) instance Text.XML.DOM.Parser.FromContent GHC.Types.Bool instance Text.XML.DOM.Parser.FromContent a => Text.XML.DOM.Parser.FromDom (Text.XML.DOM.Parser.CurrentContent a) instance GHC.Generics.Selector Text.XML.DOM.Parser.S1_0_0ParserErrors instance GHC.Generics.Constructor Text.XML.DOM.Parser.C1_0ParserErrors instance GHC.Generics.Datatype Text.XML.DOM.Parser.D1ParserErrors instance GHC.Generics.Generic Text.XML.DOM.Parser.ParserErrors instance GHC.Show.Show Text.XML.DOM.Parser.ParserErrors instance GHC.Classes.Eq Text.XML.DOM.Parser.ParserErrors instance GHC.Classes.Ord Text.XML.DOM.Parser.ParserErrors instance GHC.Generics.Selector Text.XML.DOM.Parser.S1_0_2ParserData instance GHC.Generics.Selector Text.XML.DOM.Parser.S1_0_1ParserData instance GHC.Generics.Selector Text.XML.DOM.Parser.S1_0_0ParserData instance GHC.Generics.Constructor Text.XML.DOM.Parser.C1_0ParserData instance GHC.Generics.Datatype Text.XML.DOM.Parser.D1ParserData instance GHC.Generics.Generic Text.XML.DOM.Parser.ParserData instance GHC.Exception.Exception Text.XML.DOM.Parser.ParserError instance GHC.Generics.Selector Text.XML.DOM.Parser.S1_5_1ParserError instance GHC.Generics.Selector Text.XML.DOM.Parser.S1_5_0ParserError instance GHC.Generics.Selector Text.XML.DOM.Parser.S1_4_0ParserError instance GHC.Generics.Selector Text.XML.DOM.Parser.S1_3_0ParserError instance GHC.Generics.Selector Text.XML.DOM.Parser.S1_2_1ParserError instance GHC.Generics.Selector Text.XML.DOM.Parser.S1_2_0ParserError instance GHC.Generics.Selector Text.XML.DOM.Parser.S1_1_1ParserError instance GHC.Generics.Selector Text.XML.DOM.Parser.S1_1_0ParserError instance GHC.Generics.Selector Text.XML.DOM.Parser.S1_0_0ParserError instance GHC.Generics.Constructor Text.XML.DOM.Parser.C1_5ParserError instance GHC.Generics.Constructor Text.XML.DOM.Parser.C1_4ParserError instance GHC.Generics.Constructor Text.XML.DOM.Parser.C1_3ParserError instance GHC.Generics.Constructor Text.XML.DOM.Parser.C1_2ParserError instance GHC.Generics.Constructor Text.XML.DOM.Parser.C1_1ParserError instance GHC.Generics.Constructor Text.XML.DOM.Parser.C1_0ParserError instance GHC.Generics.Datatype Text.XML.DOM.Parser.D1ParserError instance GHC.Generics.Generic Text.XML.DOM.Parser.ParserError instance GHC.Show.Show Text.XML.DOM.Parser.ParserError instance GHC.Classes.Ord Text.XML.DOM.Parser.ParserError instance GHC.Classes.Eq Text.XML.DOM.Parser.ParserError