Safe Haskell | None |
---|---|
Language | Haskell98 |
A zipper for navigating and modifying XML trees. This is nearly the
same exposed interface as the xml
package in Text.XML.Light.Cursor
,
with modifications as needed to adapt to different types.
- data Cursor
- fromNode :: Node -> Cursor
- fromNodes :: [Node] -> Maybe Cursor
- topNode :: Cursor -> Node
- topNodes :: Cursor -> [Node]
- current :: Cursor -> Node
- siblings :: Cursor -> [Node]
- parent :: Cursor -> Maybe Cursor
- root :: Cursor -> Cursor
- getChild :: Int -> Cursor -> Maybe Cursor
- firstChild :: Cursor -> Maybe Cursor
- lastChild :: Cursor -> Maybe Cursor
- left :: Cursor -> Maybe Cursor
- right :: Cursor -> Maybe Cursor
- nextDF :: Cursor -> Maybe Cursor
- findChild :: (Cursor -> Bool) -> Cursor -> Maybe Cursor
- findLeft :: (Cursor -> Bool) -> Cursor -> Maybe Cursor
- findRight :: (Cursor -> Bool) -> Cursor -> Maybe Cursor
- findRec :: (Cursor -> Bool) -> Cursor -> Maybe Cursor
- isRoot :: Cursor -> Bool
- isFirst :: Cursor -> Bool
- isLast :: Cursor -> Bool
- isLeaf :: Cursor -> Bool
- isChild :: Cursor -> Bool
- hasChildren :: Cursor -> Bool
- getNodeIndex :: Cursor -> Int
- setNode :: Node -> Cursor -> Cursor
- modifyNode :: (Node -> Node) -> Cursor -> Cursor
- modifyNodeM :: Functor m => (Node -> m Node) -> Cursor -> m Cursor
- insertLeft :: Node -> Cursor -> Cursor
- insertRight :: Node -> Cursor -> Cursor
- insertManyLeft :: [Node] -> Cursor -> Cursor
- insertManyRight :: [Node] -> Cursor -> Cursor
- insertFirstChild :: Node -> Cursor -> Maybe Cursor
- insertLastChild :: Node -> Cursor -> Maybe Cursor
- insertManyFirstChild :: [Node] -> Cursor -> Maybe Cursor
- insertManyLastChild :: [Node] -> Cursor -> Maybe Cursor
- insertGoLeft :: Node -> Cursor -> Cursor
- insertGoRight :: Node -> Cursor -> Cursor
- removeLeft :: Cursor -> Maybe (Node, Cursor)
- removeRight :: Cursor -> Maybe (Node, Cursor)
- removeGoLeft :: Cursor -> Maybe Cursor
- removeGoRight :: Cursor -> Maybe Cursor
- removeGoUp :: Cursor -> Maybe Cursor
Cursor type
Conversion to and from cursors
siblings :: Cursor -> [Node] Source
Retrieves a list of the Node
s at the same level as the current position
of a cursor, including the current node.
Cursor navigation
getChild :: Int -> Cursor -> Maybe Cursor Source
Navigates a Cursor
down to the indicated child index.
nextDF :: Cursor -> Maybe Cursor Source
Moves a Cursor
to the next node encountered in a depth-first search.
If it has children, this is equivalent to firstChild
. Otherwise, if it
has a right sibling, then this is equivalent to right
. Otherwise, the
cursor moves to the first right sibling of one of its parents.
Search
findChild :: (Cursor -> Bool) -> Cursor -> Maybe Cursor Source
Navigates a Cursor
to the first child that matches the predicate.
findLeft :: (Cursor -> Bool) -> Cursor -> Maybe Cursor Source
Navigates a Cursor
to the nearest left sibling that matches a
predicate.
findRight :: (Cursor -> Bool) -> Cursor -> Maybe Cursor Source
Navigates a Cursor
to the nearest right sibling that matches a
predicate.
findRec :: (Cursor -> Bool) -> Cursor -> Maybe Cursor Source
Does a depth-first search for a descendant matching the predicate. This can match the current cursor position.
Node classification
isChild :: Cursor -> Bool Source
Determines if the Cursor
is at a child node (i.e., if it has a parent).
hasChildren :: Cursor -> Bool Source
Determines if the Cursor
is at a non-leaf node (i.e., if it has
children).
getNodeIndex :: Cursor -> Int Source
Gets the index of the Cursor
among its siblings.
Updates
modifyNode :: (Node -> Node) -> Cursor -> Cursor Source
Modifies the current node by applying a function.
modifyNodeM :: Functor m => (Node -> m Node) -> Cursor -> m Cursor Source
Modifies the current node by applying an action in some functor.
Insertions
insertLeft :: Node -> Cursor -> Cursor Source
Inserts a new Node
to the left of the current position.
insertRight :: Node -> Cursor -> Cursor Source
Inserts a new Node
to the right of the current position.
insertManyLeft :: [Node] -> Cursor -> Cursor Source
Inserts a list of new Node
s to the left of the current position.
insertManyRight :: [Node] -> Cursor -> Cursor Source
Inserts a list of new Node
s to the right of the current position.
insertFirstChild :: Node -> Cursor -> Maybe Cursor Source
Inserts a Node
as the first child of the current element.
insertLastChild :: Node -> Cursor -> Maybe Cursor Source
Inserts a Node
as the last child of the current element.
insertManyFirstChild :: [Node] -> Cursor -> Maybe Cursor Source
Inserts a list of Node
s as the first children of the current element.
insertManyLastChild :: [Node] -> Cursor -> Maybe Cursor Source
Inserts a list of Node
s as the last children of the current element.
insertGoLeft :: Node -> Cursor -> Cursor Source
Inserts a new Node
to the left of the current position, and moves
left to the new node.
insertGoRight :: Node -> Cursor -> Cursor Source
Inserts a new Node
to the right of the current position, and moves
right to the new node.
Deletions
removeLeft :: Cursor -> Maybe (Node, Cursor) Source
Removes the Node
to the left of the current position, if any.
removeRight :: Cursor -> Maybe (Node, Cursor) Source
Removes the Node
to the right of the current position, if any.
removeGoLeft :: Cursor -> Maybe Cursor Source
Removes the current Node
, and moves the Cursor to its left sibling,
if any.