Safe Haskell | None |
---|---|
Language | Haskell98 |
- data Loc :: * -> * where
- data family Ctx f :: * -> *
- class Functor f => Zipper f where
- enter :: (Regular a, Zipper (PF a)) => a -> Loc a
- down :: Loc a -> Maybe (Loc a)
- down' :: Loc a -> Maybe (Loc a)
- up :: Loc a -> Maybe (Loc a)
- right :: Loc a -> Maybe (Loc a)
- left :: Loc a -> Maybe (Loc a)
- leave :: Loc a -> a
- on :: Loc a -> a
- update :: (a -> a) -> Loc a -> Loc a
- updateM :: Monad m => (a -> m a) -> Loc a -> m (Loc a)
Locations
data Loc :: * -> * where Source
Abstract type of locations. A location contains the current focus and its context. A location is parameterized over the family of datatypes and over the type of the complete value.
Context frames
data family Ctx f :: * -> * Source
Abstract type of context frames. Not required for the high-level navigation functions.
Generic zipper class
class Functor f => Zipper f where Source
It is in general not necessary to use the generic navigation functions directly. The functions listed in the ``Interface'' section below are more user-friendly.
Interface
enter :: (Regular a, Zipper (PF a)) => a -> Loc a Source
Start navigating a datastructure. Returns a location that focuses the entire value and has an empty context.
down :: Loc a -> Maybe (Loc a) Source
Move down to the leftmost child. Returns Nothing
if the
current focus is a leaf.
down' :: Loc a -> Maybe (Loc a) Source
Move down to the rightmost child. Returns Nothing
if the
current focus is a leaf.
up :: Loc a -> Maybe (Loc a) Source
Move up to the parent. Returns Nothing
if the current
focus is the root.
right :: Loc a -> Maybe (Loc a) Source
Move to the right sibling. Returns Nothing
if the current
focus is the rightmost sibling.
left :: Loc a -> Maybe (Loc a) Source
Move to the left sibling. Returns Nothing
if the current
focus is the leftmost sibling.
Operate on the current focus. This function can be used to extract the current point of focus.