Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Caching type checker output via interface files #197

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

buggymcbugfix
Copy link
Member

@buggymcbugfix buggymcbugfix commented Feb 21, 2023

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 file Foo.gr) to disk in an interface file Foo.gri.

The type checker can then skip re-checking Foo if Foo.gri is newer than Foo.gr.

When checking the module Bar, that depends on Foo, the checker simply loads the interface file for Foo 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 of Foo 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.

@buggymcbugfix buggymcbugfix changed the title WIP: Caching type checker output via interface files Caching type checker output via interface files Feb 21, 2023
@buggymcbugfix buggymcbugfix marked this pull request as draft February 21, 2023 12:25
@buggymcbugfix buggymcbugfix force-pushed the buggymcbugfix/checked-file-caching branch from 5eef341 to 8f6eec4 Compare March 2, 2023 13:42
@buggymcbugfix buggymcbugfix changed the base branch from dev-minor to main May 3, 2024 08:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant