Safe Haskell | Safe-Infered |
---|
- data Zipper st b
- data Top a
- data (st :> b) c
- class Hist st a c
- zipper :: a -> Zipper Top a
- close :: Hist st a b => Zipper st b -> a
- move :: Monad m => LensM m b c -> Zipper st b -> m (Zipper (st :> b) c)
- moveP :: (b :-> c) -> Zipper st b -> Zipper (st :> b) c
- moveUp :: Zipper (st :> b) c -> Zipper st b
- focus :: Zipper st b :-> b
- setf :: Zipper st b -> b -> Zipper st b
- modf :: (b -> b) -> Zipper st b -> Zipper st b
Documentation
We provide a simple, heterogenous, fully type-checked, generic zipper implementation. This flavor of zipper doesn't use "left" and "right" for navigation, and instead relies on lenses to indicate a child type to "move to".
Zipper type
Our zipper type, parameterized by a focus
and "history stack",
supporting completely type-checked zipper operations.
Zipper history
Zipper operations
close :: Hist st a b => Zipper st b -> aSource
exit the zipper, rebuilding the structure a
:
close (Zipper st b) = runHist st b
Motions
moveP :: (b :-> c) -> Zipper st b -> Zipper (st :> b) cSource
navigate to a child element indicated by the passed pure lens
moveP l = runIdentity . move l
moveUp :: Zipper (st :> b) c -> Zipper st bSource
navigate up a level in a zipper not already at Top
moveUp (Zipper (Snoc st cont) c) = Zipper st $ cont c