1module Substitute (subst) where
5import Control.Arrow (second, (***))
7subst :: String -> Expr -> Expr -> Expr
9 let f (L t s e) = L t s (subst old new e) in
11 Range e1 e2 -> Range (f e1) (f e2)
12 Access e x -> Access (f e) x
13 Remove e x -> Remove (f e) x
14 Insert e x v -> Insert (f e) x (f v)
15 Modify r fs -> Modify (f r) (map (second f) fs)
16 Record fs -> Record (map (\(lbl,as,e) -> (lbl,as,f e)) fs)
17 Binop op e1 e2 -> Binop op (f e1) (f e2)
18 Lambda x e -> if x == old then expr else Lambda x (f e)
19 App e1 e2 -> App (f e1) (f e2)
20 If e1 e2 e3 -> If (f e1) (f e2) (f e3)
21 MultiIf ps -> MultiIf (map (f *** f) ps)
22 Let defs e -> Let (map substDef defs) (f e)
23 where substDef (FnDef name vs e) = FnDef name vs (f e)
24 substDef (OpDef op a1 a2 e) = OpDef op a1 a2 (f e)
26 Var x -> if x == old then new else expr
27 Case e cases -> Case (f e) $ map (second f) cases
28 Data name es -> Data name (map f es)
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