Copyright | (c) Andreas Reuleaux 2015 - 2018 |
---|---|

License | BSD2 |

Maintainer | Andreas Reuleaux <rx@a-rx.info> |

Stability | experimental |

Portability | non-portable |

Safe Haskell | None |

Language | Haskell2010 |

a first implementation of a *zippers* (navigate through *modules*, *declarations*, *expressions*, etc.),
following closely the approach in the *Zippers* chapter of *Learn You a Haskell* (http://learnyouahaskell.com/zippers),
i.e. using a list of breadcrumbs `[`

to reconstruct the original syntax tree.`Crumb`

]

we need to wrap *modules*, *declarations*, *expressions* etc in a common data structure

,
very similar to the `Term1`

s used later, but we allow `Term`

s as well here.
White space is not taken into account here, but that would certainly be possible.`BindingTriple`

## Synopsis

- data Crumb a
- = AppLeftCrumb (Expr a a)
- | AppRightCrumb (Expr a a)
- | DefLeftCrumb (Expr a a)
- | DefRightCrumb a
- | LamBinderCrumb (Annot a a) (Expr a a)
- | LamPAsBinderCrumb [BindingTriple a a] [BindingTriple a a] (Expr a a)
- | LamBodyCrumb a (Annot a a)
- | LamPAsBodyCrumb [BindingTriple a a]
- | ParenCrumb
- | PositionCrumb Delta
- | SndOfTripleCrumb Eps (Annot a a)
- | NameOfBinderCrumb
- | DeclCrumb a [Decl a a] [Decl a a] (ConstructorNames a)

- maybe1 :: Term1 a a -> Maybe (Zipper1 a)
- either1 :: Term1 a a -> Either RefactorError (Zipper1 a)
- type Zipper1 a = (Term1 a a, [Crumb a])
- left1 :: Refactoring m => Zipper1 a -> m (Zipper1 a)
- right1 :: Refactoring m => Zipper1 a -> m (Zipper1 a)
- body1 :: Refactoring m => Zipper1 a -> m (Zipper1 a)
- binder1 :: Refactoring m => Int -> Zipper1 a -> m (Zipper1 a)
- binding1 :: Refactoring m => (Term1 a a, [Crumb a]) -> m (Term1 a a, [Crumb a])
- decl1 :: Refactoring m => Int -> Zipper1 a -> m (Zipper1 a)
- up1 :: (Refactoring m, Eq a) => Zipper1 a -> m (Zipper1 a)
- top1 :: (Eq a, Refactoring m) => Zipper1 a -> m (Zipper1 a)
- focus1 :: Refactoring m => (a, t) -> m a
- breadcrumbs1 :: Refactoring m => (a, t) -> m t

# Documentation

AppLeftCrumb (Expr a a) | |

AppRightCrumb (Expr a a) | |

DefLeftCrumb (Expr a a) | go to the left of a decl, thus keep the rhs in the crumb |

DefRightCrumb a | go to the right of a decl, thus keep the lhs in the crumb |

LamBinderCrumb (Annot a a) (Expr a a) | for a simple lambda ( |

LamPAsBinderCrumb [BindingTriple a a] [BindingTriple a a] (Expr a a) | for a |

LamBodyCrumb a (Annot a a) | simple Lam, choosing the body, store away the binder and the type annotation |

LamPAsBodyCrumb [BindingTriple a a] | LamPAs, choosing the body, store away the binder triples |

ParenCrumb | enter paren (nothing to save in addition) |

PositionCrumb Delta | |

SndOfTripleCrumb Eps (Annot a a) | choosing the binder of a triple |

NameOfBinderCrumb | choosing the binder of a triple |

DeclCrumb a [Decl a a] [Decl a a] (ConstructorNames a) |

focus1 :: Refactoring m => (a, t) -> m a Source #

breadcrumbs1 :: Refactoring m => (a, t) -> m t Source #