What is the recommended way of running some Action
if part of a file changes?
My use-case is given a file that I know exists (concretely elm-package.json
), run a shell command (elm package install --yes
) if part of the file changes (the dependencies
field).
It seems that the Oracle
abstraction exposes comparing a value to the last (via Eq
). So I tried 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.