diagrams / diagrams-haddock

Preprocessor for including inline diagrams in Haddock documentation
Other
10 stars 4 forks source link

Don't rebuild everything when one code block changes #9

Closed byorgey closed 11 years ago

byorgey commented 11 years ago

Right now, we always include every code block when compiling each diagram. This is nice for code reuse, but it means that changing the code for a single diagram causes every diagram in the entire file to be rebuilt (since the source code used to build it, and hence its hash, has changed).

Probably the right fix is to do some actual dependency analysis, and only include code blocks transitively referenced by the code block including the diagram being built. To really do this properly would require doing name resolution, but not doing name resolution and simply taking every identifier to be a global reference will always give a conservative approximation (i.e. superset) of the precisely correct group of code blocks.

Note, doing this also means we can do away with the strange restriction that supporting code must be included in the same code block with some referenced diagram definition.

fryguybob commented 11 years ago

I think you could come up with some convoluted case involving defaulting and instances that could make a change without a name involved cause a need to re-compile, but that would be a strange case indeed.

byorgey commented 11 years ago

Hmm, yes, you're right -- it doesn't even have to be that convoluted; just write an instance for some class in one block which gets (implicitly) used in another block. But under this new scheme you wouldn't even be able to write the code that way in the first place (since it wouldn't put the instance in scope), so I don't think this would lead to any weirdness with things not getting rebuilt when you think they should.