summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJose Antonio Ortega Ruiz <jao@gnu.org>2010-02-12 23:14:59 +0100
committerJose Antonio Ortega Ruiz <jao@gnu.org>2010-02-12 23:14:59 +0100
commit79791681b96a24cfb7c60c9ef2e444246ad0d77f (patch)
treee46cc58ff5ee09666871bc017f51f2759cfd3ea9
parent9670c0b9e835965717486ed815db993244df9cea (diff)
downloadxmobar-79791681b96a24cfb7c60c9ef2e444246ad0d77f.tar.gz
xmobar-79791681b96a24cfb7c60c9ef2e444246ad0d77f.tar.bz2
hlinting
Ignore-this: ab56894a498e5d5b2b551fbadafade08 darcs-hash:20100212221459-1d908-944944fcb9f40a91f7cc064a2a6a97f527c84941.gz
-rw-r--r--Plugins/Monitors/Top.hs16
1 files changed, 6 insertions, 10 deletions
diff --git a/Plugins/Monitors/Top.hs b/Plugins/Monitors/Top.hs
index 2e235d8..38686f6 100644
--- a/Plugins/Monitors/Top.hs
+++ b/Plugins/Monitors/Top.hs
@@ -23,7 +23,7 @@ import System.Directory
import System.FilePath
import System.Posix.Unistd (getSysVar, SysVar(ClockTick))
import Foreign.C.Types
-import Data.List (sortBy, foldl')
+import Data.List (sortBy)
import Data.Ord (comparing)
import Data.IORef
@@ -111,24 +111,20 @@ type TimeEntry = (Pid, TimeInfo)
type Times = IntMap TimeInfo
type TimesRef = IORef Times
-timeinfo :: FilePath -> IO TimeEntry
-timeinfo = handlePidFile (0, ("", 0)) $ \fs ->
+timeEntry :: FilePath -> IO TimeEntry
+timeEntry = handlePidFile (0, ("", 0)) $ \fs ->
let rf = read . (fs!!)
!pid = read (head fs)
!n = drop 1 $ init (fs!!1)
!t = rf 13 + rf 14
- in evaluate $ (pid, (n, t))
+ in evaluate (pid, (n, t))
timeinfos :: IO Times
-timeinfos = do
- fs <- processes
- tis <- mapM timeinfo $! fs
- return $ foldl' acc M.empty tis
- where acc m (p, (n, t)) = M.insert p (n, t) m
+timeinfos = fmap M.fromList (processes >>= mapM timeEntry)
combineTimeInfos :: Times -> Times -> Times
combineTimeInfos !t0 !t1 = M.intersectionWith timeDiff t1 t0
- where timeDiff (n, x1) (_, x0) = (n, (x1 - x0))
+ where timeDiff (n, x1) (_, x0) = (n, x1 - x0)
topTimeProcesses :: Int -> TimesRef -> Float -> IO [TimeInfo]
topTimeProcesses n tref lapse = do