uniplate-1.6.13: Help writing simple, concise and fast generic operations.
Safe HaskellNone
LanguageHaskell2010

Data.Generics.Uniplate.Zipper

Description

A zipper is a structure for walking a value and manipulating it in constant time.

This module was inspired by the paper: Michael D. Adams. Scrap Your Zippers: A Generic Zipper for Heterogeneous Types, Workshop on Generic Programming 2010.

Synopsis

Create a zipper and get back the value

data Zipper from to Source #

Zipper structure, whose root type is the first type argument, and whose focus type is the second type argument.

Instances

Instances details
(Eq from, Eq to) => Eq (Zipper from to) Source # 
Instance details

Defined in Data.Generics.Uniplate.Zipper

Methods

(==) :: Zipper from to -> Zipper from to -> Bool #

(/=) :: Zipper from to -> Zipper from to -> Bool #

zipper :: Uniplate to => to -> Zipper to to Source #

Create a zipper, focused on the top-left value.

zipperBi :: Biplate from to => from -> Maybe (Zipper from to) Source #

Create a zipper with a different focus type from the outer type. Will return Nothing if there are no instances of the focus type within the original value.

fromZipper :: Zipper from to -> from Source #

From a zipper take the whole structure, including any modifications.

Navigate within a zipper

left :: Zipper from to -> Maybe (Zipper from to) Source #

Move one step left from the current position.

right :: Zipper from to -> Maybe (Zipper from to) Source #

Move one step right from the current position.

up :: Zipper from to -> Maybe (Zipper from to) Source #

Move one step up from the current position.

down :: Uniplate to => Zipper from to -> Maybe (Zipper from to) Source #

Move one step down from the current position.

Manipulate the zipper hole

hole :: Zipper from to -> to Source #

Retrieve the current focus of the zipper..

replaceHole :: to -> Zipper from to -> Zipper from to Source #

Replace the value currently at the focus of the zipper.