From 2a7a447a7d74179278ab37c4836378e6d2a678b8 Mon Sep 17 00:00:00 2001 From: Guillaume Maudoux Date: Wed, 13 May 2020 01:53:13 +0200 Subject: [PATCH] Fix occurences of name-shadowing --- src/Nix/Effects/Basic.hs | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/Nix/Effects/Basic.hs b/src/Nix/Effects/Basic.hs index 25bd631..1aa8621 100644 --- a/src/Nix/Effects/Basic.hs +++ b/src/Nix/Effects/Basic.hs @@ -64,13 +64,13 @@ defaultMakeAbsolutePath origPath = do Nothing -> getCurrentDirectory Just v -> demand v $ \case NVPath s -> pure $ takeDirectory s - v -> + val -> throwError $ ErrorCall $ "when resolving relative path," ++ " __cur_file is in scope," ++ " but is not a path; it is: " - ++ show v + ++ show val pure $ cwd origPathExpanded removeDotDotIndirections <$> canonicalizePath absPath @@ -111,13 +111,13 @@ findEnvPathM name = do where nixFilePath :: MonadEffects t f m => FilePath -> m (Maybe FilePath) nixFilePath path = do - path <- makeAbsolutePath @t @f path - exists <- doesDirectoryExist path - path' <- if exists - then makeAbsolutePath @t @f $ path "default.nix" - else pure path - exists <- doesFileExist path' - pure $ if exists then Just path' else Nothing + absPath <- makeAbsolutePath @t @f path + isDir <- doesDirectoryExist absPath + absFile <- if isDir + then makeAbsolutePath @t @f $ absPath "default.nix" + else return absPath + exists <- doesFileExist absFile + pure $ if exists then Just absFile else Nothing findPathBy :: forall e t f m @@ -226,13 +226,13 @@ findPathM => [NValue t f m] -> FilePath -> m FilePath -findPathM = findPathBy path +findPathM = findPathBy existingPath where - path :: MonadEffects t f m => FilePath -> m (Maybe FilePath) - path path = do - path <- makeAbsolutePath @t @f path - exists <- doesPathExist path - pure $ if exists then Just path else Nothing + existingPath :: MonadEffects t f m => FilePath -> m (Maybe FilePath) + existingPath path = do + apath <- makeAbsolutePath @t @f path + exists <- doesPathExist apath + pure $ if exists then Just apath else Nothing defaultImportPath :: (MonadNix e t f m, MonadState (HashMap FilePath NExprLoc) m)