What is the recommended way of running some Action if a file (or part of a file) change?
My use-case is: given a file that I know exists ("elm-package.json"), run a shell command ("elm package install --yes") if part of the file changes (the "dependencies" field).
Browsing the docs, it seems that the "Oracle" abstraction is the only mechanism by which Shake exposes comparing a value to the last (via Eq). So, I might have a newtype like:
```
newtype ElmDependencies = ElmDependencies () deriving ...
type instance RuleResult ElmDependencies = String
```
But now, I get stuck actually using this function of type "ElmDependencies -> Action String", since the rule I want to write doesn't actually care what the returned String is, it simply wants to be called if the String changes.
In other words,
```
action $ do
_ <- askOracle (ElmDependencies ())
cmd_ "elm package install --yes"
```
at the top-level doesn't work; it will run the action every time.
I briefly looked at "addBuiltinRule" and "addUserRule" in "Development.Shake.Rule", and one of the two seems likely to be a solution for me, but I can't quite figure out how either one works :)
Thanks for the help.
1) "elm-package-dependencies.json", created from the "dependencies" field of "elm-package.json". Something like:
```
".shake/elm-package-dependencies.json" %> \out -> do
bytes <- readFile' "elm-dependencies.json"
case parse bytes of ->
Left err -> fail err
Right deps -> writeFileChanged out deps
```
2) An empty file like "elm-package-dependencies.stamp", created with:
```
".shake/elm-package-dependencies.stamp" %> \out -> do
need [".shake/elm-package-dependencies.json"]
cmd_ "elm package install --yes"
writeFile' out ""
```
Then, the main build command that we want to install dependencies *prior* to running, would incur a "need" on the stamp file.