The driver now has a "clock", with a major and minor counter.
Counters are used to mark places where we expect loaded files to change. Otherwise you may have a file change between a call to getSignature and getLowered, which is terribly confusing.
Ticks (minor updates), allow non-emitted files to be reloaded if they have changed. This means you can reimport erroring files within the repl, and we will attempt recompilation.
Tocks (major updates), reloads any changed file. This is only done when using :[re]load, as you need to throw away any existing values at the same time.
The REPL now keeps the same driver around for the whole session, ticking and tocking it where appropriate.
Files are considered to have changed if their SHA256 hash has changed, or any of their dependencies have changed.
It's worth noting that the REPL is still a little slow to run after each :r, as we still need to emit and run the appropriate Lua code, which takes a bit of time. It might be possible to defer the running of non-critical Lua code, but doing so is a much harder challenge.
Edit: Actually, it's not as bad as I thought it was - just tried it outside of ghci, and the performance is fine, so it probably isn't down to Lua.
This implements the design as discussed in #183:
getSignature
andgetLowered
, which is terribly confusing.:[re]load
, as you need to throw away any existing values at the same time.It's worth noting that the REPL is still a little slow to run after each
:r
, as we still need to emit and run the appropriate Lua code, which takes a bit of time. It might be possible to defer the running of non-critical Lua code, but doing so is a much harder challenge.Edit: Actually, it's not as bad as I thought it was - just tried it outside of ghci, and the performance is fine, so it probably isn't down to Lua.