From ba802027470938373f71ef349f4fb2bcf0e8048e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9mie=20Dimino?= Date: Sun, 5 Mar 2017 10:05:05 +0000 Subject: [PATCH] Implem of Build.progn --- src/build.ml | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/build.ml b/src/build.ml index 024be6da..6ec7bb14 100644 --- a/src/build.ml +++ b/src/build.ml @@ -190,3 +190,32 @@ let and_create_file fn = { action with action = Progn [action.action; Create_file fn] }) + +(* + {[ + let progn ts = + all ts >>^ fun (actions : Action.t list) -> + match actions with + | [] -> + { Action. + context = None + ; dir = Path.root + ; action = Progn [] + } + | first :: rest -> + let rest = + List.map rest ~f:(fun a -> + (match first.context, a.context with + | None, None -> () + | Some c1, Some c2 when c1.name = c2.name -> () + | _ -> + Sexp.code_error "Build.progn" + [ "actions", Sexp.To_sexp.list Action.sexp_of_t actions ]); + if first.dir = a.dir then + a.action + else + Chdir (a.dir, a.action)) + in + { first with action = Progn (first :: rest) } + ]} +*)