diff --git a/src/Juvix/Compiler/Pipeline/Driver.hs b/src/Juvix/Compiler/Pipeline/Driver.hs index ef0956c59e..6ca44cb601 100644 --- a/src/Juvix/Compiler/Pipeline/Driver.hs +++ b/src/Juvix/Compiler/Pipeline/Driver.hs @@ -134,7 +134,7 @@ processModule' :: Sem r (Store.ModuleInfo, Store.ModuleTable) processModule' entry = do let buildDir = resolveAbsBuildDir root (entry ^. entryPointBuildDir) - relPath = fromJust $ replaceExtension ".jvo" $ fromJust $ stripProperPrefix root sourcePath + relPath = fromJust $ replaceExtension ".jvo" $ fromJust $ stripProperPrefix $(mkAbsDir "/") sourcePath absPath = buildDir Path. relPath sha256 <- SHA256.digestFile sourcePath m :: Maybe Store.ModuleInfo <- loadFromFile absPath diff --git a/src/Juvix/Compiler/Pipeline/Package/Loader/EvalEff/IO.hs b/src/Juvix/Compiler/Pipeline/Package/Loader/EvalEff/IO.hs index 222f5fc390..206f7d0e10 100644 --- a/src/Juvix/Compiler/Pipeline/Package/Loader/EvalEff/IO.hs +++ b/src/Juvix/Compiler/Pipeline/Package/Loader/EvalEff/IO.hs @@ -8,7 +8,6 @@ import Data.HashMap.Strict qualified as HashMap import Juvix.Compiler.Concrete hiding (Symbol) import Juvix.Compiler.Core (CoreResult, coreResultModule) import Juvix.Compiler.Core qualified as Core -import Juvix.Compiler.Core.Data.Module (moduleInfoTable) import Juvix.Compiler.Core.Evaluator import Juvix.Compiler.Core.Extra.Value import Juvix.Compiler.Core.Language @@ -59,7 +58,7 @@ runEvalFileEffIO = interpretScopedAs allocator handler AssertNodeType n ty -> assertNodeType' n ty where tab :: Core.InfoTable - tab = res ^. loaderResourceResult . coreResultModule . moduleInfoTable + tab = Core.computeCombinedInfoTable (res ^. loaderResourceResult . coreResultModule) packagePath :: Path Abs File packagePath = res ^. loaderResourcePackagePath diff --git a/src/Juvix/Extra/Serialize.hs b/src/Juvix/Extra/Serialize.hs index 042c200d68..dac8bf87b0 100644 --- a/src/Juvix/Extra/Serialize.hs +++ b/src/Juvix/Extra/Serialize.hs @@ -39,12 +39,18 @@ instance (Hashable a, Serialize a) => Serialize (HashSet a) where saveToFile :: (Member Files r, Serialize a) => Path Abs File -> a -> Sem r () saveToFile file a = do + ensureDir' (parent file) let bs = runPut (S.put a) writeFileBS file bs loadFromFile :: forall a r. (Member Files r, Serialize a) => Path Abs File -> Sem r (Maybe a) loadFromFile file = do - bs <- readFileBS' file - case runGet (S.get @a) bs of - Left {} -> return Nothing - Right a -> return (Just a) + ex <- fileExists' file + if + | ex -> do + bs <- readFileBS' file + case runGet (S.get @a) bs of + Left {} -> return Nothing + Right a -> return (Just a) + | otherwise -> + return Nothing