summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libraries/ghc-boot/GHC/BaseDir.hs5
-rw-r--r--libraries/ghc-boot/GHC/Data/ShortText.hs9
2 files changed, 8 insertions, 6 deletions
diff --git a/libraries/ghc-boot/GHC/BaseDir.hs b/libraries/ghc-boot/GHC/BaseDir.hs
index 66ed339e32..0001837f75 100644
--- a/libraries/ghc-boot/GHC/BaseDir.hs
+++ b/libraries/ghc-boot/GHC/BaseDir.hs
@@ -16,7 +16,8 @@ module GHC.BaseDir where
import Prelude -- See Note [Why do we import Prelude here?]
-import Data.List (stripPrefix, uncons)
+import Data.List (stripPrefix)
+import Data.Maybe (listToMaybe)
import System.FilePath
-- Windows
@@ -37,7 +38,7 @@ expandTopDir = expandPathVar "topdir"
expandPathVar :: String -> FilePath -> String -> String
expandPathVar var value str
| Just str' <- stripPrefix ('$':var) str
- , maybe True (isPathSeparator . fst) (uncons str')
+ , maybe True isPathSeparator (listToMaybe str')
= value ++ expandPathVar var value str'
expandPathVar var value (x:xs) = x : expandPathVar var value xs
expandPathVar _ _ [] = []
diff --git a/libraries/ghc-boot/GHC/Data/ShortText.hs b/libraries/ghc-boot/GHC/Data/ShortText.hs
index 477d2b9a6d..9ea261435f 100644
--- a/libraries/ghc-boot/GHC/Data/ShortText.hs
+++ b/libraries/ghc-boot/GHC/Data/ShortText.hs
@@ -47,7 +47,6 @@ import Control.DeepSeq as DeepSeq
import Data.Binary
import qualified Data.ByteString.Char8 as B8
import qualified Data.ByteString.Short.Internal as SBS
-import Data.List (uncons)
import GHC.Exts
import GHC.IO
import GHC.Utils.Encoding
@@ -101,9 +100,11 @@ splitFilePath st = DeepSeq.force $ map (ShortText . SBS.toShort) $ B8.splitWith
-- question, this may or may not be the actual first character in the string due to Unicode
-- non-printable characters.
head :: ShortText -> Char
-head st = case uncons (unpack st) of
- Nothing -> error "head: Empty ShortText"
- Just (hd, _) -> hd
+head st
+ | hd:_ <- unpack st
+ = hd
+ | otherwise
+ = error "head: Empty ShortText"
-- | /O(n)/ The 'stripPrefix' function takes two 'ShortText's and returns 'Just' the remainder of
-- the second iff the first is its prefix, and otherwise Nothing.