|
|
|
|
|
Description |
This module ported from Text.XML.Light.Cursor
XML cursors for working XML content withing the context of
an XML document. This implementation is based on the general
tree zipper written by Krasimir Angelov and Iavor S. Diatchki.
With the exception of modifyContentM, then M-suffixed functions are
for use with monadic node types, as used when dealing with chunked I/O
with the hexpat-iteratee package. In the more common pure case, you
wouldn't need these *M functions.
|
|
Synopsis |
|
type Cursor tag text = CursorG NodeG [] tag text | | data CursorG n c tag text = Cur {} | | type Path tag text = PathG NodeG [] tag text | | type PathG n c tag text = [(c (n c tag text), Tag tag text, c (n c tag text))] | | data Tag tag text = Tag {} | | getTag :: Node tag text -> Tag tag text | | fromTag :: MkElementClass n c => Tag tag text -> c (n c tag text) -> n c tag text | | fromTree :: List c => n c tag text -> CursorG n c tag text | | fromForest :: NodeClass n [] => [n [] tag text] -> Maybe (CursorG n [] tag text) | | toForest :: MkElementClass n c => CursorG n c tag text -> c (n c tag text) | | toTree :: MkElementClass n c => CursorG n c tag text -> n c tag text | | parent :: MkElementClass n c => CursorG n c tag text -> Maybe (CursorG n c tag text) | | root :: MkElementClass n c => CursorG n c tag text -> CursorG n c tag text | | getChild :: (NodeClass n [], Monoid tag) => Int -> CursorG n [] tag text -> Maybe (CursorG n [] tag text) | | getChildM :: (NodeClass n c, Monoid tag) => Int -> CursorG n c tag text -> ItemM c (Maybe (CursorG n c tag text)) | | firstChild :: (NodeClass n [], Monoid tag) => CursorG n [] tag text -> Maybe (CursorG n [] tag text) | | firstChildM :: (NodeClass n c, Monoid tag) => CursorG n c tag text -> ItemM c (Maybe (CursorG n c tag text)) | | lastChild :: (NodeClass n [], Monoid tag) => CursorG n [] tag text -> Maybe (CursorG n [] tag text) | | lastChildM :: (NodeClass n c, Monoid tag) => CursorG n c tag text -> ItemM c (Maybe (CursorG n c tag text)) | | left :: CursorG n [] tag text -> Maybe (CursorG n [] tag text) | | leftM :: List c => CursorG n c tag text -> ItemM c (Maybe (CursorG n c tag text)) | | right :: CursorG n [] tag text -> Maybe (CursorG n [] tag text) | | rightM :: List c => CursorG n c tag text -> ItemM c (Maybe (CursorG n c tag text)) | | nextDF :: (MkElementClass n [], Monoid tag) => CursorG n [] tag text -> Maybe (CursorG n [] tag text) | | nextDFM :: (MkElementClass n c, Monoid tag) => CursorG n c tag text -> ItemM c (Maybe (CursorG n c tag text)) | | findChild :: (NodeClass n [], Monoid tag) => (CursorG n [] tag text -> Bool) -> CursorG n [] tag text -> Maybe (CursorG n [] tag text) | | findLeft :: NodeClass n [] => (CursorG n [] tag text -> Bool) -> CursorG n [] tag text -> Maybe (CursorG n [] tag text) | | findRight :: (CursorG n [] tag text -> Bool) -> CursorG n [] tag text -> Maybe (CursorG n [] tag text) | | findRec :: (MkElementClass n [], Monoid tag) => (CursorG n [] tag text -> Bool) -> CursorG n [] tag text -> Maybe (CursorG n [] tag text) | | findRecM :: (MkElementClass n c, Monoid tag) => (CursorG n c tag text -> ItemM c Bool) -> CursorG n c tag text -> ItemM c (Maybe (CursorG n c tag text)) | | isRoot :: CursorG n c tag text -> Bool | | isFirst :: CursorG n [] tag text -> Bool | | isFirstM :: List c => CursorG n c tag text -> ItemM c Bool | | isLast :: CursorG n [] tag text -> Bool | | isLastM :: List c => CursorG n c tag text -> ItemM c Bool | | isLeaf :: (NodeClass n c, Monoid tag) => CursorG n c tag text -> Bool | | isChild :: CursorG n c tag text -> Bool | | hasChildren :: (NodeClass n c, Monoid tag) => CursorG n c tag text -> Bool | | getNodeIndex :: CursorG n [] tag text -> Int | | setContent :: n c tag text -> CursorG n c tag text -> CursorG n c tag text | | modifyContent :: (n c tag text -> n c tag text) -> CursorG n c tag text -> CursorG n c tag text | | modifyContentList :: NodeClass n [] => (n [] tag text -> [n [] tag text]) -> CursorG n [] tag text -> Maybe (CursorG n [] tag text) | | modifyContentListM :: NodeClass n c => (n c tag text -> c (n c tag text)) -> CursorG n c tag text -> ItemM c (Maybe (CursorG n c tag text)) | | modifyContentM :: Monad m => (n [] tag text -> m (n [] tag text)) -> CursorG n [] tag text -> m (CursorG n [] tag text) | | insertLeft :: List c => n c tag text -> CursorG n c tag text -> CursorG n c tag text | | insertRight :: List c => n c tag text -> CursorG n c tag text -> CursorG n c tag text | | insertManyLeft :: List c => c (n c tag text) -> CursorG n c tag text -> CursorG n c tag text | | insertManyRight :: List c => c (n c tag text) -> CursorG n c tag text -> CursorG n c tag text | | insertFirstChild :: NodeClass n c => n c tag text -> CursorG n c tag text -> Maybe (CursorG n c tag text) | | insertLastChild :: NodeClass n c => n c tag text -> CursorG n c tag text -> Maybe (CursorG n c tag text) | | insertManyFirstChild :: NodeClass n c => c (n c tag text) -> CursorG n c tag text -> Maybe (CursorG n c tag text) | | insertManyLastChild :: NodeClass n c => c (n c tag text) -> CursorG n c tag text -> Maybe (CursorG n c tag text) | | insertGoLeft :: List c => n c tag text -> CursorG n c tag text -> CursorG n c tag text | | insertGoRight :: List c => n c tag text -> CursorG n c tag text -> CursorG n c tag text | | removeLeft :: CursorG n [] tag text -> Maybe (n [] tag text, CursorG n [] tag text) | | removeLeftM :: List c => CursorG n c tag text -> ItemM c (Maybe (n c tag text, CursorG n c tag text)) | | removeRight :: CursorG n [] tag text -> Maybe (n [] tag text, CursorG n [] tag text) | | removeRightM :: List c => CursorG n c tag text -> ItemM c (Maybe (n c tag text, CursorG n c tag text)) | | removeGoLeft :: CursorG n [] tag text -> Maybe (CursorG n [] tag text) | | removeGoLeftM :: List c => CursorG n c tag text -> ItemM c (Maybe (CursorG n c tag text)) | | removeGoRight :: CursorG n [] tag text -> Maybe (CursorG n [] tag text) | | removeGoRightM :: List c => CursorG n c tag text -> ItemM c (Maybe (CursorG n c tag text)) | | removeGoUp :: MkElementClass n c => CursorG n c tag text -> Maybe (CursorG n c tag text) |
|
|
|
Types
|
|
|
A cursor specific to Text.XML.Expat.Tree.Node trees.
|
|
data CursorG n c tag text | Source |
|
Generalized cursor: The position of a piece of content in an XML document.
n is the Node type and c is the list type, which would usually be [],
except when you're using chunked I/O.
| Constructors | Cur | | current :: n c tag text | The currently selected content.
| lefts :: c (n c tag text) | Siblings on the left, closest first.
| rights :: c (n c tag text) | Siblings on the right, closest first.
| parents :: PathG n c tag text | The contexts of the parent elements of this location.
|
|
| Instances | |
|
|
|
A path specific to Text.XML.Expat.Tree.Node trees.
|
|
type PathG n c tag text = [(c (n c tag text), Tag tag text, c (n c tag text))] | Source |
|
Generalized path within an XML document.
|
|
|
Constructors | | Instances | |
|
|
|
|
|
|
Conversions
|
|
|
A cursor for the given content.
|
|
|
The location of the first tree in a forest - pure version.
|
|
|
Computes the forest containing this location.
|
|
|
Computes the tree containing this location.
|
|
Moving around
|
|
|
The parent of the given location.
|
|
|
The top-most parent of the given location.
|
|
|
The child with the given index (starting from 0). - pure version.
|
|
|
The child with the given index (starting from 0) - used for monadic node types.
|
|
|
The first child of the given location - pure version.
|
|
|
The first child of the given location - used for monadic node types.
|
|
|
The last child of the given location - pure version.
|
|
|
The last child of the given location - used for monadic node types.
|
|
|
The left sibling of the given location - pure version.
|
|
|
The left sibling of the given location - used for monadic node types.
|
|
|
The right sibling of the given location - pure version.
|
|
|
The right sibling of the given location - used for monadic node types.
|
|
|
The next position in a left-to-right depth-first traversal of a document:
either the first child, right sibling, or the right sibling of a parent that
has one. Pure version.
|
|
|
The next position in a left-to-right depth-first traversal of a document:
either the first child, right sibling, or the right sibling of a parent that
has one. Used for monadic node types.
|
|
Searching
|
|
|
The first child that satisfies a predicate - pure version.
|
|
|
Find the next left sibling that satisfies a predicate.
|
|
|
Find the next right sibling that satisfies a predicate - pure version.
|
|
|
Perform a depth first search for a descendant that satisfies the
given predicate. Pure version.
|
|
|
Perform a depth first search for a descendant that satisfies the
given predicate. Used for monadic node types.
|
|
Node classification
|
|
|
Are we at the top of the document?
|
|
|
Are we at the left end of the the document? (Pure version.)
|
|
|
Are we at the left end of the the document? (Used for monadic node types.)
|
|
|
Are we at the right end of the document? (Pure version.)
|
|
|
Are we at the right end of the document? (Used for monadic node types.)
|
|
|
Are we at the bottom of the document?
|
|
|
Do we have a parent?
|
|
|
Do we have children?
|
|
|
Get the node index inside the sequence of children - pure version.
|
|
Updates
|
|
|
Change the current content.
|
|
modifyContent :: (n c tag text -> n c tag text) -> CursorG n c tag text -> CursorG n c tag text | Source |
|
Modify the current content.
|
|
|
Modify the current content - pure version.
|
|
|
Modify the current content - used for monadic node types.
|
|
modifyContentM :: Monad m => (n [] tag text -> m (n [] tag text)) -> CursorG n [] tag text -> m (CursorG n [] tag text) | Source |
|
Modify the current content, allowing for an effect.
|
|
Inserting content
|
|
|
Insert content to the left of the current position.
|
|
|
Insert content to the right of the current position.
|
|
|
Insert content to the left of the current position.
|
|
|
Insert content to the right of the current position.
|
|
|
Insert content as the first child of the current position.
|
|
|
Insert content as the first child of the current position.
|
|
|
Insert content as the first child of the current position.
|
|
|
Insert content as the first child of the current position.
|
|
|
Insert content to the left of the current position.
The new content becomes the current position.
|
|
|
Insert content to the right of the current position.
The new content becomes the current position.
|
|
Removing content
|
|
|
Remove the content on the left of the current position, if any - pure version.
|
|
|
Remove the content on the left of the current position, if any - used for monadic node types.
|
|
|
Remove the content on the right of the current position, if any - pure version.
|
|
|
Remove the content on the left of the current position, if any - used for monadic node types.
|
|
|
Remove the current element.
The new position is the one on the left. Pure version.
|
|
|
Remove the current element.
The new position is the one on the left. Pure version.
|
|
|
Remove the current element.
The new position is the one on the right. Pure version.
|
|
|
Remove the current element.
The new position is the one on the right. Used for monadic node types.
|
|
|
Remove the current element.
The new position is the parent of the old position.
|
|
Produced by Haddock version 2.6.1 |