From c8fcd976265c8378afd15a81898a619455a138ba Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 26 Sep 2024 17:52:19 -0400 Subject: [PATCH] avoid head Recent ghc has a deprecation warning on it. This is not an improvement though. I know these cannot fail, but I can't prove it to ghc. --- Assistant/WebApp/Pairing.hs | 5 +++-- Remote.hs | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Assistant/WebApp/Pairing.hs b/Assistant/WebApp/Pairing.hs index 2c4086a5cf..26847e11fb 100644 --- a/Assistant/WebApp/Pairing.hs +++ b/Assistant/WebApp/Pairing.hs @@ -35,8 +35,9 @@ newWormholePairingState = newTVarIO M.empty addWormholePairingState :: WormholePairingHandle -> WormholePairingState -> IO WormholePairingId addWormholePairingState h tv = atomically $ do m <- readTVar tv - -- use of head is safe because allids is infinite - let i = Prelude.head $ filter (`notElem` M.keys m) allids + -- safe because allids is infinite + let i = fromMaybe (error "internal") $ + headMaybe $ filter (`notElem` M.keys m) allids writeTVar tv (M.insert i h m) return i where diff --git a/Remote.hs b/Remote.hs index 0f19d7a880..cfe771bb12 100644 --- a/Remote.hs +++ b/Remote.hs @@ -473,7 +473,8 @@ claimingUrl = claimingUrl' (const True) claimingUrl' :: (Remote -> Bool) -> URLString -> Annex Remote claimingUrl' remotefilter url = do rs <- remoteList - let web = Prelude.head $ filter (\r -> uuid r == webUUID) rs + let web = fromMaybe (error "internal") $ headMaybe $ + filter (\r -> uuid r == webUUID) rs fromMaybe web <$> firstM checkclaim (filter remotefilter rs) where checkclaim = maybe (pure False) (`id` url) . claimUrl