diff options
author | jao <jao@gnu.org> | 2016-07-28 00:30:21 +0200 |
---|---|---|
committer | jao <jao@gnu.org> | 2016-07-28 00:30:21 +0200 |
commit | 5e783dc34abb507f4d9715f0fd30ed8db016772a (patch) | |
tree | 8ffade9020f5cf770ff7bdb104f645465a2f55a8 /src/Plugins/Monitors | |
parent | 6af854ffa7ca840857876629690a10e143396e1f (diff) | |
download | xmobar-5e783dc34abb507f4d9715f0fd30ed8db016772a.tar.gz xmobar-5e783dc34abb507f4d9715f0fd30ed8db016772a.tar.bz2 |
Fixing compatibility with GHC 7.6
Diffstat (limited to 'src/Plugins/Monitors')
-rw-r--r-- | src/Plugins/Monitors/Batt.hs | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/Plugins/Monitors/Batt.hs b/src/Plugins/Monitors/Batt.hs index 81c9aee..fba45dd 100644 --- a/src/Plugins/Monitors/Batt.hs +++ b/src/Plugins/Monitors/Batt.hs @@ -21,8 +21,9 @@ import System.FilePath ((</>)) import System.IO (IOMode(ReadMode), hGetLine, withFile) import System.Posix.Files (fileExist) import System.Console.GetOpt -import Data.List (sort, sortOn, group) +import Data.List (sort, sortBy, group) import Data.Maybe (fromMaybe) +import Data.Ord (comparing) import Text.Read (readMaybe) data BattOpts = BattOpts @@ -163,6 +164,11 @@ readBattery sc files = grabs f = handle onError' $ withFile f ReadMode hGetLine onError' = const (return "Idle") :: SomeException -> IO String +-- sortOn is only available starting at ghc 7.10 +sortOn :: Ord b => (a -> b) -> [a] -> [a] +sortOn f = + map snd . sortBy (comparing fst) . map (\x -> let y = f x in y `seq` (y, x)) + readBatteries :: BattOpts -> [Files] -> IO Result readBatteries opts bfs = do bats <- mapM (readBattery (scale opts)) (take 3 bfs) |