ref: ee9cc21cbe78601febaf8c79d91af307c2c17f04
parent: 715436792787ecc3eef91d07b5563de8f159f8f5
author: Lennart Augustsson <lennart@augustsson.net>
date: Sat Apr 20 10:33:29 EDT 2024
Write cache even with interactive
--- a/src/MicroHs/Compile.hs
+++ b/src/MicroHs/Compile.hs
@@ -3,7 +3,7 @@
module MicroHs.Compile(
compileCacheTop,
compileMany,
- mhsCacheName,
+ maybeSaveCache,
getCached,
validateCache,
Cache, emptyCache, deleteFromCache,
@@ -68,6 +68,14 @@
when (loading flags || verbosityGT flags 0) $
putStrLn $ "Loading saved cache " ++ show mhsCacheName
validateCache flags cash
+
+maybeSaveCache :: Flags -> Cache -> IO ()
+maybeSaveCache flags cash =
+ when (writeCache flags) $ do
+ when (verbosityGT flags 0) $
+ putStrLn $ "Saving cache " ++ show mhsCacheName
+ () <- seq (rnfNoErr cash) (return ())
+ saveCache mhsCacheName cash
compile :: Flags -> IdentModule -> Cache -> IO ((IdentModule, [LDef]), Symbols, Cache)
compile flags nm ach = do
--- a/src/MicroHs/Interactive.hs
+++ b/src/MicroHs/Interactive.hs
@@ -45,6 +45,8 @@
start :: I ()
start = do
reload
+ is <- get
+ liftIO $ maybeSaveCache (isFlags is) (isCache is)
liftIO $ putStrLn "Type ':quit' to quit, ':help' for help"
when compiledWithGHC $
liftIO $ putStrLn "WARNING: Compiled with GHC, so limited functionality."
--- a/src/MicroHs/Main.hs
+++ b/src/MicroHs/Main.hs
@@ -158,11 +158,7 @@
(rmn, allDefs) <- do
cash <- getCached flags
(rds, _, cash') <- compileCacheTop flags mn cash
- when (writeCache flags) $ do
- when (verbosityGT flags 0) $
- putStrLn $ "Saving cache " ++ show mhsCacheName
- () <- seq (rnfNoErr cash) (return ())
- saveCache mhsCacheName cash'
+ maybeSaveCache flags cash'
return rds
t1 <- getTimeMilli
--
⑨