From ad64ccf601e76a4504aacffffa234233b30ee24d Mon Sep 17 00:00:00 2001 From: jao Date: Mon, 11 May 2020 19:32:06 +0100 Subject: more hlinting --- src/Xmobar/System/Utils.hs | 5 ++--- 1 file 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) -- cgit v1.2.3