gelisam / klister

an implementation of stuck macros
BSD 3-Clause "New" or "Revised" License
132 stars 11 forks source link

demonstrate that separate compilation is possible #118

Open gelisam opened 4 years ago

gelisam commented 4 years ago

Klister is an interpreter, not a compiler, but we want to demonstrate that its ideas are applicable in a wider setting in the hope that they will be adopted by a larger project such as ghc. To this end, we should serialize each module after expansion, so that we can load this binary artifact (which would be compiled code in a compiler, but would consist of Maps of bindings in our context) instead of re-traversing a module.

This would also improve the performance of our test suite, as several examples happen to load the same modules (e.g. the prelude).

One thing we need to be careful about is our newUnique calls: Uniques are only guaranteed to be unique within one invocation of a Haskell program, not between runs! Therefore, we need to use a slightly more complex system of references. For example, we could write our own variant of newUnique which increments a different counter for each module, and each reference would include both a module identifier and that unique number.

david-christiansen commented 4 years ago

Rather than a map of bindings, I would probably serialize the fully-expanded source code of the module, as that's entirely first-order and readable.