hexml-lens-0.2.1: Lenses for the hexml package

Safe HaskellNone





_children :: Getter Node [Node] Source #

Getter for the element children

class XML s where Source #

Minimal complete definition

textContents, iattributes, nodes


_XML :: Prism' s Node Source #

A prism for parsing and unparsing XML.

unparsing is provided by outer.

>>> "<?xml version=\"1.0\"?><foo/>" ^? _XML
Just Node "<?xml version=\"1.0\"?><foo/>"

Nameless nodes are inserted for trees with >1 root.

>>> "<?xml version=\"1.0\"?><foo/>" ^? _XML.to name
Just ""
>>> "<?xml version=\"1.0\"?><foo/>" ^? _XML._children.ix(0)
Just Node "<?xml version=\"1.0\"?>"
>>> "<?xml version=\"1.0\"?><foo/>" ^? _XML._children.ix(1)
Just Node "<foo/>"

If the tree has only 1 root, no nameless nodes are inserted.

>>> "<foo/>" ^? _XML.re(_XML @String)._XML.to name
Just "foo"

The law x ^? re _XML . _XML == x doesn't hold for the nameless nodes injected by parse.

>>> parse "<foo/>" ^? _Right.to name
Just ""
>>> parse "<foo/>" ^? _Right.re(_XML @String)._XML.to name
Just "foo"

_contents :: Fold Node (Either s Node) Source #

Fold over all the children (text and element)

_inner :: Getter Node s Source #

Getter for the inner contents of a node

_outer :: Getter Node s Source #

Getter for the inner contents of a node

textContents :: Fold Node s Source #

Fold for accessing the text contents of a node

_Attribute :: s -> Getter Node (Maybe s) Source #

Fold for accessing attributes by name.

iattributes :: IndexedFold String Node s Source #

Name-Indexed fold over the attribute values

nodes :: s -> Getter Node [Node] Source #

A getter for accessing named children nodes This is a more efficient version of

nodes foo = _children . to (filter (\n -> name n == foo))


XML String Source # 
XML ByteString Source # 
XML ByteString Source # 
XML String Source # 
XML Text Source # 
XML Text Source # 

node :: XML s => s -> Fold Node Node Source #

node n = nodes n . folded