Haskell shake: special rule for building directories

Viewed 357

Sometimes it is the case that to create a directory mkdir is not the right tool. It may be git clone or rsync or mount. So when we have a rule like this:

needDir dirs = filterM ((fmap not) . doesDirectoryExist) dirs >>= need

rules = do {
  "project" </> "tool" %> \out -> do {
    needDir [takeDirectory out];
    cmd "make -C" [takeDirectory out];
    }

  "project" %> \out -> cmd "git clone a.url.to/repo.git" [out]
  }

As one might expect the "project" </> "tool" creates the directory project before anything else and git clone isn't even run. Is there a way to go around this?

I suspect a new Rule is due here but I the docs were minimal and the code too confusing for me to come up with a working solution.

1 Answers
Related