Commit 6041ae6 1 parent 47139c5 commit 6041ae6 Copy full SHA for 6041ae6
File tree 2 files changed +17
-3
lines changed
Cabal/src/Distribution/Simple/Build/PathsModule
2 files changed +17
-3
lines changed Original file line number Diff line number Diff line change @@ -69,7 +69,6 @@ render z_root = execWriter $ do
69
69
return ()
70
70
tell " \n "
71
71
tell " import qualified Control.Exception as Exception\n "
72
- tell " import qualified Data.List as List\n "
73
72
tell " import Data.Version (Version(..))\n "
74
73
tell " import System.Environment (getEnv)\n "
75
74
tell " import Prelude\n "
@@ -306,9 +305,14 @@ render z_root = execWriter $ do
306
305
tell " joinFileName \"\" fname = fname\n "
307
306
tell " joinFileName \" .\" fname = fname\n "
308
307
tell " joinFileName dir \"\" = dir\n "
309
- tell " joinFileName dir fname\n "
310
- tell " | isPathSeparator (List.last dir ) = dir ++ fname\n "
308
+ tell " joinFileName dir@(c:cs) fname\n "
309
+ tell " | isPathSeparator (lastChar c cs ) = dir ++ fname\n "
311
310
tell " | otherwise = dir ++ pathSeparator : fname\n "
311
+ tell " where\n "
312
+ -- We do not use Data.List.NonEmpty.last, as that would limit the module to
313
+ -- base >= 4.9.0.0 (GHC >= 8.0.1).
314
+ tell " lastChar x [] = x\n "
315
+ tell " lastChar _ (x:xs) = lastChar x xs\n "
312
316
tell " \n "
313
317
tell " pathSeparator :: Char\n "
314
318
if (zIsWindows z_root)
Original file line number Diff line number Diff line change
1
+ synopsis: Avoid partial `Data.List.last` in autogenerated `Paths_<pkg>.hs`
2
+ packages: Cabal
3
+ prs: #10432
4
+ significance:
5
+
6
+ description: {
7
+
8
+ - Autogenerated `Paths_<pkg>.hs` now avoids use of the partial function `Data.List.last`.
9
+
10
+ }
You can’t perform that action at this time.
0 commit comments