1{-# OPTIONS_GHC -Wall #-}
2module Transform.Substitute (subst) where
4import SourceSyntax.Expression
5import SourceSyntax.Location
6import Control.Arrow (second, (***))
8subst :: String -> Expr t v -> Expr t v -> Expr t v
10 let f (L t s e) = L t s (subst old new e) in
12 Range e1 e2 -> Range (f e1) (f e2)
13 ExplicitList es -> ExplicitList (map f es)
14 Binop op e1 e2 -> Binop op (f e1) (f e2)
15 Lambda p e -> Lambda p (f e)
16 App e1 e2 -> App (f e1) (f e2)
17 MultiIf ps -> MultiIf (map (f *** f) ps)
18 Let defs body -> Let (map substDef defs) (f body)
19 where substDef (Def name e) = Def name (f e)
20 substDef anno@(TypeAnnotation _ _) = anno
21 Var x -> if x == old then new else expr
22 Case e cases -> Case (f e) $ map (second f) cases
23 Data name es -> Data name (map f es)
24 Access e x -> Access (f e) x
25 Remove e x -> Remove (f e) x
26 Insert e x v -> Insert (f e) x (f v)
27 Modify r fs -> Modify (f r) (map (second f) fs)
28 Record fs -> Record (map (second f) fs)
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list