Caching type checker output via interface files #197
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Instead of rechecking the whole dependency tree of a Granule program at every type checker run, we can cache (transitively) unchanged code and only check new/changed code. This reduces some unnecessary re-computation, thereby speeding up the development/type-check cycle.
This patch brings
caching granularity at the module level. (Modules currently map one-to-one to Granule source files, so bear with me if I sloppily conflate the two.)
We write the checker output of checking a module
Foo
(from fileFoo.gr
) to disk in an interface fileFoo.gri
.The type checker can then skip re-checking
Foo
ifFoo.gri
is newer thanFoo.gr
.When checking the module
Bar
, that depends onFoo
, the checker simply loads the interface file forFoo
into the context.Module dependencies
are relevant for cache invalidation. When determining whether we can skip re-checking module
Foo
, it is actually not enough to consider whether the interface file is newer than the source file. We also need to verify that the module signatures of the dependencies ofFoo
have not changed.Therefore, we need to do a dependency analysis of the module hierarchy of a Granule program. (Incidentally this will make it easy for us to avoid hanging in an infinite loop when chasing circular imports, which is what happens with the current module... sitch.)
But there is more in this patch
such as adding
gr
, a nice quasi quoter for embedding Granule ASTs in your Haskell source files:[gr| --your granule code here! |]
There are also bugfixes like the already mentioned cyclical imports (which we simply disallow), as well as allowing dependencies to be literate files.
Naming things is difficult.
This patch adds something similar to header files in C. ML uses the term interface file for a related concept, which is, more generally, a module signature. We could have a discussion about what we call this concept in Granule.