Copyright | (c) 2008--2009 Universiteit Utrecht |
---|---|
License | BSD3 |
Maintainer | generics@haskell.org |
Stability | experimental |
Portability | non-portable |
Safe Haskell | Safe-Inferred |
Language | Haskell98 |
The generic zipper.
- data Loc :: (* -> *) -> (* -> *) -> * -> * where
- data Ctxs :: (* -> *) -> * -> (* -> *) -> * -> * where
- data family Ctx f :: * -> (* -> *) -> * -> *
- 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
- impossible :: a -> b
Locations and context stacks
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.
Zipper phi f => HFunctor phi (Ctx f b) | |
data Ctx U | |
data Ctx (I xi) where | |
data Ctx (K a) | |
data Ctx ((:+:) f g) | |
data Ctx ((:*:) f g) | |
data Ctx ((:>:) f xi) where | |
data Ctx ((:.:) [] g) = CCL [g r ix] (Ctx g b r ix) [g r ix] | |
data Ctx ((:.:) Maybe g) = CCM (Ctx g b r ix) | |
data Ctx (C c f) = CC (Ctx f b r ix) |
Contexts and locations are functors
Generic navigation functions
class HFunctor phi f => Zipper phi 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.
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 ix Source
first, last :: (forall b. phi b -> r b -> Ctx f b r ix -> a) -> f r ix -> Maybe a Source
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 Source
Zipper phi U | |
Zipper phi (K a) | |
El phi xi => Zipper phi (I xi) | |
(Constructor c, Zipper phi f) => Zipper phi (C c f) | |
Zipper phi f => Zipper phi ((:>:) f xi) | |
Zipper phi g => Zipper phi ((:.:) Maybe g) | |
Zipper phi g => Zipper phi ((:.:) [] g) | |
(Zipper phi f, Zipper phi g) => Zipper phi ((:*:) f g) | |
(Zipper phi f, Zipper phi g) => Zipper phi ((:+:) f g) |
Internal functions
impossible :: a -> b Source