From 1a46c1189d73cea5483100c5849796385d095f36 Mon Sep 17 00:00:00 2001 From: Paul Cadman Date: Fri, 3 May 2024 14:07:38 +0100 Subject: [PATCH] Rename envProjectRoot to envInitialRoot and add comment --- src/Juvix/Compiler/Pipeline/Loader/PathResolver.hs | 6 +++--- .../Compiler/Pipeline/Loader/PathResolver/Data.hs | 10 ++++++---- .../Pipeline/Loader/PathResolver/DependencyResolver.hs | 2 +- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/Juvix/Compiler/Pipeline/Loader/PathResolver.hs b/src/Juvix/Compiler/Pipeline/Loader/PathResolver.hs index 1f4922fb4e..117ca1be36 100644 --- a/src/Juvix/Compiler/Pipeline/Loader/PathResolver.hs +++ b/src/Juvix/Compiler/Pipeline/Loader/PathResolver.hs @@ -203,7 +203,7 @@ addRootDependency conf e root = do resolvedDependency <- resolveDependency d checkRemoteDependency resolvedDependency let p = resolvedDependency ^. resolvedDependencyPath - withEnvProjectRoot p $ do + withEnvInitialRoot p $ do pkg <- mkPackage (Just e) p shouldUpdateLockfile' <- shouldUpdateLockfile pkg when shouldUpdateLockfile' setShouldUpdateLockfile @@ -406,7 +406,7 @@ runPathResolver2 st topEnv arg = do env' = ResolverEnv { _envRoot = root', - _envProjectRoot = root', + _envInitialRoot = root', _envLockfileInfo = Nothing, _envSingleFile } @@ -430,7 +430,7 @@ runPathResolver' st root x = do env = ResolverEnv { _envRoot = root, - _envProjectRoot = root, + _envInitialRoot = root, _envLockfileInfo = Nothing, _envSingleFile } diff --git a/src/Juvix/Compiler/Pipeline/Loader/PathResolver/Data.hs b/src/Juvix/Compiler/Pipeline/Loader/PathResolver/Data.hs index 14e469945f..8886f317de 100644 --- a/src/Juvix/Compiler/Pipeline/Loader/PathResolver/Data.hs +++ b/src/Juvix/Compiler/Pipeline/Loader/PathResolver/Data.hs @@ -6,8 +6,10 @@ import Juvix.Compiler.Pipeline.Package.Base import Juvix.Prelude data ResolverEnv = ResolverEnv - { _envRoot :: Path Abs Dir, - _envProjectRoot :: Path Abs Dir, + { -- | The root path of the current project being resolved + _envRoot :: Path Abs Dir, + -- | The root path of the initial project (i.e the first project considered in the resolution) + _envInitialRoot :: Path Abs Dir, -- | The path of the input file *if* we are using the global project _envSingleFile :: Maybe (Path Abs File), _envLockfileInfo :: Maybe LockfileInfo @@ -62,8 +64,8 @@ checkRemoteDependency d = case d ^. resolvedDependencyDependency of withEnvRoot :: (Members '[Reader ResolverEnv] r) => Path Abs Dir -> Sem r a -> Sem r a withEnvRoot root' = local (set envRoot root') -withEnvProjectRoot :: (Members '[Reader ResolverEnv] r) => Path Abs Dir -> Sem r a -> Sem r a -withEnvProjectRoot projectRoot = local (set envProjectRoot projectRoot) . local (set envRoot projectRoot) +withEnvInitialRoot :: (Members '[Reader ResolverEnv] r) => Path Abs Dir -> Sem r a -> Sem r a +withEnvInitialRoot projectRoot = local (set envInitialRoot projectRoot) . local (set envRoot projectRoot) withLockfile :: (Members '[Reader ResolverEnv] r) => LockfileInfo -> Sem r a -> Sem r a withLockfile f = local (set envLockfileInfo (Just f)) diff --git a/src/Juvix/Compiler/Pipeline/Loader/PathResolver/DependencyResolver.hs b/src/Juvix/Compiler/Pipeline/Loader/PathResolver/DependencyResolver.hs index b19aaf2368..6de227406f 100644 --- a/src/Juvix/Compiler/Pipeline/Loader/PathResolver/DependencyResolver.hs +++ b/src/Juvix/Compiler/Pipeline/Loader/PathResolver/DependencyResolver.hs @@ -36,7 +36,7 @@ runDependencyResolver = runProvider_ helper _resolvedDependencyDependency = i ^. packageDepdendencyInfoDependency } DependencyGit g -> do - let r = rootBuildDir (env ^. envProjectRoot) + let r = rootBuildDir (env ^. envInitialRoot) gitCacheDir <- globalGitCache let cloneRelDir :: Path Rel Dir cloneRelDir = mkSafeDir (g ^. gitDependencyUrl)