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