Apply hlint 3.3 hints

This commit is contained in:
Tomas Janousek 2021-11-04 20:39:39 +00:00
parent e7f102bc9a
commit 5aff766a4c
20 changed files with 32 additions and 36 deletions

View File

@ -114,10 +114,10 @@ copyWindow w n = copy'
where copy' s = if n `W.tagMember` s where copy' s = if n `W.tagMember` s
then W.view (W.currentTag s) $ insertUp' w $ W.view n s then W.view (W.currentTag s) $ insertUp' w $ W.view n s
else s else s
insertUp' a s = W.modify (Just $ W.Stack a [] []) insertUp' a = W.modify (Just $ W.Stack a [] [])
(\(W.Stack t l r) -> if a `elem` t:l++r (\(W.Stack t l r) -> if a `elem` t:l++r
then Just $ W.Stack t l r then Just $ W.Stack t l r
else Just $ W.Stack a (L.delete a l) (L.delete a (t:r))) s else Just $ W.Stack a (L.delete a l) (L.delete a (t:r)))
-- | runOrCopy will run the provided shell command unless it can -- | runOrCopy will run the provided shell command unless it can

View File

@ -296,7 +296,7 @@ handleSelectWindow c = do
allKeys (PerScreenKeys m) = concat $ M.elems m allKeys (PerScreenKeys m) = concat $ M.elems m
buildOverlays :: [KeySym] -> [OverlayWindow] -> [Overlay] buildOverlays :: [KeySym] -> [OverlayWindow] -> [Overlay]
buildOverlays ks = appendChords (maxChordLen c) ks buildOverlays = appendChords (maxChordLen c)
buildOverlayWindows :: Display -> Position -> [Window] -> X [OverlayWindow] buildOverlayWindows :: Display -> Position -> [Window] -> X [OverlayWindow]
buildOverlayWindows dpy th ws = sequence $ buildOverlayWin dpy th <$> ws buildOverlayWindows dpy th ws = sequence $ buildOverlayWin dpy th <$> ws

View File

