Skip to content

Commit

Permalink
bugfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaszcz committed Dec 14, 2023
1 parent 7cd72fb commit b048ad4
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/Juvix/Compiler/Pipeline/Driver.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions src/Juvix/Compiler/Pipeline/Package/Loader/EvalEff/IO.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
14 changes: 10 additions & 4 deletions src/Juvix/Extra/Serialize.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit b048ad4

Please sign in to comment.