Open nh2 opened 9 years ago
Does the testRule
phony have a problem if you skip the writeFile'
? My guess is that is a red herring. I suspect the key line you are missing is https://github.com/ndmitchell/shake/blob/master/src/Development/Shake/Special.hs#L13 - there is a hack to say that oracles always rebuild, and that is fine. If that turns out to be the issue, I can add an extra method to Rule
that returns whether a rule should be ignored for lint checking.
In general, if you depend on a value, and then something else in the build causes it to change value, that would be bad. In this case, I'd also suggest push the find call into storedValue
, and not returning Nothing
, which should fix it as well. Was there a reason for wanting to pull it out and do it later?
In general, if you depend on a value, and then something else in the build causes it to change value, that would be bad.
I probably wasn't very clear: I precisely desire to get the Lint checking error - value has changed since being depended upon
error.
When I switched from an Oracle to my own rule, it suddenly got me those lint errors that I hoped to see, because my build system was wrong.
Your link to Special
indeed explains what the difference is.
Now the next question would be: Oracles are much less verbose than custom rules. Would it be possible to have some flavour of oracles that don't always rebuild, or otherwise achieve a conciseness similar to that of oracles for my problem?
Oracles are a bit weird, they seem to be conflating many concepts (caching, always rebuilding, type-directed rules) into one. I do suspect that splitting the pieces up would make them more reusable and less magical. In many ways they are custom rules, and with GHC's new type level literals, it might be more feasible to give enough sugar so that defining real rules is so simple that oracles aren't required.
The lint check is defined to rerun storedValue
and see if the value matches. For Oracles, that never matches, as there is no storedValue
, and it would be hard to see how you could get one with the current API, unless you modified the approach and went from something other than storedValue
.
I have the following, with question at the end:
Why is that?
It seems to me that what I do with
GetNonHiddenFilesQ/A
is exactly whatDevelopment.Shake.Rules.Oracle
does (havingstoredValue _ _ = return Nothing
).What am I missing?