@ -62,7 +62,7 @@ type ExtensionActions = M.Map String (String -> X())
instance XPrompt CalculatorMode where instance XPrompt CalculatorMode where
showXPrompt CalcMode = "calc %s> " showXPrompt CalcMode = "calc %s> "
commandToComplete CalcMode = id --send the whole string to `calc` commandToComplete CalcMode = id --send the whole string to `calc`
completionFunction CalcMode = \s -> if null s then return [] else completionFunction CalcMode s = if null s then return [] else
lines <$> runProcessWithInput "calc" [s] "" lines <$> runProcessWithInput "calc" [s] ""
modeAction CalcMode _ _ = return () -- do nothing; this might copy the result to the clipboard modeAction CalcMode _ _ = return () -- do nothing; this might copy the result to the clipboard
@ -70,7 +70,7 @@ instance XPrompt CalculatorMode where
instance XPrompt HoogleMode where instance XPrompt HoogleMode where
showXPrompt _ = "hoogle %s> " showXPrompt _ = "hoogle %s> "
commandToComplete _ = id commandToComplete _ = id
completionFunction (HMode pathToHoogleBin' _) = \s -> completionFunctionWith pathToHoogleBin' ["--count","8",s] completionFunction (HMode pathToHoogleBin' _) s = completionFunctionWith pathToHoogleBin' ["--count","8",s]
-- This action calls hoogle again to find the URL corresponding to the autocompleted item -- This action calls hoogle again to find the URL corresponding to the autocompleted item
modeAction (HMode pathToHoogleBin'' browser') query result = do modeAction (HMode pathToHoogleBin'' browser') query result = do
completionsWithLink <- liftIO $ completionFunctionWith pathToHoogleBin'' ["--count","5","--link",query] completionsWithLink <- liftIO $ completionFunctionWith pathToHoogleBin'' ["--count","5","--link",query]

View File

@ -127,7 +127,7 @@ swap = withTargetWindow swapWithFocused
Just currentWin -> W.focusWindow currentWin $ Just currentWin -> W.focusWindow currentWin $
mapWindows (swapWin currentWin targetWin) winSet mapWindows (swapWin currentWin targetWin) winSet
Nothing -> winSet Nothing -> winSet
mapWindows f ss = W.mapWorkspace (mapWindows' f) ss mapWindows f = W.mapWorkspace (mapWindows' f)
mapWindows' f ws@W.Workspace{ W.stack = s } = ws { W.stack = mapWindows'' f <$> s } mapWindows' f ws@W.Workspace{ W.stack = s } = ws { W.stack = mapWindows'' f <$> s }
mapWindows'' f (W.Stack focused up down) = W.Stack (f focused) (map f up) (map f down) mapWindows'' f (W.Stack focused up down) = W.Stack (f focused) (map f up) (map f down)
swapWin win1 win2 win swapWin win1 win2 win

View File

@ -194,7 +194,7 @@ bluetileLayoutHook = avoidStruts $ minimize $ boringWindows $
fullscreen = tilingDeco $ maximize $ smartBorders Full fullscreen = tilingDeco $ maximize $ smartBorders Full
tilingDeco l = windowSwitcherDecorationWithButtons shrinkText defaultThemeWithButtons (draggingVisualizer l) tilingDeco l = windowSwitcherDecorationWithButtons shrinkText defaultThemeWithButtons (draggingVisualizer l)
floatingDeco l = buttonDeco shrinkText defaultThemeWithButtons l floatingDeco = buttonDeco shrinkText defaultThemeWithButtons
bluetileConfig = bluetileConfig =
docks . ewmhFullscreen . ewmh $ docks . ewmhFullscreen . ewmh $

View File

@ -92,10 +92,6 @@ vmask numLockMask msk = unwords $
fst $ fst $
foldr vmask' ([],msk) masks foldr vmask' ([],msk) masks
where where
#if __GLASGOW_HASKELL__ < 707
finiteBitSize x = bitSize x
#endif
masks = map (\m -> (m,show m)) [0..toEnum (finiteBitSize msk - 1)] ++ masks = map (\m -> (m,show m)) [0..toEnum (finiteBitSize msk - 1)] ++
[(numLockMask,"num" ) [(numLockMask,"num" )
,( lockMask,"lock" ) ,( lockMask,"lock" )

View File

@ -69,7 +69,7 @@ setWMName name = do
changeProperty32 dpy root atom_NET_SUPPORTED_ATOM aTOM propModeReplace (nub $ fromIntegral atom_NET_SUPPORTING_WM_CHECK : fromIntegral atom_NET_WM_NAME : supportedList) changeProperty32 dpy root atom_NET_SUPPORTED_ATOM aTOM propModeReplace (nub $ fromIntegral atom_NET_SUPPORTING_WM_CHECK : fromIntegral atom_NET_WM_NAME : supportedList)
where where
latin1StringToCCharList :: String -> [CChar] latin1StringToCCharList :: String -> [CChar]
latin1StringToCCharList str = map (fromIntegral . ord) str latin1StringToCCharList = map (fromIntegral . ord)
netSupportingWMCheckAtom :: X Atom netSupportingWMCheckAtom :: X Atom
netSupportingWMCheckAtom = getAtom "_NET_SUPPORTING_WM_CHECK" netSupportingWMCheckAtom = getAtom "_NET_SUPPORTING_WM_CHECK"

View File

@ -53,5 +53,5 @@ newtype ButtonDecoration a = NFD Bool deriving (Show, Read)
instance Eq a => DecorationStyle ButtonDecoration a where instance Eq a => DecorationStyle ButtonDecoration a where
describeDeco _ = "ButtonDeco" describeDeco _ = "ButtonDeco"
decorationCatchClicksHook _ mainw dFL dFR = titleBarButtonHandler mainw dFL dFR decorationCatchClicksHook _ = titleBarButtonHandler
decorationAfterDraggingHook _ (mainw, _) decoWin = focus mainw >> handleScreenCrossing mainw decoWin >> return () decorationAfterDraggingHook _ (mainw, _) decoWin = focus mainw >> handleScreenCrossing mainw decoWin >> return ()

View File

@ -152,7 +152,7 @@ class (Read (ds a), Show (ds a), Eq a) => DecorationStyle ds a where
-- | The description that the 'Decoration' modifier will display. -- | The description that the 'Decoration' modifier will display.
describeDeco :: ds a -> String describeDeco :: ds a -> String
describeDeco ds = show ds describeDeco = show
-- | Shrink the window's rectangle when applying a decoration. -- | Shrink the window's rectangle when applying a decoration.
shrink :: ds a -> Rectangle -> Rectangle -> Rectangle shrink :: ds a -> Rectangle -> Rectangle -> Rectangle
@ -160,7 +160,7 @@ class (Read (ds a), Show (ds a), Eq a) => DecorationStyle ds a where
-- | The decoration event hook -- | The decoration event hook
decorationEventHook :: ds a -> DecorationState -> Event -> X () decorationEventHook :: ds a -> DecorationState -> Event -> X ()
decorationEventHook ds s e = handleMouseFocusDrag ds s e decorationEventHook = handleMouseFocusDrag
-- | A hook that can be used to catch the cases when the user -- | A hook that can be used to catch the cases when the user
-- clicks on the decoration. If you return True here, the click event -- clicks on the decoration. If you return True here, the click event
@ -176,7 +176,7 @@ class (Read (ds a), Show (ds a), Eq a) => DecorationStyle ds a where
-- The hook can be overwritten if a different way of handling the dragging -- The hook can be overwritten if a different way of handling the dragging
-- is required. -- is required.
decorationWhileDraggingHook :: ds a -> CInt -> CInt -> (Window, Rectangle) -> Position -> Position -> X () decorationWhileDraggingHook :: ds a -> CInt -> CInt -> (Window, Rectangle) -> Position -> Position -> X ()
decorationWhileDraggingHook _ ex ey (mainw, r) x y = handleDraggingInProgress ex ey (mainw, r) x y decorationWhileDraggingHook _ = handleDraggingInProgress
-- | This hoook is called after a window has been dragged using the decoration. -- | This hoook is called after a window has been dragged using the decoration.
decorationAfterDraggingHook :: ds a -> (Window, Rectangle) -> Window -> X () decorationAfterDraggingHook :: ds a -> (Window, Rectangle) -> Window -> X ()

View File

@ -239,7 +239,7 @@ removeDeleted z = filterZ_ (`elemZ` z)
findNewWindows :: Eq a => [a] -> Zipper (Group l a) findNewWindows :: Eq a => [a] -> Zipper (Group l a)
-> (Zipper (Group l a), [a]) -> (Zipper (Group l a), [a])
findNewWindows as gs = (gs, foldrZ_ removePresent as gs) findNewWindows as gs = (gs, foldrZ_ removePresent as gs)
where removePresent g as' = filter (not . flip elemZ (gZipper g)) as' where removePresent g = filter (not . flip elemZ (gZipper g))
-- | Add windows to the focused group. If you need to create one, -- | Add windows to the focused group. If you need to create one,
-- use the given layout and an id from the given list. -- use the given layout and an id from the given list.

View File

@ -177,5 +177,5 @@ newtype ImageButtonDecoration a = NFD Bool deriving (Show, Read)
instance Eq a => DecorationStyle ImageButtonDecoration a where instance Eq a => DecorationStyle ImageButtonDecoration a where
describeDeco _ = "ImageButtonDeco" describeDeco _ = "ImageButtonDeco"
decorationCatchClicksHook _ mainw dFL dFR = imageTitleBarButtonHandler mainw dFL dFR decorationCatchClicksHook _ = imageTitleBarButtonHandler
decorationAfterDraggingHook _ (mainw, _) decoWin = focus mainw >> handleScreenCrossing mainw decoWin >> return () decorationAfterDraggingHook _ (mainw, _) decoWin = focus mainw >> handleScreenCrossing mainw decoWin >> return ()

View File

@ -164,7 +164,7 @@ applyHints s root (((w,lrect@(Rectangle a b c d)),adj):xs) =
$ if isInStack s w then Rectangle a b c' d' else lrect $ if isInStack s w then Rectangle a b c' d' else lrect
ds = (fromIntegral c - fromIntegral c',fromIntegral d - fromIntegral d') ds = (fromIntegral c - fromIntegral c',fromIntegral d - fromIntegral d')
growOther' r = growOther ds lrect (freeDirs root lrect) r growOther' = growOther ds lrect (freeDirs root lrect)
mapSnd f = map (first $ second f) mapSnd f = map (first $ second f)
next = applyHints s root $ mapSnd growOther' xs next = applyHints s root $ mapSnd growOther' xs
in (w,redr):next in (w,redr):next

View File

@ -107,7 +107,7 @@ class (Show (m a), Read (m a)) => LayoutModifier m a where
-> Workspace WorkspaceId (l a) a -- ^ current workspace -> Workspace WorkspaceId (l a) a -- ^ current workspace
-> Rectangle -- ^ screen rectangle -> Rectangle -- ^ screen rectangle
-> X ([(a, Rectangle)], Maybe (l a)) -> X ([(a, Rectangle)], Maybe (l a))
modifyLayout _ w r = runLayout w r modifyLayout _ = runLayout
-- | Similar to 'modifyLayout', but this function also allows you -- | Similar to 'modifyLayout', but this function also allows you
-- update the state of your layout modifier(the second value in the -- update the state of your layout modifier(the second value in the

View File

@ -99,8 +99,8 @@ instance LayoutModifier LimitWindows a where
where pos x = guard (x>=1) >> return x where pos x = guard (x>=1) >> return x
app f x = guard (f x /= x) >> return (f x) app f x = guard (f x /= x) >> return (f x)
modifyLayout (LimitWindows style n) ws r = modifyLayout (LimitWindows style n) ws =
runLayout ws { W.stack = f n <$> W.stack ws } r runLayout ws { W.stack = f n <$> W.stack ws }
where f = case style of where f = case style of
FirstN -> firstN FirstN -> firstN
Slice -> slice Slice -> slice
@ -123,8 +123,8 @@ data Selection a = Sel { nMaster :: Int, start :: Int, nRest :: Int }
deriving (Read, Show, Eq) deriving (Read, Show, Eq)
instance LayoutModifier Selection a where instance LayoutModifier Selection a where
modifyLayout s w r = modifyLayout s w =
runLayout (w { W.stack = updateAndSelect s <$> W.stack w }) r runLayout (w { W.stack = updateAndSelect s <$> W.stack w })
pureModifier sel _ stk wins = (wins, update sel <$> stk) pureModifier sel _ stk wins = (wins, update sel <$> stk)

View File

@ -71,7 +71,7 @@ instance LayoutModifier ResizeScreen a where
| ResizeScreen T i <- m = resize $ Rectangle x (y + fi i) w (h - fi i) | ResizeScreen T i <- m = resize $ Rectangle x (y + fi i) w (h - fi i)
| ResizeScreen B i <- m = resize $ Rectangle x y w (h - fi i) | ResizeScreen B i <- m = resize $ Rectangle x y w (h - fi i)
| WithNewScreen r <- m = resize r | WithNewScreen r <- m = resize r
where resize nr = runLayout ws nr where resize = runLayout ws
pureMess (ResizeScreen d _) m pureMess (ResizeScreen d _) m
| Just (SetTheme t) <- fromMessage m = Just $ ResizeScreen d (fi $ decoHeight t) | Just (SetTheme t) <- fromMessage m = Just $ ResizeScreen d (fi $ decoHeight t)

View File

@ -77,7 +77,7 @@ instance Default SWNConfig where
} }
instance LayoutModifier ShowWName a where instance LayoutModifier ShowWName a where
redoLayout sn r _ wrs = doShow sn r wrs redoLayout sn r _ = doShow sn r
handleMess (SWN _ c (Just (i,w))) m handleMess (SWN _ c (Just (i,w))) m
| Just e <- fromMessage m = handleTimer i e (deleteWindow w >> return Nothing) | Just e <- fromMessage m = handleTimer i e (deleteWindow w >> return Nothing)

View File

@ -84,7 +84,7 @@ instance Eq a => DecorationStyle WindowSwitcherDecoration a where
decorationCatchClicksHook (WSD withButtons) mainw dFL dFR = if withButtons decorationCatchClicksHook (WSD withButtons) mainw dFL dFR = if withButtons
then titleBarButtonHandler mainw dFL dFR then titleBarButtonHandler mainw dFL dFR
else return False else return False
decorationWhileDraggingHook _ ex ey (mainw, r) x y = handleTiledDraggingInProgress ex ey (mainw, r) x y decorationWhileDraggingHook _ = handleTiledDraggingInProgress
decorationAfterDraggingHook _ (mainw, _) decoWin = do focus mainw decorationAfterDraggingHook _ (mainw, _) decoWin = do focus mainw
hasCrossed <- handleScreenCrossing mainw decoWin hasCrossed <- handleScreenCrossing mainw decoWin
unless hasCrossed $ do sendMessage DraggingStopped unless hasCrossed $ do sendMessage DraggingStopped
@ -105,7 +105,7 @@ instance Eq a => DecorationStyle ImageWindowSwitcherDecoration a where
decorationCatchClicksHook (IWSD withButtons) mainw dFL dFR = if withButtons decorationCatchClicksHook (IWSD withButtons) mainw dFL dFR = if withButtons
then imageTitleBarButtonHandler mainw dFL dFR then imageTitleBarButtonHandler mainw dFL dFR
else return False else return False
decorationWhileDraggingHook _ ex ey (mainw, r) x y = handleTiledDraggingInProgress ex ey (mainw, r) x y decorationWhileDraggingHook _ = handleTiledDraggingInProgress
decorationAfterDraggingHook _ (mainw, _) decoWin = do focus mainw decorationAfterDraggingHook _ (mainw, _) decoWin = do focus mainw
hasCrossed <- handleScreenCrossing mainw decoWin hasCrossed <- handleScreenCrossing mainw decoWin
unless hasCrossed $ do sendMessage DraggingStopped unless hasCrossed $ do sendMessage DraggingStopped

View File

@ -271,7 +271,7 @@ class XPrompt t where
-- The argument passed to this function is given by `commandToComplete` -- The argument passed to this function is given by `commandToComplete`
-- The default implementation shows an error message. -- The default implementation shows an error message.
completionFunction :: t -> ComplFunction completionFunction :: t -> ComplFunction
completionFunction t = \_ -> return ["Completions for " ++ showXPrompt t ++ " could not be loaded"] completionFunction t = const $ return ["Completions for " ++ showXPrompt t ++ " could not be loaded"]
-- | When the prompt has multiple modes (created with mkXPromptWithModes), this function is called -- | When the prompt has multiple modes (created with mkXPromptWithModes), this function is called
-- when the user picks an item from the autocompletion list. -- when the user picks an item from the autocompletion list.
@ -748,7 +748,7 @@ handleCompletion cs = do
alwaysHlight <- gets $ alwaysHighlight . config alwaysHlight <- gets $ alwaysHighlight . config
st <- get st <- get
let updateWins l = redrawWindows (pure ()) l let updateWins = redrawWindows (pure ())
updateState l = if alwaysHlight updateState l = if alwaysHlight
then hlComplete (getLastWord $ command st) l st then hlComplete (getLastWord $ command st) l st
else simpleComplete l st else simpleComplete l st

View File

@ -92,8 +92,8 @@ instance XPrompt WindowModePrompt where
showXPrompt (WindowModePrompt action _ _) = showXPrompt (WindowModePrompt action _ _) =
showXPrompt action showXPrompt action
completionFunction (WindowModePrompt _ winmap predicate) = completionFunction (WindowModePrompt _ winmap predicate) s =
\s -> return . filter (predicate s) . map fst . M.toList $ winmap return . filter (predicate s) . map fst . M.toList $ winmap
modeAction (WindowModePrompt action winmap _) buf auto = do modeAction (WindowModePrompt action winmap _) buf auto = do
let name = if null auto then buf else auto let name = if null auto then buf else auto

View File

@ -162,20 +162,20 @@ focusUpZ :: Zipper a -> Zipper a
focusUpZ Nothing = Nothing focusUpZ Nothing = Nothing
focusUpZ (Just s) | u:up <- W.up s = Just $ W.Stack u up (W.focus s:W.down s) focusUpZ (Just s) | u:up <- W.up s = Just $ W.Stack u up (W.focus s:W.down s)
focusUpZ (Just s) | null $ W.down s = Just s focusUpZ (Just s) | null $ W.down s = Just s
focusUpZ (Just (W.Stack f _ down)) = Just $ W.Stack (last down) (reverse (init down) ++ [f]) [] focusUpZ (Just (W.Stack f _ down)) = Just $ W.Stack (last down) (tail (reverse down) ++ [f]) []
-- | Move the focus to the next element -- | Move the focus to the next element
focusDownZ :: Zipper a -> Zipper a focusDownZ :: Zipper a -> Zipper a
focusDownZ Nothing = Nothing focusDownZ Nothing = Nothing
focusDownZ (Just s) | d:down <- W.down s = Just $ W.Stack d (W.focus s:W.up s) down focusDownZ (Just s) | d:down <- W.down s = Just $ W.Stack d (W.focus s:W.up s) down
focusDownZ (Just s) | null $ W.up s = Just s focusDownZ (Just s) | null $ W.up s = Just s
focusDownZ (Just (W.Stack f up _)) = Just $ W.Stack (last up) [] (reverse (init up) ++ [f]) focusDownZ (Just (W.Stack f up _)) = Just $ W.Stack (last up) [] (tail (reverse up) ++ [f])
-- | Move the focus to the first element -- | Move the focus to the first element
focusMasterZ :: Zipper a -> Zipper a focusMasterZ :: Zipper a -> Zipper a
focusMasterZ Nothing = Nothing focusMasterZ Nothing = Nothing
focusMasterZ (Just (W.Stack f up down)) | not $ null up focusMasterZ (Just (W.Stack f up down)) | not $ null up
= Just $ W.Stack (last up) [] (reverse (init up) ++ [f] ++ down) = Just $ W.Stack (last up) [] (tail (reverse up) ++ [f] ++ down)
focusMasterZ (Just s) = Just s focusMasterZ (Just s) = Just s
-- | Refocus a @Stack a@ on an element satisfying the predicate, or fail to -- | Refocus a @Stack a@ on an element satisfying the predicate, or fail to
@ -284,7 +284,7 @@ deleteFocusedZ = filterZ (\b _ -> not b)
-- | Delete the ith element -- | Delete the ith element
deleteIndexZ :: Int -> Zipper a -> Zipper a deleteIndexZ :: Int -> Zipper a -> Zipper a
deleteIndexZ i z = let numbered = (fromTags . zipWith number [0..] . toTags) z deleteIndexZ i z = let numbered = (fromTags . zipWith number [0..] . toTags) z
number j ea = mapE (\_ a -> (j,a)) ea number j = mapE (\_ a -> (j,a))
in mapZ_ snd $ filterZ_ ((/=i) . fst) numbered in mapZ_ snd $ filterZ_ ((/=i) . fst) numbered
-- ** Folds -- ** Folds