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.
This commit is contained in:
parent
30713ab0d3
commit
c8fcd97626
2 changed files with 5 additions and 3 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue