Annotations-0.2: Constructing, analyzing and destructing annotated trees

Safe HaskellSafe-Infered

Annotations.F.Zipper

Synopsis

Documentation

data Zipper a Source

A quasi-zipper, meant for O(1), fixed-memory stepping through a tree structure, but not meant for updates.

Constructors

Zipper 

Fields

zFocus :: a

The current focus of this zipper.

zUp :: Maybe (Zipper a)

Move up to the parent.

zLeft :: Maybe (Zipper a)

Move to the left sibling.

zRight :: Maybe (Zipper a)

Move to the right sibling.

zDown :: Maybe (Zipper a)

Move down into the leftmost child.

enter :: Foldable f => Fix f -> Zipper (Fix f)Source

Move into the root of the fixed point. The returned zipper builds a data structure with optimal sharing and fixed memory usage. For example, zLeft >=> zRight (if successful) returns to the same node in memory.

leave :: Zipper a -> aSource

Walk back up to the root of the fixed point and leave the zipper structure.

child :: Int -> Zipper a -> Maybe (Zipper a)Source

Move down into a specific child.

allFoci :: Foldable f => Fix f -> [Zipper (Fix f)]Source

Traverses the tree in preorder, yielding all possible tree selections.

newtype Nav Source

Captures navigation steps in a Zipper. Its Monoid instance specifies the identity step (mempty) and step composition (mappend).

Constructors

Nav 

Fields

nav :: forall a. Zipper a -> Maybe (Zipper a)
 

Instances