Control.Arrow.ArrowNavigatableTree

hxt-9.3.1.16: A collection of tools for processing XML with Haskell.

Copyright | Copyright (C) 2010 Uwe Schmidt
License | MIT
Maintainer | Uwe Schmidt (uwe\@fh-wedel.de)
Stability | experimental
Portability | portable
Safe Haskell | Safe
Language | Haskell98

Control.Arrow.ArrowNavigatableTree

Description

List arrows for navigatable trees

Trees that implement the Data.Tree.NavigatableTree.Class interface, can be processed with these arrows.

Synopsis

- class ArrowList a => ArrowNavigatableTree a where
- parentAxis :: (ArrowList a, NavigatableTree t) => a (t b) (t b)
- ancestorAxis :: (ArrowList a, NavigatableTree t) => a (t b) (t b)
- ancestorOrSelfAxis :: (ArrowList a, NavigatableTree t) => a (t b) (t b)
- childAxis :: (ArrowList a, NavigatableTree t) => a (t b) (t b)
- descendantAxis :: (ArrowList a, NavigatableTree t) => a (t b) (t b)
- descendantOrSelfAxis :: (ArrowList a, NavigatableTree t) => a (t b) (t b)
- descendantOrFollowingAxis :: (ArrowList a, NavigatableTree t) => a (t b) (t b)
- revDescendantOrSelfAxis :: (ArrowList a, NavigatableTree t) => a (t b) (t b)
- followingSiblingAxis :: (ArrowList a, NavigatableTree t) => a (t b) (t b)
- precedingSiblingAxis :: (ArrowList a, NavigatableTree t) => a (t b) (t b)
- selfAxis :: (ArrowList a, NavigatableTree t) => a (t b) (t b)
- followingAxis :: (ArrowList a, NavigatableTree t) => a (t b) (t b)
- precedingAxis :: (ArrowList a, NavigatableTree t) => a (t b) (t b)
- moveToRoot :: (Arrow a, NavigatableTree t) => a (t b) (t b)
- isAtRoot :: (ArrowList a, NavigatableTree t) => a (t b) (t b)
- addNav :: (ArrowList a, NavigatableTreeToTree nt t) => a (t b) (nt b)
- remNav :: (ArrowList a, NavigatableTreeToTree nt t) => a (nt b) (t b)
- withNav :: (ArrowList a, NavigatableTreeToTree nt t) => a (nt b) (nt c) -> a (t b) (t c)
- withoutNav :: (ArrowList a, NavigatableTreeToTree nt t, NavigatableTreeModify nt t) => a (t b) (t b) -> a (nt b) (nt b)
- filterAxis :: (ArrowIf a, NavigatableTreeToTree nt t) => a (t b) c -> a (nt b) (nt b)
- moveOn :: (ArrowList a, NavigatableTree t) => a (t b) (t b) -> a (t b) (t b)
- changeThisTree :: (ArrowList a, ArrowIf a, NavigatableTreeToTree nt t, NavigatableTreeModify nt t) => a (t b) (t b) -> a (nt b) (nt b)
- substThisTree :: (ArrowList a, ArrowIf a, NavigatableTreeToTree nt t, NavigatableTreeModify nt t) => t b -> a (nt b) (nt b)
- addToTheLeft :: (ArrowList a, NavigatableTreeToTree nt t, NavigatableTreeModify nt t) => a (t b) (t b) -> a (nt b) (nt b)
- addToTheRight :: (ArrowList a, NavigatableTreeToTree nt t, NavigatableTreeModify nt t) => a (t b) (t b) -> a (nt b) (nt b)
- addToOneSide :: (ArrowList a, NavigatableTreeToTree nt t, NavigatableTreeModify nt t) => (Maybe (nt b) -> [t b] -> Maybe (nt b)) -> a (t b) (t b) -> a (nt b) (nt b)
- dropFromTheLeft :: (ArrowList a, NavigatableTreeModify nt t) => a (nt b) (nt b)
- dropFromTheRight :: (ArrowList a, NavigatableTreeModify nt t) => a (nt b) (nt b)

# Documentation

class ArrowList a => ArrowNavigatableTree a where #

The interface for navigatable tree arrows

all functions have default implementations

Methods

moveUp :: NavigatableTree t => a (t b) (t b) #

moveDown :: NavigatableTree t => a (t b) (t b) #

moveLeft :: NavigatableTree t => a (t b) (t b) #

moveRight :: NavigatableTree t => a (t b) (t b) #

Instances

ArrowNavigatableTree LA # |
Methods moveUp :: NavigatableTree t => LA (t b) (t b) # moveDown :: NavigatableTree t => LA (t b) (t b) # moveLeft :: NavigatableTree t => LA (t b) (t b) # moveRight :: NavigatableTree t => LA (t b) (t b) #
ArrowNavigatableTree IOLA # |
Methods moveUp :: NavigatableTree t => IOLA (t b) (t b) # moveDown :: NavigatableTree t => IOLA (t b) (t b) # moveLeft :: NavigatableTree t => IOLA (t b) (t b) # moveRight :: NavigatableTree t => IOLA (t b) (t b) #
ArrowNavigatableTree (SLA s) # |
Methods moveUp :: NavigatableTree t => SLA s (t b) (t b) # moveDown :: NavigatableTree t => SLA s (t b) (t b) # moveLeft :: NavigatableTree t => SLA s (t b) (t b) # moveRight :: NavigatableTree t => SLA s (t b) (t b) #
ArrowNavigatableTree (IOSLA s) # |
Methods moveUp :: NavigatableTree t => IOSLA s (t b) (t b) # moveDown :: NavigatableTree t => IOSLA s (t b) (t b) # moveLeft :: NavigatableTree t => IOSLA s (t b) (t b) # moveRight :: NavigatableTree t => IOSLA s (t b) (t b) #

