diff options
author | Bodigrim <andrew.lelechenko@gmail.com> | 2022-11-19 11:59:03 +0000 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2022-11-25 04:38:28 -0500 |
commit | 5943e739f8060bcc9867ef048a462f2c465fde00 (patch) | |
tree | d9107917e28bf3e7680662984af701dc1ae6a821 /libraries/template-haskell | |
parent | d198a19ae08fec797121e3907ca93c5840db0c53 (diff) | |
download | haskell-5943e739f8060bcc9867ef048a462f2c465fde00.tar.gz |
Assorted fixes to avoid Data.List.{head,tail}
Diffstat (limited to 'libraries/template-haskell')
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] |