diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Xmobar/System/Utils.hs | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/src/Xmobar/System/Utils.hs b/src/Xmobar/System/Utils.hs index d532149..53052ea 100644 --- a/src/Xmobar/System/Utils.hs +++ b/src/Xmobar/System/Utils.hs @@ -27,6 +27,7 @@ module Xmobar.System.Utils import Control.Monad import Control.Concurrent.STM import qualified Data.List.NonEmpty as NE +import Data.Maybe (fromMaybe) import System.Environment import System.FilePath @@ -67,6 +68,4 @@ onSomeException io what = io `catch` \e -> do _ <- what e {-# INLINE (!!?) #-} safeIndex :: NE.NonEmpty a -> Int -> a -safeIndex xs index = case NE.toList xs !!? index of - Nothing -> NE.head xs - Just value -> value +safeIndex xs index = fromMaybe (NE.head xs) (NE.toList xs !!? index) |