pire-0.2.5

Copyright(c) Andreas Reuleaux 2015 - 2018
LicenseBSD2
MaintainerAndreas Reuleaux <rx@a-rx.info>
Stabilityexperimental
Portabilitynon-portable
Safe HaskellNone
LanguageHaskell2010

Zipper1

Description

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 [Crumb] to reconstruct the original syntax tree.

we need to wrap modules, declarations, expressions etc in a common data structure Term1, very similar to the Terms used later, but we allow BindingTriples as well here. White space is not taken into account here, but that would certainly be possible.

Synopsis

Documentation

data Crumb a Source #

Constructors

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 (Lam nm an scope): if going to the binder nm, keep the the type annotation and body (scope) in the Crumb

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

for a LamPAs nms scope: if choosing a binder x, keep the other binders (triples ie.) and the body

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) 
Instances
Show a => Show (Crumb a) Source # 
Instance details

Defined in Zipper1

Methods

showsPrec :: Int -> Crumb a -> ShowS #

show :: Crumb a -> String #

showList :: [Crumb a] -> ShowS #

type Zipper1 a = (Term1 a a, [Crumb a]) Source #

binder1 :: Refactoring m => Int -> Zipper1 a -> m (Zipper1 a) Source #

binding1 :: Refactoring m => (Term1 a a, [Crumb a]) -> m (Term1 a a, [Crumb a]) Source #

decl1 :: Refactoring m => Int -> Zipper1 a -> m (Zipper1 a) Source #

up1 :: (Refactoring m, Eq a) => Zipper1 a -> m (Zipper1 a) Source #

go up

top1 :: (Eq a, Refactoring m) => Zipper1 a -> m (Zipper1 a) Source #

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

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