Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- parseByteString :: Element a -> ByteString -> Either Text a
- parseLazyByteString :: Element a -> ByteString -> Either Text a
- parseFile :: Element a -> FilePath -> IO (Either Text a)
- parseElementAst :: Element a -> Element -> Either Text a
- data Element a
- elementName :: (Maybe Text -> Text -> Either Text a) -> Element a
- elementNameIs :: Maybe Text -> Text -> Element ()
- children :: Nodes a -> Element a
- childrenByName :: ByName Element a -> Element a
- attributesByName :: ByName Content a -> Element a
- astElement :: Element Element
- data Nodes a
- elementNode :: Element a -> Nodes a
- contentNode :: Content content -> Nodes content
- data ByName parser a
- byName :: Maybe Text -> Text -> parser a -> ByName parser a
- data Content content
- textContent :: Content Text
- narrowedContent :: (Text -> Maybe a) -> Content a
- refinedContent :: (Text -> Either Text a) -> Content a
- enumContent :: [(Text, a)] -> Content a
- attoparsedContent :: Parser a -> Content a
- qNameContent :: Content (Maybe Text, Text)
Execution
parseByteString :: Element a -> ByteString -> Either Text a Source #
Parse XML bytestring.
parseLazyByteString :: Element a -> ByteString -> Either Text a Source #
Parse XML lazy bytestring.
parseElementAst :: Element a -> Element -> Either Text a Source #
Parse an "xml-conduit" element AST.
Parsers by context
Element
Parse in the context of an element node.
elementName :: (Maybe Text -> Text -> Either Text a) -> Element a Source #
Parse namespace and name with the given function.
elementNameIs :: Maybe Text -> Text -> Element () Source #
Fail if the namespace and name don't match the provided.
attributesByName :: ByName Content a -> Element a Source #
Look up the last attribute by name and parse it.
astElement :: Element Element Source #
Expose the element's AST.
Nodes
Parser in the context of a sequence of nodes.
elementNode :: Element a -> Nodes a Source #
Consume the next node expecting it to be element and parse its contents.
contentNode :: Content content -> Nodes content Source #
Consume the next node expecting it to be textual and parse its contents.
ByName
Composable extension to a parser, which looks up its input by name.
Useful for searching elements and attributes by name.
Alternative and MonadPlus alternate only on lookup errors. When lookup is successful, but the deeper parser fails, the error propagates.
Monad and Applicative sequentially fetch contents by matching names.
Instances
Alternative (ByName parser) Source # | |
Applicative (ByName parser) Source # | |
Defined in XmlParser.AstParser pure :: a -> ByName parser a # (<*>) :: ByName parser (a -> b) -> ByName parser a -> ByName parser b # liftA2 :: (a -> b -> c) -> ByName parser a -> ByName parser b -> ByName parser c # (*>) :: ByName parser a -> ByName parser b -> ByName parser b # (<*) :: ByName parser a -> ByName parser b -> ByName parser a # | |
Functor (ByName parser) Source # | |
Monad (ByName parser) Source # | |
MonadPlus (ByName parser) Source # | |
byName :: Maybe Text -> Text -> parser a -> ByName parser a Source #
Execute a parser on the result of looking up a content by namespace and name.
Content
Parser in the context of decoded textual content, which can be the value of an attribute or a textual node.
textContent :: Content Text Source #
Return the content as it is.
refinedContent :: (Text -> Either Text a) -> Content a Source #
Parse the content with a possibly failing function.
enumContent :: [(Text, a)] -> Content a Source #
Map the content using a dictionary.
attoparsedContent :: Parser a -> Content a Source #
Parse the content using the "attoparsec" parser.