fixplate-0.1: Uniplate-style generic traversals for fixed-point types, with some extras.

Data.Generics.Fixplate.Zipper

Contents

Description

The Zipper.

Synopsis

Types

type Node f = Either (Mu f) (Path f)Source

data Path f Source

Constructors

Top 
Path 

Fields

unPath :: f (Node f)
 

Instances

EqF f => Eq (Path f) 
ReadF f => Read (Path f) 
ShowF f => Show (Path f) 

data Loc f Source

Constructors

Loc 

Fields

focus :: Mu f
 
path :: Path f
 

Instances

EqF f => Eq (Loc f) 
ReadF f => Read (Loc f) 
ShowF f => Show (Loc f) 

Converting to and from zippers

root :: Mu f -> Loc fSource

Creates a zipper from a tree, with the focus at the root.

defocus :: Traversable f => Loc f -> Mu fSource

Restores a tree from a zipper.

locForget :: Functor f => Loc (Ann f a) -> Loc fSource

The zipper version of forget.

Manipulating the subtree at focus

extract :: Loc f -> Mu fSource

replace :: Mu f -> Loc f -> Loc fSource

modify :: (Mu f -> Mu f) -> Loc f -> Loc fSource

Safe movements

moveDown :: Traversable f => Int -> Loc f -> Maybe (Loc f)Source

Moves down the child with the given index. The leftmost children has index 0.

moveDownL :: Traversable f => Loc f -> Maybe (Loc f)Source

Moves down the leftmost child.

moveDownR :: Traversable f => Loc f -> Maybe (Loc f)Source

Moves down the rightmost child.

Testing for borders

isTop :: Loc f -> BoolSource

Checks whether we are the top.

isBottom :: Traversable f => Loc f -> BoolSource

Checks whether we cannot move down.

Compound movements

moveTop :: Traversable f => Loc f -> Loc fSource

Moves to the top, by repeatedly moving up.

leftmost :: Traversable f => Loc f -> Loc fSource

Moves left until it can.

rightmost :: Traversable f => Loc f -> Loc fSource

Moves right until it can.

Unsafe movements