elynx-tree-0.6.0.0: Handle phylogenetic trees
Copyright(c) Dominik Schrempf 2021
LicenseGPL-3.0-or-later
Maintainerdominik.schrempf@gmail.com
Stabilityunstable
Portabilityportable
Safe HaskellNone
LanguageHaskell2010

ELynx.Tree.Zipper

Description

Creation date: Thu Jul 23 08:42:37 2020.

Synopsis

Data type

data TreePos e a Source #

Tree zipper. For reference, please see http://hackage.haskell.org/package/rosezipper.

Constructors

Pos 

Fields

Instances

Instances details
(Eq e, Eq a) => Eq (TreePos e a) Source # 
Instance details

Defined in ELynx.Tree.Zipper

Methods

(==) :: TreePos e a -> TreePos e a -> Bool #

(/=) :: TreePos e a -> TreePos e a -> Bool #

(Show e, Show a) => Show (TreePos e a) Source # 
Instance details

Defined in ELynx.Tree.Zipper

Methods

showsPrec :: Int -> TreePos e a -> ShowS #

show :: TreePos e a -> String #

showList :: [TreePos e a] -> ShowS #

Conversion

fromTree :: Tree e a -> TreePos e a Source #

Get a zipper pointing to the root.

toTree :: TreePos e a -> Tree e a Source #

Get the complete tree of the zipper.

Movement

goParent :: TreePos e a -> Maybe (TreePos e a) Source #

Go to parent.

goParentUnsafe :: TreePos e a -> TreePos e a Source #

Go to parent.

Call error if no parent is found.

goRoot :: TreePos e a -> TreePos e a Source #

Go to root.

goLeft :: TreePos e a -> Maybe (TreePos e a) Source #

Go to left sibling in current forest.

goRight :: TreePos e a -> Maybe (TreePos e a) Source #

Go to right sibling in current forest.

goChild :: Int -> TreePos e a -> Maybe (TreePos e a) Source #

Go to child with given index in forest.

goChildUnsafe :: Int -> TreePos e a -> TreePos e a Source #

Go to child with given index in forest. Call error if child does not exist.

Paths

type Path = [Int] Source #

Path from the root of a tree to the node of the tree.

The position is specific to a tree topology. If the topology changes, the position becomes invalid.

goPath :: Path -> TreePos e a -> Maybe (TreePos e a) Source #

Go to node with given path.

goPathUnsafe :: Path -> TreePos e a -> TreePos e a Source #

Got to node with given path.

Call error if path is invalid.

getSubTreeUnsafe :: Path -> Tree e a -> Tree e a Source #

Get the sub tree at path.

Call error if path is invalid.

isValidPath :: Tree e a -> Path -> Bool Source #

Check if a path is valid in that it leads to a node on a tree.

isLeafPath :: Tree e a -> Path -> Bool Source #

Check if a path leads to a leaf.

Modification

insertTree :: Tree e a -> TreePos e a -> TreePos e a Source #

Insert a new tree into the current focus of the zipper.

modifyTree :: (Tree e a -> Tree e a) -> TreePos e a -> TreePos e a Source #

Modify the tree at the current focus of the zipper.

insertBranch :: e -> TreePos e a -> TreePos e a Source #

Insert a new branch label into the current focus of the zipper.

insertLabel :: a -> TreePos e a -> TreePos e a Source #

Insert a new node label into the current focus of the zipper.