diff options
author | Benjamin Barenblat <bbarenblat@gmail.com> | 2022-01-19 12:58:54 -0500 |
---|---|---|
committer | Benjamin Barenblat <bbarenblat@gmail.com> | 2022-01-19 13:31:02 -0500 |
commit | 44df82dcbf72d01d2bbb6c0afacff329ca749854 (patch) | |
tree | 2619d3890a9e7e532f0ad19fd5fb4e6579bd0db7 /Assistant | |
parent | 0ded71e9a53b1482019aedaa194e913d3a021c8d (diff) |
Eliminate Data.Map.insertWith'
containers-0.6 removed insertWith' in favor of the Data.Map.Strict API.
Switch to the new API where appropriate.
Diffstat (limited to 'Assistant')
-rw-r--r-- | Assistant/Alert/Utility.hs | 6 | ||||
-rw-r--r-- | Assistant/DaemonStatus.hs | 5 | ||||
-rw-r--r-- | Assistant/NamedThread.hs | 5 | ||||
-rw-r--r-- | Assistant/TransferQueue.hs | 5 |
4 files changed, 12 insertions, 9 deletions
diff --git a/Assistant/Alert/Utility.hs b/Assistant/Alert/Utility.hs index 5a6c73b85..4618633cc 100644 --- a/Assistant/Alert/Utility.hs +++ b/Assistant/Alert/Utility.hs @@ -1,6 +1,7 @@ {- git-annex assistant alert utilities - - Copyright 2012, 2013 Joey Hess <id@joeyh.name> + - Copyright 2022 Benjamin Barenblat <bbarenblat@gmail.com> - - Licensed under the GNU GPL version 3 or higher. -} @@ -13,7 +14,7 @@ import Utility.Tense import qualified Data.Text as T import Data.Text (Text) -import qualified Data.Map as M +import qualified Data.Map.Strict as M {- This is as many alerts as it makes sense to display at a time. - A display might be smaller, or larger, the point is to not overwhelm the @@ -121,8 +122,7 @@ mergeAlert i al m = maybe updatePrune updateCombine (alertCombiner al) pruneold l = let (f, rest) = partition (\(_, a) -> isFiller a) l in drop bloat f ++ rest - updatePrune = pruneBloat $ M.filterWithKey pruneSame $ - M.insertWith' const i al m + updatePrune = pruneBloat $ M.filterWithKey pruneSame $ M.insert i al m updateCombine combiner = let combined = M.mapMaybe (combiner al) m in if M.null combined diff --git a/Assistant/DaemonStatus.hs b/Assistant/DaemonStatus.hs index 49823c3c0..3fafb585d 100644 --- a/Assistant/DaemonStatus.hs +++ b/Assistant/DaemonStatus.hs @@ -1,6 +1,7 @@ {- git-annex assistant daemon status - - Copyright 2012 Joey Hess <id@joeyh.name> + - Copyright 2022 Benjamin Barenblat <bbarenblat@gmail.com> - - Licensed under the GNU GPL version 3 or higher. -} @@ -25,7 +26,7 @@ import Annex.Export import Control.Concurrent.STM import System.Posix.Types import Data.Time.Clock.POSIX -import qualified Data.Map as M +import qualified Data.Map.Strict as M import qualified Data.Set as S getDaemonStatus :: Assistant DaemonStatus @@ -181,7 +182,7 @@ alterTransferInfo t a = updateTransferInfo' $ M.adjust a t - or if already present, updates it while preserving the old transferTid, - transferPaused, and bytesComplete values, which are not written to disk. -} updateTransferInfo :: Transfer -> TransferInfo -> Assistant () -updateTransferInfo t info = updateTransferInfo' $ M.insertWith' merge t info +updateTransferInfo t info = updateTransferInfo' $ M.insertWith merge t info where merge new old = new { transferTid = maybe (transferTid new) Just (transferTid old) diff --git a/Assistant/NamedThread.hs b/Assistant/NamedThread.hs index 090a3a7cd..ae7375a27 100644 --- a/Assistant/NamedThread.hs +++ b/Assistant/NamedThread.hs @@ -1,6 +1,7 @@ {- git-annex assistant named threads. - - Copyright 2012 Joey Hess <id@joeyh.name> + - Copyright 2022 Benjamin Barenblat <bbarenblat@gmail.com> - - Licensed under the GNU GPL version 3 or higher. -} @@ -20,7 +21,7 @@ import Utility.NotificationBroadcaster import Control.Concurrent import Control.Concurrent.Async -import qualified Data.Map as M +import qualified Data.Map.Strict as M import qualified Control.Exception as E #ifdef WITH_WEBAPP @@ -57,7 +58,7 @@ startNamedThread urlrenderer (NamedThread afterstartupsanitycheck name a) = aid <- liftIO $ runner $ d { threadName = name } restart <- asIO $ startNamedThread urlrenderer (NamedThread False name a) modifyDaemonStatus_ $ \s -> s - { startedThreads = M.insertWith' const name (aid, restart) (startedThreads s) } + { startedThreads = M.insert name (aid, restart) (startedThreads s) } runmanaged first d = do aid <- async $ runAssistant d $ do void first diff --git a/Assistant/TransferQueue.hs b/Assistant/TransferQueue.hs index 278bcbaa1..fbc589673 100644 --- a/Assistant/TransferQueue.hs +++ b/Assistant/TransferQueue.hs @@ -1,6 +1,7 @@ {- git-annex assistant pending transfer queue - - Copyright 2012-2014 Joey Hess <id@joeyh.name> + - Copyright 2022 Benjamin Barenblat <bbarenblat@gmail.com> - - Licensed under the GNU GPL version 3 or higher. -} @@ -35,7 +36,7 @@ import Annex.Wanted import Utility.TList import Control.Concurrent.STM -import qualified Data.Map as M +import qualified Data.Map.Strict as M import qualified Data.Set as S type Reason = String @@ -198,7 +199,7 @@ getNextTransfer acceptable = do if acceptable info then do adjustTransfersSTM dstatus $ - M.insertWith' const t info + M.insert t info return $ Just r else return Nothing |