Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell98 |
Data.Tree.Zipper
Synopsis
- data TreePos (t :: Type -> Type) a
- class PosType (t :: Type -> Type)
- data Empty a
- data Full a
- before :: forall (t :: Type -> Type) a. PosType t => TreePos t a -> Forest a
- after :: forall (t :: Type -> Type) a. PosType t => TreePos t a -> Forest a
- forest :: forall (t :: Type -> Type) a. PosType t => TreePos t a -> Forest a
- tree :: TreePos Full a -> Tree a
- label :: TreePos Full a -> a
- parents :: forall (t :: Type -> Type) a. PosType t => TreePos t a -> [(Forest a, a, Forest a)]
- fromTree :: Tree a -> TreePos Full a
- fromForest :: Forest a -> TreePos Empty a
- toForest :: forall (t :: Type -> Type) a. PosType t => TreePos t a -> Forest a
- toTree :: TreePos Full a -> Tree a
- parent :: forall (t :: Type -> Type) a. PosType t => TreePos t a -> Maybe (TreePos Full a)
- root :: TreePos Full a -> TreePos Full a
- prevSpace :: TreePos Full a -> TreePos Empty a
- prevTree :: TreePos Empty a -> Maybe (TreePos Full a)
- prev :: forall (t :: Type -> Type) a. PosType t => TreePos t a -> Maybe (TreePos t a)
- first :: TreePos Empty a -> TreePos Empty a
- spaceAt :: Int -> TreePos Empty a -> TreePos Empty a
- nextSpace :: TreePos Full a -> TreePos Empty a
- nextTree :: TreePos Empty a -> Maybe (TreePos Full a)
- next :: forall (t :: Type -> Type) a. PosType t => TreePos t a -> Maybe (TreePos t a)
- last :: TreePos Empty a -> TreePos Empty a
- children :: TreePos Full a -> TreePos Empty a
- firstChild :: TreePos Full a -> Maybe (TreePos Full a)
- lastChild :: TreePos Full a -> Maybe (TreePos Full a)
- childAt :: Int -> TreePos Full a -> Maybe (TreePos Full a)
- isRoot :: forall (t :: Type -> Type) a. PosType t => TreePos t a -> Bool
- isFirst :: forall (t :: Type -> Type) a. PosType t => TreePos t a -> Bool
- isLast :: forall (t :: Type -> Type) a. PosType t => TreePos t a -> Bool
- isLeaf :: TreePos Full a -> Bool
- isContained :: forall (t :: Type -> Type) a. PosType t => TreePos t a -> Bool
- hasChildren :: TreePos Full a -> Bool
- insert :: Tree a -> TreePos Empty a -> TreePos Full a
- delete :: TreePos Full a -> TreePos Empty a
- setTree :: Tree a -> TreePos Full a -> TreePos Full a
- modifyTree :: (Tree a -> Tree a) -> TreePos Full a -> TreePos Full a
- modifyLabel :: (a -> a) -> TreePos Full a -> TreePos Full a
- setLabel :: a -> TreePos Full a -> TreePos Full a
Documentation
data TreePos (t :: Type -> Type) a Source #
A position within a Tree
.
The parameter t
inidcates if the position is pointing to
a specific tree (if t
is Full
), or if it is pointing in-between
trees (if t
is Empty
).
class PosType (t :: Type -> Type) Source #
Minimal complete definition
_prev, _next, _forest
Position which does not point to a tree (e.g., it is between two trees).
Position which points to a tree.
Context
before :: forall (t :: Type -> Type) a. PosType t => TreePos t a -> Forest a Source #
Siblings before this position, closest first.
after :: forall (t :: Type -> Type) a. PosType t => TreePos t a -> Forest a Source #
Siblings after this position, closest first.
forest :: forall (t :: Type -> Type) a. PosType t => TreePos t a -> Forest a Source #
All trees at this location (i.e., the current tree---if any---and its siblings).
parents :: forall (t :: Type -> Type) a. PosType t => TreePos t a -> [(Forest a, a, Forest a)] Source #
The contexts of the parents for this position.
Conversions
fromTree :: Tree a -> TreePos Full a Source #
A location corresponding to the root of the given tree.
fromForest :: Forest a -> TreePos Empty a Source #
The location at the beginning of the forest.
toForest :: forall (t :: Type -> Type) a. PosType t => TreePos t a -> Forest a Source #
The forest containing this location.
Moving around
parent :: forall (t :: Type -> Type) a. PosType t => TreePos t a -> Maybe (TreePos Full a) Source #
The parent of the given location.
prevTree :: TreePos Empty a -> Maybe (TreePos Full a) Source #
The tree before this location, if any.
prev :: forall (t :: Type -> Type) a. PosType t => TreePos t a -> Maybe (TreePos t a) Source #
The sibling before this location.
spaceAt :: Int -> TreePos Empty a -> TreePos Empty a Source #
The empty space at the given index. The first space is at index 0. For indexes that are negative or too large, we return the first and last position in the tree, respectively.
next :: forall (t :: Type -> Type) a. PosType t => TreePos t a -> Maybe (TreePos t a) Source #
The sibling after this location.
children :: TreePos Full a -> TreePos Empty a Source #
The location at the beginning of the forest of children.
firstChild :: TreePos Full a -> Maybe (TreePos Full a) Source #
The first child of the given location.
childAt :: Int -> TreePos Full a -> Maybe (TreePos Full a) Source #
The child at the given index in the tree. The first child is at index 0.
Node classification
isRoot :: forall (t :: Type -> Type) a. PosType t => TreePos t a -> Bool Source #
Are we at the top of the tree?
isFirst :: forall (t :: Type -> Type) a. PosType t => TreePos t a -> Bool Source #
Are we the first position (of its kind) in a forest.
isLast :: forall (t :: Type -> Type) a. PosType t => TreePos t a -> Bool Source #
Are we the last position (of its kind) in a forest.
isContained :: forall (t :: Type -> Type) a. PosType t => TreePos t a -> Bool Source #
Do we have a parent?
hasChildren :: TreePos Full a -> Bool Source #
Do we have children?
Working with the current tree
insert :: Tree a -> TreePos Empty a -> TreePos Full a Source #
Insert a new tree at the current position.
modifyTree :: (Tree a -> Tree a) -> TreePos Full a -> TreePos Full a Source #
Modify the current tree.