From c714967eb3cab550ed1387d43182ee3b498124e3 Mon Sep 17 00:00:00 2001 From: Michal Zielonka Date: Tue, 12 Apr 2022 12:04:21 +0200 Subject: make small refactoring of load linux code Add <$> for parsing content of file. --- src/Xmobar/Plugins/Monitors/Load/Linux.hs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src/Xmobar/Plugins/Monitors') diff --git a/src/Xmobar/Plugins/Monitors/Load/Linux.hs b/src/Xmobar/Plugins/Monitors/Load/Linux.hs index 9ba5a5c..19174c7 100644 --- a/src/Xmobar/Plugins/Monitors/Load/Linux.hs +++ b/src/Xmobar/Plugins/Monitors/Load/Linux.hs @@ -22,9 +22,9 @@ import System.Posix.Files (fileExist) -- | Parses the contents of a loadavg proc file, returning -- the list of load averages -parseLoadAvgs :: B.ByteString -> [Float] +parseLoadAvgs :: B.ByteString -> Result parseLoadAvgs = - map (read . B.unpack) . take 3 . B.words . head . B.lines + Result . map (read . B.unpack) . take 3 . B.words . head . B.lines fetchLoads :: IO Result fetchLoads = do @@ -32,7 +32,6 @@ fetchLoads = do exists <- fileExist file if exists then - (do contents <- B.readFile file - return $ Result (parseLoadAvgs contents)) + parseLoadAvgs <$> B.readFile file else - return NA + return NA -- cgit v1.2.3