Portability | non-portable |
---|---|

Stability | experimental |

Maintainer | generics@haskell.org |

Safe Haskell | Safe-Infered |

The generic zipper.

- data Loc where
- data family Ctx f :: * -> (* -> *) -> * -> *
- data Ctxs where
- class HFunctor phi f => Zipper phi f where
- cmapA :: Applicative a => (forall ix. phi ix -> r ix -> a (r' ix)) -> phi ix -> Ctx f b r ix -> a (Ctx f b r' ix)
- fill :: phi b -> Ctx f b r ix -> r b -> f r ix
- first, last :: (forall b. phi b -> r b -> Ctx f b r ix -> a) -> f r ix -> Maybe a
- next, prev :: (forall b. phi b -> r b -> Ctx f b r ix -> a) -> phi b -> Ctx f b r ix -> r b -> Maybe a

- enter :: Zipper phi f => phi ix -> r ix -> Loc phi f r ix
- on :: (forall xi. phi xi -> r xi -> a) -> Loc phi f r ix -> a
- update :: (forall xi. phi xi -> r xi -> r xi) -> Loc phi f r ix -> Loc phi f r ix

# Locations

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 HFunctor phi f => Zipper phi f whereSource

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.

cmapA :: Applicative a => (forall ix. phi ix -> r ix -> a (r' ix)) -> phi ix -> Ctx f b r ix -> a (Ctx f b r' ix)Source

fill :: phi b -> Ctx f b r ix -> r b -> f r ixSource

first, last :: (forall b. phi b -> r b -> Ctx f b r ix -> a) -> f r ix -> Maybe aSource

next, prev :: (forall b. phi b -> r b -> Ctx f b r ix -> a) -> phi b -> Ctx f b r ix -> r b -> Maybe aSource

# Interface

enter :: Zipper phi f => phi ix -> r ix -> Loc phi f r ixSource

Start navigating a datastructure. Returns a location that focuses the entire value and has an empty context.