refactoring
This commit is contained in:
parent
07871b1190
commit
2f4ec1c281
|
@ -155,6 +155,25 @@ module Mini_shexp = struct
|
||||||
| Update_file (x, y) -> f (f acc x) y
|
| Update_file (x, y) -> f (f acc x) y
|
||||||
| Rename (x, y) -> f (f acc x) y
|
| Rename (x, y) -> f (f acc x) y
|
||||||
|
|
||||||
|
let fold_one_step t ~init:acc ~f =
|
||||||
|
match t with
|
||||||
|
| Chdir (_, t)
|
||||||
|
| Setenv (_, _, t)
|
||||||
|
| Redirect (_, _, t)
|
||||||
|
| Ignore (_, t) -> f acc t
|
||||||
|
| Progn l -> List.fold_left l ~init:acc ~f
|
||||||
|
| Run _
|
||||||
|
| Echo _
|
||||||
|
| Cat _
|
||||||
|
| Create_file _
|
||||||
|
| Copy _
|
||||||
|
| Symlink _
|
||||||
|
| Copy_and_add_line_directive _
|
||||||
|
| System _
|
||||||
|
| Bash _
|
||||||
|
| Update_file _
|
||||||
|
| Rename _ -> acc
|
||||||
|
|
||||||
let rec map
|
let rec map
|
||||||
: 'a 'b 'c 'd. ('a, 'b) t -> f1:('a -> 'c) -> f2:('b -> 'd) -> ('c, 'd) t
|
: 'a 'b 'c 'd. ('a, 'b) t -> f1:('a -> 'c) -> f2:('b -> 'd) -> ('c, 'd) t
|
||||||
= fun t ~f1 ~f2 ->
|
= fun t ~f1 ~f2 ->
|
||||||
|
@ -191,23 +210,12 @@ module Mini_shexp = struct
|
||||||
|
|
||||||
let updated_files =
|
let updated_files =
|
||||||
let rec loop acc t =
|
let rec loop acc t =
|
||||||
match t with
|
let acc =
|
||||||
| Update_file (fn, _) -> Path.Set.add fn acc
|
match t with
|
||||||
| Chdir (_, t)
|
| Update_file (fn, _) -> Path.Set.add fn acc
|
||||||
| Setenv (_, _, t)
|
| _ -> acc
|
||||||
| Redirect (_, _, t)
|
in
|
||||||
| Ignore (_, t) -> loop acc t
|
Ast.fold_one_step t ~init:acc ~f:loop
|
||||||
| Progn l -> List.fold_left l ~init:acc ~f:loop
|
|
||||||
| Run _ -> acc
|
|
||||||
| Echo _
|
|
||||||
| Cat _
|
|
||||||
| Create_file _
|
|
||||||
| Copy _
|
|
||||||
| Symlink _
|
|
||||||
| Copy_and_add_line_directive _
|
|
||||||
| System _
|
|
||||||
| Bash _
|
|
||||||
| Rename _ -> acc
|
|
||||||
in
|
in
|
||||||
fun t -> loop Path.Set.empty t
|
fun t -> loop Path.Set.empty t
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue