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:
Joey Hess 2024-09-26 17:52:19 -04:00
parent 30713ab0d3
commit c8fcd97626
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
2 changed files with 5 additions and 3 deletions

View file

@ -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