From c75c5f8254181242a96f3f6652a53cc70f40b13e Mon Sep 17 00:00:00 2001 From: Josh Rahm Date: Mon, 28 Mar 2022 23:27:45 -0600 Subject: Fix things that Hlint is complaining about. --- src/Internal/CornerLayout.hs | 4 ++-- src/Internal/DMenu.hs | 1 - src/Internal/Hash.hs | 2 +- src/Internal/Keys.hs | 4 ++-- src/Internal/LayoutDraw.hs | 12 ++++++------ src/Internal/Lib.hs | 10 +++++----- src/Internal/Logger.hs | 2 +- src/Internal/Marking.hs | 4 ++-- src/Internal/RebindKeys.hs | 5 ++--- src/Internal/Submap.hs | 4 ++-- src/Internal/SwapMaster.hs | 8 ++++---- 11 files changed, 27 insertions(+), 29 deletions(-) (limited to 'src') diff --git a/src/Internal/CornerLayout.hs b/src/Internal/CornerLayout.hs index 10fbe5b..b3898fc 100644 --- a/src/Internal/CornerLayout.hs +++ b/src/Internal/CornerLayout.hs @@ -31,8 +31,8 @@ instance LayoutClass Corner a where zip ws $ map ( \(Rectangle x' y' w h) -> Rectangle (x + x') (y + y') w h) $ corner : - (splitVert vertRect vn) ++ - (splitHoriz horizRect hn) + splitVert vertRect vn ++ + splitHoriz horizRect hn pureMessage (Corner frac delta) m = fmap resize (fromMessage m) where diff --git a/src/Internal/DMenu.hs b/src/Internal/DMenu.hs index 0ec7927..0d22b55 100644 --- a/src/Internal/DMenu.hs +++ b/src/Internal/DMenu.hs @@ -2,7 +2,6 @@ module Internal.DMenu where import XMonad.Util.Dmenu import XMonad -import XMonad.Util.Run import Control.Monad import Data.Map (Map) import qualified Data.Map as Map diff --git a/src/Internal/Hash.hs b/src/Internal/Hash.hs index 63f6043..272808b 100644 --- a/src/Internal/Hash.hs +++ b/src/Internal/Hash.hs @@ -8,4 +8,4 @@ import qualified Crypto.Hash.SHA1 as SHA1 quickHash :: String -> String quickHash str = - concatMap (flip showHex "") $ BS.unpack (SHA1.hash $ BC.pack str) + concatMap (`showHex` "") $ BS.unpack (SHA1.hash $ BC.pack str) diff --git a/src/Internal/Keys.hs b/src/Internal/Keys.hs index b322eb4..446b7b7 100644 --- a/src/Internal/Keys.hs +++ b/src/Internal/Keys.hs @@ -277,7 +277,7 @@ keymap = runKeys $ do recur bind xK_v $ do - justMod $ recur + justMod recur bind xK_w $ do justMod windowJump @@ -494,4 +494,4 @@ modifyWindowBorder i = ModifyWindowBorder $ \(Border a b c d) -> Border (clip $ a + i) (clip $ b + i) (clip $ c + i) (clip $ d + i) where clip i | i < 0 = 0 - clip i | otherwise = i + clip i = i diff --git a/src/Internal/LayoutDraw.hs b/src/Internal/LayoutDraw.hs index 8b029bd..131b32b 100644 --- a/src/Internal/LayoutDraw.hs +++ b/src/Internal/LayoutDraw.hs @@ -43,17 +43,17 @@ import qualified XMonad.StackSet as S drawLayout :: X (Bool, String, String) drawLayout = do winset <- X.gets X.windowset - let layout = S.layout $ S.workspace $ S.current $ winset + let layout = S.layout $ S.workspace $ S.current winset -- Gotta reset the layout to a consistent state. - layout' <- foldM (flip ($)) layout $ [ + layout' <- foldM (flip ($)) layout [ handleMessage' $ ModifyWindowBorder $ const $ Border 0 0 0 0, - handleMessage' $ Unzoom + handleMessage' Unzoom ] (cached, xpm) <- drawXpmIO layout' - return $ (cached, X.description layout, printf "" xpm) + return (cached , X.description layout, printf "" xpm) -- Returns true if a point is inside a rectangle (inclusive). pointInRect :: (Dimension, Dimension) -> Rectangle -> Bool @@ -98,14 +98,14 @@ drawXpmIO l = do (S.Workspace "0" l (S.differentiate [1 .. 5])) (Rectangle 0 0 ((w + shrinkAmt) * sf) ((h + shrinkAmt) * sf)) - let rects = flip map rects' $ \(_, (Rectangle x y w h)) -> + let rects = flip map rects' $ \(_, Rectangle x y w h) -> Rectangle (x `div` sf) (y `div` sf) (w `div` sf) (h `div` sf) X.liftIO $ do exists <- doesFileExist iconPath createDirectoryIfMissing True iconCacheDir - when (not exists) $ do + unless exists $ do let xpmText = drawXpm (w, h) (zip (cycle colors) rects) 4 writeFile iconPath xpmText diff --git a/src/Internal/Lib.hs b/src/Internal/Lib.hs index 3beb640..d8784ea 100644 --- a/src/Internal/Lib.hs +++ b/src/Internal/Lib.hs @@ -47,7 +47,7 @@ data WorkspaceState = Current | Hidden | Visible getPopulatedWorkspaces :: (Ord i) => S.StackSet i l a sid sd -> [(WorkspaceState, S.Workspace i l a)] getPopulatedWorkspaces (S.StackSet (S.Screen cur _ _) vis hi _) = - sortBy (comparing (tag . snd)) $ + sortOn (tag . snd) $ mapMaybe (\w@(S.Workspace _ _ s) -> fmap (const (Hidden, w)) s) hi ++ map (\(S.Screen w _ _) -> (Visible, w)) vis ++ [(Current, cur)] @@ -93,10 +93,10 @@ swapWorkspace toWorkspaceName = do windows $ \ss -> do let fromWorkspace = tag $ workspace $ current ss toWorkspace = [toWorkspaceName] in - (StackSet (swapSc fromWorkspace toWorkspace $ current ss) + StackSet (swapSc fromWorkspace toWorkspace $ current ss) (map (swapSc fromWorkspace toWorkspace) $ visible ss) (map (swapWs fromWorkspace toWorkspace) $ hidden ss) - (floating ss)) + (floating ss) where swapSc fromWorkspace toWorkspace (Screen ws a b) = Screen (swapWs fromWorkspace toWorkspace ws) a b @@ -125,7 +125,7 @@ getString = runQuery $ do relativeWorkspaceShift :: Selector -> X () relativeWorkspaceShift (Selector selector) = do windows $ \ss -> - let tags = sort $ (tag . snd <$> filter (\x -> fst x /= Visible ) (getPopulatedWorkspaces ss)) + let tags = sort (tag . snd <$> filter (\x -> fst x /= Visible ) (getPopulatedWorkspaces ss)) from = tag $ workspace $ current ss to = selector from tags in greedyView to ss @@ -144,7 +144,7 @@ prev = Selector $ \a l -> withScreen :: (WorkspaceId -> WindowSet -> WindowSet) -> Int -> X () withScreen fn n = do windows $ \windowSet -> - case (getHorizontallyOrderedScreens windowSet !! n) of + case getHorizontallyOrderedScreens windowSet !! n of Nothing -> windowSet Just screen -> fn (tag $ workspace screen) windowSet diff --git a/src/Internal/Logger.hs b/src/Internal/Logger.hs index cc52c7e..1dbd493 100644 --- a/src/Internal/Logger.hs +++ b/src/Internal/Logger.hs @@ -6,7 +6,7 @@ import System.IO import Internal.NoPersist -data LoggerState = +newtype LoggerState = LoggerState { logHandle :: Maybe (NoPersist Handle) } diff --git a/src/Internal/Marking.hs b/src/Internal/Marking.hs index c1234ec..e37e241 100644 --- a/src/Internal/Marking.hs +++ b/src/Internal/Marking.hs @@ -40,7 +40,7 @@ greedyFocus win = do markCurrentWindow :: Mark -> X () markCurrentWindow mark = do withFocused $ \win -> - XS.modify $ \state@(MarkState {markStateMap = ms}) -> + XS.modify $ \state@MarkState {markStateMap = ms} -> state { markStateMap = Map.insert mark win ms } @@ -73,7 +73,7 @@ setFocusedWindow case stack of Nothing -> Nothing Just (Stack _ up down) -> Just (Stack window up down) in - (StackSet (Screen (Workspace t l newStack) a b) vis hid float) + StackSet (Screen (Workspace t l newStack) a b) vis hid float swapWithFocused :: (Ord a) => a -> StackSet i l a s sd -> StackSet i l a s sd swapWithFocused winToSwap stackSet = diff --git a/src/Internal/RebindKeys.hs b/src/Internal/RebindKeys.hs index 7c5d47c..38af754 100644 --- a/src/Internal/RebindKeys.hs +++ b/src/Internal/RebindKeys.hs @@ -7,7 +7,6 @@ module Internal.RebindKeys where import XMonad import Text.Printf -import Data.Monoid (Endo(..)) import Control.Monad.Trans.Class (lift) import Control.Monad (forM, forM_) import Data.Default (Default, def) @@ -21,10 +20,10 @@ import Internal.NoPersist type WindowHook = Query () -data InterceptState = +newtype InterceptState = InterceptState (NoPersist (Map (KeyMask, KeySym) (X ()))) -data RemapState = +newtype RemapState = RemapState (NoPersist (Map (Window, (KeyMask, KeySym)) (X ()))) instance ExtensionClass InterceptState where diff --git a/src/Internal/Submap.hs b/src/Internal/Submap.hs index e5968ff..c51f9b6 100644 --- a/src/Internal/Submap.hs +++ b/src/Internal/Submap.hs @@ -28,7 +28,7 @@ mapNextString fn = do if isModifierKey keysym then nextkey - else return $ (m, str) + else return (m, str) io $ ungrabKeyboard d currentTime @@ -63,7 +63,7 @@ nextMotion = do return ret submapButtonsWithKey :: - ((ButtonMask, Button) -> Window -> X ()) -> (Map (ButtonMask, Button) (Window -> X ())) -> Window -> X () + ((ButtonMask, Button) -> Window -> X ()) -> Map (ButtonMask, Button) (Window -> X ()) -> Window -> X () submapButtonsWithKey defaultAction actions window = do arg <- nextButton diff --git a/src/Internal/SwapMaster.hs b/src/Internal/SwapMaster.hs index c73cbd9..e7ade19 100644 --- a/src/Internal/SwapMaster.hs +++ b/src/Internal/SwapMaster.hs @@ -9,12 +9,12 @@ import XMonad (Window, ExtensionClass(..), X(..), windows, windowset) import Control.Monad (void) import Control.Monad.Trans (lift) import Data.Maybe (fromMaybe) -import Control.Monad.State (get) +import Control.Monad.State (gets) import qualified XMonad.Util.ExtensibleState as XS -data LastWindow = LastWindow { - lastWindow :: (Maybe Window) +newtype LastWindow = LastWindow { + lastWindow :: Maybe Window } deriving (Show, Read) instance ExtensionClass LastWindow where @@ -25,7 +25,7 @@ hoist = MaybeT . return swapMaster :: X () swapMaster = void $ runMaybeT $ do - ss <- lift $ windowset <$> get + ss <- gets windowset focused <- hoist $ W.peek ss master <- hoist $ getMaster ss -- cgit