From d9b24473ce65c6ce7f5bdea8c7d6eee07a62461e Mon Sep 17 00:00:00 2001 From: Reto Hablützel Date: Sat, 9 Aug 2014 21:33:10 +0200 Subject: hlint refactorings --- src/Plugins/Monitors/MultiCpu.hs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/Plugins/Monitors/MultiCpu.hs') diff --git a/src/Plugins/Monitors/MultiCpu.hs b/src/Plugins/Monitors/MultiCpu.hs index 429c38a..150fb7e 100644 --- a/src/Plugins/Monitors/MultiCpu.hs +++ b/src/Plugins/Monitors/MultiCpu.hs @@ -15,6 +15,7 @@ module Plugins.Monitors.MultiCpu (startMultiCpu) where import Plugins.Monitors.Common +import Control.Applicative ((<$>)) import qualified Data.ByteString.Lazy.Char8 as B import Data.List (isPrefixOf, transpose, unfoldr) import Data.IORef (IORef, newIORef, readIORef, writeIORef) @@ -52,16 +53,16 @@ parseCpuData cref = percent :: [Float] -> [Float] -> [Float] percent b a = if tot > 0 then map (/ tot) $ take 4 dif else [0, 0, 0, 0] where dif = zipWith (-) b a - tot = foldr (+) 0 dif + tot = sum dif formatMultiCpus :: [[Float]] -> Monitor [String] formatMultiCpus [] = return [] -formatMultiCpus xs = fmap concat $ mapM formatCpu xs +formatMultiCpus xs = concat <$> mapM formatCpu xs formatCpu :: [Float] -> Monitor [String] formatCpu xs | length xs < 4 = showPercentsWithColors $ replicate vNum 0.0 - | otherwise = let t = foldr (+) 0 $ take 3 xs + | otherwise = let t = sum $ take 3 xs in do b <- showPercentBar (100 * t) t h <- showVerticalBar (100 * t) t ps <- showPercentsWithColors (t:xs) -- cgit v1.2.3