Skip to content

ghci: Explicitly store and restore interface file cache

Matthew Pickering requested to merge wip/t20217 into master

In the old days the old HPT was used as an interface file cache when using ghci. The HPT is a ModuleEnv HomeModInfo and so if you were using hs-boot files then the interface file from compiling the .hs file would be present in the cache but not the hi-boot file. This used to be ok, because the .hi file used to just be a better version of the .hi-boot file, with more information so it was fine to reuse it. Now the source hash of a module is kept track of in the interface file and the source hash for the .hs and .hs-boot file are correspondingly different so it's no longer safe to reuse an interface file.

I took the decision to move the cache management of interface files to GHCi itself, and provide an API where load can be provided with a list of interface files which can be used as a cache. An alternative would be to manage this cache somewhere in the HscEnv but it seemed that an API user should be responsible for populating and suppling the cache rather than having it managed implicitly.

Fixes #20217 (closed)

I am not sure this is the best approach, we can discuss how is best to solve this problem but this approach does work.

Merge request reports