parentAxis :: (ArrowList a, NavigatableTree t) => a (t b) (t b) #

ancestorAxis :: (ArrowList a, NavigatableTree t) => a (t b) (t b) #

XPath axis: ancestor

ancestorOrSelfAxis :: (ArrowList a, NavigatableTree t) => a (t b) (t b) #

XPath axis: ancestor or self

childAxis :: (ArrowList a, NavigatableTree t) => a (t b) (t b) #

XPath axis: child

descendantAxis :: (ArrowList a, NavigatableTree t) => a (t b) (t b) #

XPath axis: descendant

descendantOrSelfAxis :: (ArrowList a, NavigatableTree t) => a (t b) (t b) #

XPath axis: descendant or self

descendantOrFollowingAxis :: (ArrowList a, NavigatableTree t) => a (t b) (t b) #

not an XPath axis but useful: descendant or following

revDescendantOrSelfAxis :: (ArrowList a, NavigatableTree t) => a (t b) (t b) #

not an official XPath axis but useful: reverse descendant or self, used in preceding axis

followingSiblingAxis :: (ArrowList a, NavigatableTree t) => a (t b) (t b) #

XPath axis: following sibling

precedingSiblingAxis :: (ArrowList a, NavigatableTree t) => a (t b) (t b) #

XPath axis: preceeding sibling

selfAxis :: (ArrowList a, NavigatableTree t) => a (t b) (t b) #

XPath axis: self

followingAxis :: (ArrowList a, NavigatableTree t) => a (t b) (t b) #

XPath axis: following

precedingAxis :: (ArrowList a, NavigatableTree t) => a (t b) (t b) #

XPath axis: preceding

moveToRoot :: (Arrow a, NavigatableTree t) => a (t b) (t b) #

move to the root

isAtRoot :: (ArrowList a, NavigatableTree t) => a (t b) (t b) #

addNav :: (ArrowList a, NavigatableTreeToTree nt t) => a (t b) (nt b) #

Conversion from a tree into a navigatable tree

remNav :: (ArrowList a, NavigatableTreeToTree nt t) => a (nt b) (t b) #

Conversion from a navigatable tree into an ordinary tree

withNav :: (ArrowList a, NavigatableTreeToTree nt t) => a (nt b) (nt c) -> a (t b) (t c) #

apply an operation using navigation to an ordinary tree

This root and all children may be visited in arbitrary order

withoutNav :: (ArrowList a, NavigatableTreeToTree nt t, NavigatableTreeModify nt t) => a (t b) (t b) -> a (nt b) (nt b) #

apply a simple operation without use of navigation to a navigatable tree

This enables to apply arbitrary tree operations to navigatable trees

filterAxis :: (ArrowIf a, NavigatableTreeToTree nt t) => a (t b) c -> a (nt b) (nt b) #

Filter an axis with an ordinary tree predicate

Example: In a tree of Ints find all nodes in the subtrees (in preorder) that have label 42

    descendantAxis >>> filterAxis (hasNode (== 42))

Example: In an XML Tree find the following nodes of a node with attribute id and value 42

    descendantAxis >>> filterAxis (hasAttrValue "id" (=="42")) >>> followingAxis

moveOn :: (ArrowList a, NavigatableTree t) => a (t b) (t b) -> a (t b) (t b) #

Move to the next tree on a given axis. Deterministic arrow

Example: Move to the next node in a preorder visit: next child or else next following

    moveOn descendantOrFollowingAxis

changeThisTree :: (ArrowList a, ArrowIf a, NavigatableTreeToTree nt t, NavigatableTreeModify nt t) => a (t b) (t b) -> a (nt b) (nt b) #

Change the current subtree of a navigatable tree.

The arrow for computing the changes should be deterministic. If it fails nothing is changed.

substThisTree :: (ArrowList a, ArrowIf a, NavigatableTreeToTree nt t, NavigatableTreeModify nt t) => t b -> a (nt b) (nt b) #

Substitute the current subtree of a navigatable tree by a given tree

addToTheLeft :: (ArrowList a, NavigatableTreeToTree nt t, NavigatableTreeModify nt t) => a (t b) (t b) -> a (nt b) (nt b) #

apply an ordinary arrow to the current subtree of a navigatabe tree and add the result trees in front of the current tree.

If this arrow is applied to the root, it will fail, because we want a tree as result, not a forest.

addToTheRight :: (ArrowList a, NavigatableTreeToTree nt t, NavigatableTreeModify nt t) => a (t b) (t b) -> a (nt b) (nt b) #

apply an ordinary arrow to the current subtree of a navigatabe tree and add the result trees behind the current tree.

If this arrow is applied to the root, it will fail, because we want a tree as result, not a forest.

addToOneSide :: (ArrowList a, NavigatableTreeToTree nt t, NavigatableTreeModify nt t) => (Maybe (nt b) -> [t b] -> Maybe (nt b)) -> a (t b) (t b) -> a (nt b) (nt b) #

addToOneSide does the real work for `addToTheLeft` and `addToTheRight`

dropFromTheLeft :: (ArrowList a, NavigatableTreeModify nt t) => a (nt b) (nt b) #

drop the direct left sibling tree of the given navigatable tree

If this arrow is applied to the root or a leftmost tree, it will fail, because there is nothing to remove

dropFromTheRight :: (ArrowList a, NavigatableTreeModify nt t) => a (nt b) (nt b) #

drop the direct left sibling tree of the given navigatable tree

If this arrow is applied to the root or a rightmost tree, it will fail, because there is nothing to remove