summaryrefslogtreecommitdiff
path: root/libraries/template-haskell
diff options
context:
space:
mode:
authorBodigrim <andrew.lelechenko@gmail.com>2022-11-19 11:59:03 +0000
committerMarge Bot <ben+marge-bot@smart-cactus.org>2022-11-25 04:38:28 -0500
commit5943e739f8060bcc9867ef048a462f2c465fde00 (patch)
treed9107917e28bf3e7680662984af701dc1ae6a821 /libraries/template-haskell
parentd198a19ae08fec797121e3907ca93c5840db0c53 (diff)
downloadhaskell-5943e739f8060bcc9867ef048a462f2c465fde00.tar.gz
Assorted fixes to avoid Data.List.{head,tail}
Diffstat (limited to 'libraries/template-haskell')
-rw-r--r--libraries/template-haskell/Language/Haskell/TH/Syntax.hs5
-rw-r--r--libraries/template-haskell/vendored-filepath/System/FilePath/Posix.hs4
-rw-r--r--libraries/template-haskell/vendored-filepath/System/FilePath/Windows.hs4
3 files changed, 7 insertions, 6 deletions
diff --git a/libraries/template-haskell/Language/Haskell/TH/Syntax.hs b/libraries/template-haskell/Language/Haskell/TH/Syntax.hs
index 0c74758fa6..37de9717b0 100644
--- a/libraries/template-haskell/Language/Haskell/TH/Syntax.hs
+++ b/libraries/template-haskell/Language/Haskell/TH/Syntax.hs
@@ -1133,8 +1133,9 @@ addrToByteArrayName = helper
where
helper :: HasCallStack => Name
helper =
- case head (getCallStack ?callStack) of
- (_, SrcLoc{..}) -> mkNameG_v srcLocPackage srcLocModule "addrToByteArray"
+ case getCallStack ?callStack of
+ [] -> error "addrToByteArrayName: empty call stack"
+ (_, SrcLoc{..}) : _ -> mkNameG_v srcLocPackage srcLocModule "addrToByteArray"
addrToByteArray :: Int -> Addr# -> ByteArray
diff --git a/libraries/template-haskell/vendored-filepath/System/FilePath/Posix.hs b/libraries/template-haskell/vendored-filepath/System/FilePath/Posix.hs
index 368f081772..a1e414aa3d 100644
--- a/libraries/template-haskell/vendored-filepath/System/FilePath/Posix.hs
+++ b/libraries/template-haskell/vendored-filepath/System/FilePath/Posix.hs
@@ -600,7 +600,7 @@ hasTrailingPathSeparator x = isPathSeparator (last x)
hasLeadingPathSeparator :: FilePath -> Bool
hasLeadingPathSeparator "" = False
-hasLeadingPathSeparator x = isPathSeparator (head x)
+hasLeadingPathSeparator (hd : _) = isPathSeparator hd
-- | Add a trailing file path separator if one is not already present.
@@ -824,7 +824,7 @@ makeRelative root path
where (a,b) = break isPathSeparator $ dropWhile isPathSeparator x
-- on windows, need to drop '/' which is kind of absolute, but not a drive
- dropAbs x | hasLeadingPathSeparator x && not (hasDrive x) = tail x
+ dropAbs x | hasLeadingPathSeparator x && not (hasDrive x) = drop 1 x
dropAbs x = dropDrive x
takeAbs x | hasLeadingPathSeparator x && not (hasDrive x) = [pathSeparator]
diff --git a/libraries/template-haskell/vendored-filepath/System/FilePath/Windows.hs b/libraries/template-haskell/vendored-filepath/System/FilePath/Windows.hs
index 52a0cd86c2..2884d06595 100644
--- a/libraries/template-haskell/vendored-filepath/System/FilePath/Windows.hs
+++ b/libraries/template-haskell/vendored-filepath/System/FilePath/Windows.hs
@@ -600,7 +600,7 @@ hasTrailingPathSeparator x = isPathSeparator (last x)
hasLeadingPathSeparator :: FilePath -> Bool
hasLeadingPathSeparator "" = False
-hasLeadingPathSeparator x = isPathSeparator (head x)
+hasLeadingPathSeparator (hd : _) = isPathSeparator hd
-- | Add a trailing file path separator if one is not already present.
@@ -824,7 +824,7 @@ makeRelative root path
where (a,b) = break isPathSeparator $ dropWhile isPathSeparator x
-- on windows, need to drop '/' which is kind of absolute, but not a drive
- dropAbs x | hasLeadingPathSeparator x && not (hasDrive x) = tail x
+ dropAbs x | hasLeadingPathSeparator x && not (hasDrive x) = drop 1 x
dropAbs x = dropDrive x
takeAbs x | hasLeadingPathSeparator x && not (hasDrive x) = [pathSeparator]