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 :: WormholePairingHandle -> WormholePairingState -> IO WormholePairingId
|
||||||
addWormholePairingState h tv = atomically $ do
|
addWormholePairingState h tv = atomically $ do
|
||||||
m <- readTVar tv
|
m <- readTVar tv
|
||||||
-- use of head is safe because allids is infinite
|
-- safe because allids is infinite
|
||||||
let i = Prelude.head $ filter (`notElem` M.keys m) allids
|
let i = fromMaybe (error "internal") $
|
||||||
|
headMaybe $ filter (`notElem` M.keys m) allids
|
||||||
writeTVar tv (M.insert i h m)
|
writeTVar tv (M.insert i h m)
|
||||||
return i
|
return i
|
||||||
where
|
where
|
||||||
|
|
|
@ -473,7 +473,8 @@ claimingUrl = claimingUrl' (const True)
|
||||||
claimingUrl' :: (Remote -> Bool) -> URLString -> Annex Remote
|
claimingUrl' :: (Remote -> Bool) -> URLString -> Annex Remote
|
||||||
claimingUrl' remotefilter url = do
|
claimingUrl' remotefilter url = do
|
||||||
rs <- remoteList
|
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)
|
fromMaybe web <$> firstM checkclaim (filter remotefilter rs)
|
||||||
where
|
where
|
||||||
checkclaim = maybe (pure False) (`id` url) . claimUrl
|
checkclaim = maybe (pure False) (`id` url) . claimUrl
|
||||||
|
|
Loading…
Reference in a new issue