Skip to content

Commit

Permalink
Merge pull request #7656 from haskell/mergify/bp/3.6/pr-7650
Browse files Browse the repository at this point in the history
Generate Paths_ module with qualified Data.List.last import (backport #7650)
  • Loading branch information
Mikolaj authored Sep 18, 2021
2 parents c183ca0 + b278960 commit 2f44d28
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions Cabal/src/Distribution/Simple/Build/PathsModule/Z.hs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ render z_root = execWriter $ do
return ()
tell "\n"
tell "import qualified Control.Exception as Exception\n"
tell "import qualified Data.List as List\n"
tell "import Data.Version (Version(..))\n"
tell "import System.Environment (getEnv)\n"
tell "import Prelude\n"
Expand Down Expand Up @@ -295,8 +296,8 @@ render z_root = execWriter $ do
tell "joinFileName \".\" fname = fname\n"
tell "joinFileName dir \"\" = dir\n"
tell "joinFileName dir fname\n"
tell " | isPathSeparator (last dir) = dir ++ fname\n"
tell " | otherwise = dir ++ pathSeparator : fname\n"
tell " | isPathSeparator (List.last dir) = dir ++ fname\n"
tell " | otherwise = dir ++ pathSeparator : fname\n"
tell "\n"
tell "pathSeparator :: Char\n"
if (zIsWindows z_root)
Expand Down
5 changes: 3 additions & 2 deletions templates/Paths_pkg.template.hs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import Foreign.C
{% endif %}

import qualified Control.Exception as Exception
import qualified Data.List as List
import Data.Version (Version(..))
import System.Environment (getEnv)
import Prelude
Expand Down Expand Up @@ -166,8 +167,8 @@ joinFileName "" fname = fname
joinFileName "." fname = fname
joinFileName dir "" = dir
joinFileName dir fname
| isPathSeparator (last dir) = dir ++ fname
| otherwise = dir ++ pathSeparator : fname
| isPathSeparator (List.last dir) = dir ++ fname
| otherwise = dir ++ pathSeparator : fname

pathSeparator :: Char
{% if isWindows %}
Expand Down

0 comments on commit 2f44d28

Please sign in to comment.