mirror of
https://github.com/xmonad/xmonad-contrib.git
synced 2025-05-19 11:30:22 -07:00
Merge pull request #320 from slotThe/master
Remove legacy code regarding fmap
This commit is contained in:
commit
c3bb1cb2e7
@ -262,7 +262,7 @@ wsTypeToPred HiddenEmptyWS = do ne <- wsTypeToPred EmptyWS
|
||||
hi <- wsTypeToPred HiddenWS
|
||||
return (\w -> hi w && ne w)
|
||||
wsTypeToPred AnyWS = return (const True)
|
||||
wsTypeToPred (WSTagGroup sep) = do cur <- (groupName.workspace.current) `fmap` gets windowset
|
||||
wsTypeToPred (WSTagGroup sep) = do cur <- (groupName.workspace.current) <$> gets windowset
|
||||
return $ (cur ==).groupName
|
||||
where groupName = takeWhile (/=sep).tag
|
||||
wsTypeToPred (WSIs p) = p
|
||||
|
@ -231,7 +231,7 @@ dynamicProjectsStartupHook ps = XS.modify go
|
||||
--------------------------------------------------------------------------------
|
||||
-- | Find a project based on its name.
|
||||
lookupProject :: ProjectName -> X (Maybe Project)
|
||||
lookupProject name = Map.lookup name `fmap` XS.gets projects
|
||||
lookupProject name = Map.lookup name <$> XS.gets projects
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
-- | Fetch the current project (the one being used for the currently
|
||||
@ -327,7 +327,7 @@ changeProjectDirPrompt = projectPrompt [ DirMode
|
||||
-- | Prompt for a project name.
|
||||
projectPrompt :: [ProjectMode] -> XPConfig -> X ()
|
||||
projectPrompt submodes c = do
|
||||
ws <- map W.tag `fmap` gets (W.workspaces . windowset)
|
||||
ws <- map W.tag <$> gets (W.workspaces . windowset)
|
||||
ps <- XS.gets projects
|
||||
|
||||
let names = sort (Map.keys ps `union` ws)
|
||||
|
@ -108,7 +108,7 @@ withWorkspaceIndex job widx = do
|
||||
maybe (return ()) (windows . job) wtag
|
||||
where
|
||||
ilookup :: WorkspaceIndex -> X (Maybe WorkspaceTag)
|
||||
ilookup idx = Map.lookup idx `fmap` XS.gets workspaceIndexMap
|
||||
ilookup idx = Map.lookup idx <$> XS.gets workspaceIndexMap
|
||||
|
||||
|
||||
mkCompl :: [String] -> String -> IO [String]
|
||||
|
@ -27,7 +27,6 @@ module XMonad.Actions.FloatSnap (
|
||||
ifClick') where
|
||||
|
||||
import XMonad
|
||||
import Control.Applicative((<$>))
|
||||
import Data.List (sort)
|
||||
import Data.Maybe (listToMaybe,fromJust,isNothing)
|
||||
import qualified XMonad.StackSet as W
|
||||
@ -291,8 +290,8 @@ getSnap horiz collidedist d w = do
|
||||
screen <- W.current <$> gets windowset
|
||||
let sr = screenRect $ W.screenDetail screen
|
||||
wl = W.integrate' . W.stack $ W.workspace screen
|
||||
gr <- fmap ($sr) $ calcGap $ S.fromList [minBound .. maxBound]
|
||||
wla <- filter (collides wa) `fmap` (io $ mapM (getWindowAttributes d) $ filter (/=w) wl)
|
||||
gr <- ($sr) <$> calcGap (S.fromList [minBound .. maxBound])
|
||||
wla <- filter (collides wa) <$> (io $ mapM (getWindowAttributes d) $ filter (/=w) wl)
|
||||
|
||||
return ( neighbours (back wa sr gr wla) (wpos wa)
|
||||
, neighbours (front wa sr gr wla) (wpos wa + wdim wa)
|
||||
|
@ -435,7 +435,7 @@ shadowWithKeymap keymap dflt keyEvent@(ks,_,m') = fromMaybe (dflt keyEvent) (M.l
|
||||
select :: TwoD a (Maybe a)
|
||||
select = do
|
||||
s <- get
|
||||
return $ fmap (snd . snd) $ findInElementMap (td_curpos s) (td_elementmap s)
|
||||
return $ snd . snd <$> findInElementMap (td_curpos s) (td_elementmap s)
|
||||
|
||||
-- | Closes gridselect returning no element.
|
||||
cancel :: TwoD a (Maybe a)
|
||||
@ -711,11 +711,11 @@ windowMap = do
|
||||
ws <- gets windowset
|
||||
wins <- mapM keyValuePair (W.allWindows ws)
|
||||
return wins
|
||||
where keyValuePair w = flip (,) w `fmap` decorateName' w
|
||||
where keyValuePair w = flip (,) w <$> decorateName' w
|
||||
|
||||
decorateName' :: Window -> X String
|
||||
decorateName' w = do
|
||||
fmap show $ getName w
|
||||
show <$> getName w
|
||||
|
||||
-- | Builds a default gs config from a colorizer function.
|
||||
buildDefaultGSConfig :: (a -> Bool -> X (String,String)) -> GSConfig a
|
||||
|
@ -127,7 +127,7 @@ focusNextMatchOrDo qry act = findM (runQuery qry)
|
||||
-- Returns the list of windows ordered by workspace as specified in
|
||||
-- ~/.xmonad/xmonad.hs
|
||||
orderedWindowList :: Direction -> X (Seq Window)
|
||||
orderedWindowList History = liftM (\(HistoryDB w ws) -> maybe ws (ws |>) w) XS.get
|
||||
orderedWindowList History = fmap (\(HistoryDB w ws) -> maybe ws (ws |>) w) XS.get
|
||||
orderedWindowList dir = withWindowSet $ \ss -> do
|
||||
wsids <- asks (Seq.fromList . workspaces . config)
|
||||
let wspcs = orderedWorkspaceList ss wsids
|
||||
|
@ -63,7 +63,7 @@ instance XPrompt CalculatorMode where
|
||||
showXPrompt CalcMode = "calc %s> "
|
||||
commandToComplete CalcMode = id --send the whole string to `calc`
|
||||
completionFunction CalcMode = \s -> if (length s == 0) then return [] else do
|
||||
fmap lines $ runProcessWithInput "calc" [s] ""
|
||||
lines <$> runProcessWithInput "calc" [s] ""
|
||||
modeAction CalcMode _ _ = return () -- do nothing; this might copy the result to the clipboard
|
||||
|
||||
-- | Uses the program `hoogle` to search for functions
|
||||
@ -88,7 +88,7 @@ instance XPrompt HoogleMode where
|
||||
|
||||
-- | Creates an autocompletion function for a programm given the program's name and a list of args to send to the command.
|
||||
completionFunctionWith :: String -> [String] -> IO [String]
|
||||
completionFunctionWith cmd args = do fmap lines $ runProcessWithInput cmd args ""
|
||||
completionFunctionWith cmd args = do lines <$> runProcessWithInput cmd args ""
|
||||
|
||||
-- | Creates a prompt with the given modes
|
||||
launcherPrompt :: XPConfig -> [XPMode] -> X()
|
||||
|
@ -57,7 +57,7 @@ import XMonad.Operations ( updateLayout, windowBracket, modifyWindowSet )
|
||||
import Data.Maybe ( isJust )
|
||||
import Control.Monad ( void )
|
||||
import Control.Monad.State ( gets )
|
||||
import Control.Applicative ( (<$>), liftA2 )
|
||||
import Control.Applicative ( liftA2 )
|
||||
|
||||
-- $usage
|
||||
-- You can use this module with the following in your @~\/.xmonad\/xmonad.hs@:
|
||||
|
@ -43,7 +43,6 @@ import XMonad.Util.Minimize
|
||||
import XMonad.Util.WindowProperties (getProp32)
|
||||
|
||||
import Foreign.C.Types (CLong)
|
||||
import Control.Applicative((<$>))
|
||||
import Control.Monad (join)
|
||||
import Data.Maybe (fromMaybe, listToMaybe)
|
||||
import qualified Data.List as L
|
||||
|
@ -27,7 +27,7 @@ toggleBorder :: Window -> X ()
|
||||
toggleBorder w = do
|
||||
bw <- asks (borderWidth . config)
|
||||
withDisplay $ \d -> io $ do
|
||||
cw <- wa_border_width `fmap` getWindowAttributes d w
|
||||
cw <- wa_border_width <$> getWindowAttributes d w
|
||||
if cw == 0
|
||||
then setWindowBorderWidth d w bw
|
||||
else setWindowBorderWidth d w 0
|
||||
|
@ -24,7 +24,6 @@ module XMonad.Actions.RandomBackground (
|
||||
import XMonad(X, XConf(config), XConfig(terminal), io, spawn,
|
||||
MonadIO, asks)
|
||||
import System.Random
|
||||
import Control.Monad(liftM)
|
||||
import Numeric(showHex)
|
||||
|
||||
-- $usage
|
||||
@ -55,7 +54,7 @@ randPermutation xs g = swap $ zip (randoms g) xs
|
||||
|
||||
-- | @randomBg'@ produces a random hex number in the form @'#xxyyzz'@
|
||||
randomBg' :: (MonadIO m) => RandomColor -> m String
|
||||
randomBg' (RGB l h) = io $ liftM (toHex . take 3 . randomRs (l,h)) newStdGen
|
||||
randomBg' (RGB l h) = io $ fmap (toHex . take 3 . randomRs (l,h)) newStdGen
|
||||
randomBg' (HSV s v) = io $ do
|
||||
g <- newStdGen
|
||||
let x = (^(2::Int)) $ fst $ randomR (0,sqrt $ pi / 3) g
|
||||
|
@ -65,7 +65,6 @@ import qualified Data.Set as S
|
||||
import Data.List
|
||||
import Data.Maybe
|
||||
import Control.Arrow
|
||||
import Control.Applicative ((<$>),(<*>))
|
||||
import Control.Monad
|
||||
|
||||
|
||||
|
@ -89,7 +89,7 @@ getTags w = withDisplay $ \d ->
|
||||
|
||||
-- | check a window for the given tag
|
||||
hasTag :: String -> Window -> X Bool
|
||||
hasTag s w = (s `elem`) `fmap` getTags w
|
||||
hasTag s w = (s `elem`) <$> getTags w
|
||||
|
||||
-- | add a tag to the existing ones
|
||||
addTag :: String -> Window -> X ()
|
||||
|
@ -46,7 +46,8 @@ import Data.List
|
||||
import Data.Maybe (fromMaybe, isNothing, listToMaybe, fromJust)
|
||||
import Data.Ord
|
||||
import qualified Data.Map as M
|
||||
import Control.Monad (liftM2,when,unless,replicateM_)
|
||||
import Control.Applicative (liftA2)
|
||||
import Control.Monad (when,unless,replicateM_)
|
||||
import System.IO
|
||||
|
||||
import qualified XMonad.StackSet as W
|
||||
@ -264,7 +265,7 @@ pprWindowSet tg pp = do
|
||||
-- | Given a prompt configuration and a topic configuration, triggers the action associated with
|
||||
-- the topic given in prompt.
|
||||
topicActionWithPrompt :: XPConfig -> TopicConfig -> X ()
|
||||
topicActionWithPrompt xp tg = workspacePrompt xp (liftM2 (>>) (switchTopic tg) (topicAction tg))
|
||||
topicActionWithPrompt xp tg = workspacePrompt xp (liftA2 (>>) (switchTopic tg) (topicAction tg))
|
||||
|
||||
-- | Given a configuration and a topic, triggers the action associated with the given topic.
|
||||
topicAction :: TopicConfig -> Topic -> X ()
|
||||
|
@ -24,7 +24,6 @@ module XMonad.Actions.WindowBringer (
|
||||
windowMap, windowAppMap, windowMap', bringWindow, actionMenu
|
||||
) where
|
||||
|
||||
import Control.Applicative((<$>))
|
||||
import qualified Data.Map as M
|
||||
|
||||
import qualified XMonad.StackSet as W
|
||||
|
@ -43,7 +43,6 @@ import XMonad
|
||||
import XMonad.Util.Types (Direction2D(..))
|
||||
import qualified XMonad.StackSet as W
|
||||
|
||||
import Control.Applicative ((<$>))
|
||||
import Control.Arrow (second)
|
||||
import Data.IORef
|
||||
import Data.List (sortBy)
|
||||
|
@ -48,8 +48,8 @@ import XMonad.Layout.LayoutModifier(ModifiedLayout(..),
|
||||
LayoutModifier(handleMess, redoLayout))
|
||||
import XMonad(Typeable, Message, WorkspaceId, X, XState(windowset),
|
||||
fromMessage, sendMessage, windows, gets)
|
||||
import Control.Monad((<=<), guard, liftM, liftM2, when)
|
||||
import Control.Applicative((<$>))
|
||||
import Control.Applicative (liftA2)
|
||||
import Control.Monad((<=<), guard, when)
|
||||
import Data.Foldable(Foldable(foldMap), toList)
|
||||
import Data.Maybe(fromJust, listToMaybe)
|
||||
import Data.Monoid(Monoid(mappend, mconcat))
|
||||
@ -161,12 +161,12 @@ focusDepth (Cons x) = 1 + focusDepth (W.focus x)
|
||||
focusDepth (End _) = 0
|
||||
|
||||
descend :: Monad m =>(W.Stack (Cursors a) -> m (W.Stack (Cursors a)))-> Int-> Cursors a-> m (Cursors a)
|
||||
descend f 1 (Cons x) = Cons `liftM` f x
|
||||
descend f n (Cons x) | n > 1 = liftM Cons $ descend f (pred n) `onFocus` x
|
||||
descend f 1 (Cons x) = Cons <$> f x
|
||||
descend f n (Cons x) | n > 1 = fmap Cons $ descend f (pred n) `onFocus` x
|
||||
descend _ _ x = return x
|
||||
|
||||
onFocus :: (Monad m) => (a1 -> m a1) -> W.Stack a1 -> m (W.Stack a1)
|
||||
onFocus f st = (\x -> st { W.focus = x}) `liftM` f (W.focus st)
|
||||
onFocus f st = (\x -> st { W.focus = x}) <$> f (W.focus st)
|
||||
|
||||
-- | @modifyLayer@ is used to change the focus at a given depth
|
||||
modifyLayer :: (W.Stack (Cursors String) -> W.Stack (Cursors String)) -> Int -> X ()
|
||||
@ -192,7 +192,7 @@ modifyLayer' :: (W.Stack (Cursors String) -> X (W.Stack (Cursors String))) -> In
|
||||
modifyLayer' f depth = modifyCursors (descend f depth)
|
||||
|
||||
modifyCursors :: (Cursors String -> X (Cursors String)) -> X ()
|
||||
modifyCursors = sendMessage . ChangeCursors . (liftM2 (>>) updateXMD return <=<)
|
||||
modifyCursors = sendMessage . ChangeCursors . (liftA2 (>>) updateXMD return <=<)
|
||||
|
||||
data WorkspaceCursors a = WorkspaceCursors (Cursors String)
|
||||
deriving (Typeable,Read,Show)
|
||||
|
@ -106,7 +106,7 @@ getWorkspaceNames = do
|
||||
|
||||
-- | Gets the name of a workspace, if set, otherwise returns nothing.
|
||||
getWorkspaceName :: WorkspaceId -> X (Maybe String)
|
||||
getWorkspaceName w = ($ w) `fmap` getWorkspaceNames'
|
||||
getWorkspaceName w = ($ w) <$> getWorkspaceNames'
|
||||
|
||||
-- | Gets the name of the current workspace. See 'getWorkspaceName'
|
||||
getCurrentWorkspaceName :: X (Maybe String)
|
||||
|
@ -72,7 +72,7 @@ gnomeRun = withDisplay $ \dpy -> do
|
||||
-- > gconftool-2 -s /desktop/gnome/session/required_components/windowmanager xmonad --type string
|
||||
gnomeRegister :: MonadIO m => m ()
|
||||
gnomeRegister = io $ do
|
||||
x <- lookup "DESKTOP_AUTOSTART_ID" `fmap` getEnvironment
|
||||
x <- lookup "DESKTOP_AUTOSTART_ID" <$> getEnvironment
|
||||
whenJust x $ \sessionId -> safeSpawn "dbus-send"
|
||||
["--session"
|
||||
,"--print-reply=literal"
|
||||
|
@ -77,7 +77,7 @@ mateRun = withDisplay $ \dpy -> do
|
||||
-- (the extra quotes are required by dconf)
|
||||
mateRegister :: MonadIO m => m ()
|
||||
mateRegister = io $ do
|
||||
x <- lookup "DESKTOP_AUTOSTART_ID" `fmap` getEnvironment
|
||||
x <- lookup "DESKTOP_AUTOSTART_ID" <$> getEnvironment
|
||||
whenJust x $ \sessionId -> safeSpawn "dbus-send"
|
||||
["--session"
|
||||
,"--print-reply=literal"
|
||||
|
@ -190,7 +190,7 @@ debugEventsHook' (ClientMessageEvent {ev_window = w
|
||||
ta <- getAtom ta'
|
||||
return (ta,b,l)
|
||||
let wl = bytes b
|
||||
vs <- io $ take (l * wl) `fmap` splitCInt vs'
|
||||
vs <- io $ take (l * wl) <$> splitCInt vs'
|
||||
s <- dumpProperty' w a n ta b vs 0 (10 + length n)
|
||||
say " message" $ n ++ s
|
||||
|
||||
@ -199,7 +199,7 @@ debugEventsHook' _ = return ()
|
||||
-- | Emit information about an atom.
|
||||
atomName :: Atom -> X String
|
||||
atomName a = withDisplay $ \d ->
|
||||
io $ fromMaybe ("(unknown atom " ++ show a ++ ")") `fmap` getAtomName d a
|
||||
io $ fromMaybe ("(unknown atom " ++ show a ++ ")") <$> getAtomName d a
|
||||
|
||||
-- | Emit an atom with respect to the current event.
|
||||
atomEvent :: String -> Atom -> X ()
|
||||
@ -313,9 +313,9 @@ dumpProperty a n w i = do
|
||||
vsp
|
||||
case rc of
|
||||
0 -> do
|
||||
fmt <- fromIntegral `fmap` peek fmtp
|
||||
fmt <- fromIntegral <$> peek fmtp
|
||||
vs' <- peek vsp
|
||||
sz <- fromIntegral `fmap` peek szp
|
||||
sz <- fromIntegral <$> peek szp
|
||||
case () of
|
||||
() | fmt == none -> xFree vs' >> return (Left "(property deleted)" )
|
||||
| sz < 0 -> xFree vs' >> return (Left $ "(illegal bit size " ++
|
||||
@ -325,9 +325,9 @@ dumpProperty a n w i = do
|
||||
show sz ++
|
||||
")" )
|
||||
| otherwise -> do
|
||||
len <- fromIntegral `fmap` peek lenp
|
||||
len <- fromIntegral <$> peek lenp
|
||||
-- that's as in "ack! it's fugged!"
|
||||
ack <- fromIntegral `fmap` peek ackp
|
||||
ack <- fromIntegral <$> peek ackp
|
||||
vs <- peekArray (len * bytes sz) vs'
|
||||
_ <- xFree vs'
|
||||
return $ Right (fmt,sz,ack,vs)
|
||||
@ -527,7 +527,7 @@ dumpProp a _ | a == wM_NAME = dumpString
|
||||
| a == sECONDARY = dumpSelection
|
||||
-- this is gross
|
||||
| a == wM_TRANSIENT_FOR = do
|
||||
root <- fromIntegral `fmap` inX (asks theRoot)
|
||||
root <- fromIntegral <$> inX (asks theRoot)
|
||||
w <- asks window
|
||||
WMHints {wmh_window_group = group} <-
|
||||
inX $ asks display >>= io . flip getWMHints w
|
||||
@ -740,7 +740,7 @@ dumpSelection = do
|
||||
-- for now, not querying Xkb
|
||||
dumpXKlInds :: Decoder Bool
|
||||
dumpXKlInds = guardType iNTEGER $ do
|
||||
n <- fmap fromIntegral `fmap` getInt' 32
|
||||
n <- fmap fromIntegral <$> getInt' 32
|
||||
case n of
|
||||
Nothing -> propShortErr
|
||||
Just is -> append $ "indicators " ++ unwords (dumpInds is 1 1 [])
|
||||
@ -849,7 +849,7 @@ dumpPixmap = guardType pIXMAP $ do
|
||||
Just p -> do
|
||||
append $ "pixmap " ++ showHex p ""
|
||||
g' <- inX $ withDisplay $ \d -> io $
|
||||
Just `fmap` getGeometry d (fromIntegral p)
|
||||
(Just <$> getGeometry d (fromIntegral p))
|
||||
`E.catch`
|
||||
\e -> case fromException e of
|
||||
Just x -> throw e `const` (x `asTypeOf` ExitSuccess)
|
||||
@ -945,7 +945,7 @@ dumpPid = guardType cARDINAL $ do
|
||||
case o of
|
||||
Nothing -> append $ "pid " ++ pid
|
||||
Just p' -> do
|
||||
prc <- io $ lines `fmap` hGetContents p'
|
||||
prc <- io $ lines <$> hGetContents p'
|
||||
-- deliberately forcing it
|
||||
append $ if length prc < 2
|
||||
then "pid " ++ pid
|
||||
@ -1007,7 +1007,7 @@ dumpMDBlocks _ = propSimple "(drop site info)" -- @@@ maybe later if needed
|
||||
|
||||
dumpMotifEndian :: Decoder Bool
|
||||
dumpMotifEndian = guardType cARDINAL $ guardSize 8 $ do
|
||||
c <- map twiddle `fmap` eat 1
|
||||
c <- map twiddle <$> eat 1
|
||||
case c of
|
||||
['l'] -> append "little"
|
||||
['B'] -> append "big"
|
||||
@ -1166,7 +1166,7 @@ getInt' 64 = guardR width 32 (\a e -> propSizeErr a e >> return Nothing) $
|
||||
return $ Just $ lo + hi * (fromIntegral (maxBound :: Word32) + 1)
|
||||
getInt' w = guardR width w (\a e -> propSizeErr a e >> return Nothing) $
|
||||
guardSize' (bytes w) (propShortErr >> return Nothing) $
|
||||
Just `fmap` inhale w
|
||||
Just <$> inhale w
|
||||
|
||||
-- parse an integral value and feed it to a show-er of some kind
|
||||
getInt :: Int -> (Integer -> String) -> Decoder Bool
|
||||
@ -1199,7 +1199,7 @@ inhale b = error $ "inhale " ++ show b
|
||||
|
||||
eat :: Int -> Decoder Raw
|
||||
eat n = do
|
||||
(bs,rest) <- splitAt n `fmap` gets value
|
||||
(bs,rest) <- splitAt n <$> gets value
|
||||
modify (\r -> r {value = rest})
|
||||
return bs
|
||||
|
||||
|
@ -59,7 +59,8 @@ module XMonad.Hooks.DynamicLog (
|
||||
-- Useful imports
|
||||
|
||||
import Codec.Binary.UTF8.String (encodeString)
|
||||
import Control.Monad (liftM2, msum)
|
||||
import Control.Applicative (liftA2)
|
||||
import Control.Monad (msum)
|
||||
import Data.Char ( isSpace, ord )
|
||||
import Data.List (intersperse, stripPrefix, isPrefixOf, sortBy)
|
||||
import Data.Maybe ( isJust, catMaybes, mapMaybe, fromMaybe )
|
||||
@ -229,7 +230,7 @@ statusBar cmd pp k conf = do
|
||||
, logHook = do
|
||||
logHook conf
|
||||
dynamicLogWithPP pp { ppOutput = hPutStrLn h }
|
||||
, keys = liftM2 M.union keys' (keys conf)
|
||||
, keys = liftA2 M.union keys' (keys conf)
|
||||
}
|
||||
where
|
||||
keys' = (`M.singleton` sendMessage ToggleStruts) . k
|
||||
@ -321,7 +322,7 @@ pprWindowSet sort' urgents pp s = sepBy (ppWsSep pp) . map fmt . sort' $
|
||||
where printer | any (\x -> maybe False (== S.tag w) (S.findTag x s)) urgents = ppUrgent
|
||||
| S.tag w == this = ppCurrent
|
||||
| S.tag w `elem` visibles && isJust (S.stack w) = ppVisible
|
||||
| S.tag w `elem` visibles = liftM2 fromMaybe ppVisible ppVisibleNoWindows
|
||||
| S.tag w `elem` visibles = liftA2 fromMaybe ppVisible ppVisibleNoWindows
|
||||
| isJust (S.stack w) = ppHidden
|
||||
| otherwise = ppHiddenNoWindows
|
||||
|
||||
|
@ -25,7 +25,6 @@ module XMonad.Hooks.EwmhDesktops (
|
||||
) where
|
||||
|
||||
import Codec.Binary.UTF8.String (encode)
|
||||
import Control.Applicative((<$>))
|
||||
import Data.List
|
||||
import Data.Maybe
|
||||
import Data.Monoid
|
||||
@ -224,7 +223,7 @@ fullscreenEventHook :: Event -> X All
|
||||
fullscreenEventHook (ClientMessageEvent _ _ _ dpy win typ (action:dats)) = do
|
||||
wmstate <- getAtom "_NET_WM_STATE"
|
||||
fullsc <- getAtom "_NET_WM_STATE_FULLSCREEN"
|
||||
wstate <- fromMaybe [] `fmap` getProp32 wmstate win
|
||||
wstate <- fromMaybe [] <$> getProp32 wmstate win
|
||||
|
||||
let isFull = fromIntegral fullsc `elem` wstate
|
||||
|
||||
|
@ -28,6 +28,7 @@ module XMonad.Hooks.FadeInactive (
|
||||
|
||||
import XMonad
|
||||
import qualified XMonad.StackSet as W
|
||||
import Control.Applicative (liftA2)
|
||||
import Control.Monad
|
||||
|
||||
-- $usage
|
||||
@ -112,4 +113,4 @@ fadeOutLogHook :: Query Rational -> X ()
|
||||
fadeOutLogHook qry = withWindowSet $ \s -> do
|
||||
let visibleWins = (W.integrate' . W.stack . W.workspace . W.current $ s) ++
|
||||
concatMap (W.integrate' . W.stack . W.workspace) (W.visible s)
|
||||
forM_ visibleWins $ liftM2 (=<<) setOpacity (runQuery qry)
|
||||
forM_ visibleWins $ liftA2 (=<<) setOpacity (runQuery qry)
|
||||
|
@ -22,7 +22,6 @@ module XMonad.Hooks.InsertPosition (
|
||||
|
||||
import XMonad(ManageHook, MonadReader(ask))
|
||||
import qualified XMonad.StackSet as W
|
||||
import Control.Applicative((<$>))
|
||||
import Data.Maybe(fromMaybe)
|
||||
import Data.List(find)
|
||||
import Data.Monoid(Endo(Endo))
|
||||
|
@ -167,7 +167,7 @@ getStrut w = do
|
||||
msp <- getProp32s "_NET_WM_STRUT_PARTIAL" w
|
||||
case msp of
|
||||
Just sp -> return $ parseStrutPartial sp
|
||||
Nothing -> fmap (maybe [] parseStrut) $ getProp32s "_NET_WM_STRUT" w
|
||||
Nothing -> maybe [] parseStrut <$> getProp32s "_NET_WM_STRUT" w
|
||||
where
|
||||
parseStrut xs@[_, _, _, _] = parseStrutPartial . take 12 $ xs ++ cycle [minBound, maxBound]
|
||||
parseStrut _ = []
|
||||
@ -182,7 +182,7 @@ getStrut w = do
|
||||
calcGap :: S.Set Direction2D -> X (Rectangle -> Rectangle)
|
||||
calcGap ss = withDisplay $ \dpy -> do
|
||||
rootw <- asks theRoot
|
||||
struts <- (filter careAbout . concat) `fmap` XS.gets (M.elems . fromStrutCache)
|
||||
struts <- (filter careAbout . concat) <$> XS.gets (M.elems . fromStrutCache)
|
||||
|
||||
-- we grab the window attributes of the root window rather than checking
|
||||
-- the width of the screen because xlib caches this info and it tends to
|
||||
|
@ -40,7 +40,6 @@ import XMonad.Hooks.ManageDocks
|
||||
import XMonad.Layout.Decoration
|
||||
|
||||
import System.Random(randomRIO)
|
||||
import Control.Applicative((<$>))
|
||||
import Control.Monad(when)
|
||||
import Data.Maybe
|
||||
import Data.Monoid
|
||||
|
@ -65,7 +65,7 @@ addScreenCorner corner xF = do
|
||||
(win,xFunc) <- case find (\(_,(sc,_)) -> sc == corner) (M.toList m) of
|
||||
|
||||
Just (w, (_,xF')) -> return (w, xF' >> xF) -- chain X actions
|
||||
Nothing -> flip (,) xF `fmap` createWindowAt corner
|
||||
Nothing -> flip (,) xF <$> createWindowAt corner
|
||||
|
||||
XS.modify $ \(ScreenCornerState m') -> ScreenCornerState $ M.insert win (corner,xFunc) m'
|
||||
|
||||
|
@ -65,7 +65,7 @@ setWMName name = do
|
||||
-- set WM_NAME in supportWindow (now only accepts latin1 names to eliminate dependency on utf8 encoder)
|
||||
changeProperty8 dpy supportWindow atom_NET_WM_NAME atom_UTF8_STRING 0 (latin1StringToCCharList name)
|
||||
-- declare which _NET protocols are supported (append to the list if it exists)
|
||||
supportedList <- fmap (join . maybeToList) $ getWindowProperty32 dpy atom_NET_SUPPORTED_ATOM root
|
||||
supportedList <- join . maybeToList <$> getWindowProperty32 dpy atom_NET_SUPPORTED_ATOM root
|
||||
changeProperty32 dpy root atom_NET_SUPPORTED_ATOM aTOM 0 (nub $ fromIntegral atom_NET_SUPPORTING_WM_CHECK : fromIntegral atom_NET_WM_NAME : supportedList)
|
||||
where
|
||||
netSupportingWMCheckAtom :: X Atom
|
||||
@ -78,7 +78,7 @@ setWMName name = do
|
||||
getSupportWindow = withDisplay $ \dpy -> do
|
||||
atom_NET_SUPPORTING_WM_CHECK <- netSupportingWMCheckAtom
|
||||
root <- asks theRoot
|
||||
supportWindow <- fmap (join . fmap listToMaybe) $ io $ getWindowProperty32 dpy atom_NET_SUPPORTING_WM_CHECK root
|
||||
supportWindow <- (listToMaybe =<<) <$> io (getWindowProperty32 dpy atom_NET_SUPPORTING_WM_CHECK root)
|
||||
validateWindow (fmap fromIntegral supportWindow)
|
||||
|
||||
validateWindow :: Maybe Window -> X Window
|
||||
|
@ -42,7 +42,6 @@ import XMonad
|
||||
import qualified XMonad.Util.ExtensibleState as XS
|
||||
|
||||
import Control.Monad (join,guard)
|
||||
import Control.Applicative ((<$>))
|
||||
import Control.Arrow (first, second)
|
||||
|
||||
import Data.Map
|
||||
|
@ -81,7 +81,6 @@ import XMonad.Util.NamedWindows (getName)
|
||||
import XMonad.Util.Timer (TimerId, startTimer, handleTimer)
|
||||
import XMonad.Util.WindowProperties (getProp32)
|
||||
|
||||
import Control.Applicative ((<$>))
|
||||
import Control.Monad (when)
|
||||
import Data.Bits (testBit)
|
||||
import Data.List (delete, (\\))
|
||||
@ -321,7 +320,7 @@ data WithUrgencyHook h = WithUrgencyHook h UrgencyConfig
|
||||
changeNetWMState :: Display -> Window -> ([CLong] -> [CLong]) -> X ()
|
||||
changeNetWMState dpy w f = do
|
||||
wmstate <- getAtom "_NET_WM_STATE"
|
||||
wstate <- fromMaybe [] `fmap` getProp32 wmstate w
|
||||
wstate <- fromMaybe [] <$> getProp32 wmstate w
|
||||
let ptype = 4 -- atom property type for changeProperty
|
||||
io $ changeProperty32 dpy w wmstate ptype propModeReplace (f wstate)
|
||||
return ()
|
||||
@ -338,7 +337,7 @@ removeNetWMState dpy w atom = changeNetWMState dpy w $ delete (fromIntegral atom
|
||||
getNetWMState :: Window -> X [CLong]
|
||||
getNetWMState w = do
|
||||
a_wmstate <- getAtom "_NET_WM_STATE"
|
||||
fromMaybe [] `fmap` getProp32 a_wmstate w
|
||||
fromMaybe [] <$> getProp32 a_wmstate w
|
||||
|
||||
|
||||
-- The Non-ICCCM Manifesto:
|
||||
|
@ -25,7 +25,6 @@ import qualified XMonad.StackSet as W
|
||||
import XMonad.Util.XUtils (fi)
|
||||
|
||||
import Data.Maybe
|
||||
import Control.Applicative((<$>))
|
||||
import Control.Monad.Error ((<=<),guard,lift,runErrorT,throwError)
|
||||
|
||||
-- $usage
|
||||
|
@ -108,10 +108,10 @@ instance LayoutModifier AvoidFloats Window where
|
||||
modifyLayoutWithUpdate lm w r = withDisplay $ \d -> do
|
||||
floating <- gets $ W.floating . windowset
|
||||
case cache lm of
|
||||
Just (key, mer) | key == (floating,r) -> flip (,) Nothing `fmap` runLayout w mer
|
||||
_ -> do rs <- io $ map toRect `fmap` mapM (getWindowAttributes d) (filter shouldAvoid $ M.keys floating)
|
||||
Just (key, mer) | key == (floating,r) -> flip (,) Nothing <$> runLayout w mer
|
||||
_ -> do rs <- io $ map toRect <$> mapM (getWindowAttributes d) (filter shouldAvoid $ M.keys floating)
|
||||
let mer = maximumBy (comparing area) $ filter bigEnough $ maxEmptyRectangles r rs
|
||||
flip (,) (Just $ pruneWindows $ lm { cache = Just ((floating,r),mer) }) `fmap` runLayout w mer
|
||||
flip (,) (Just $ pruneWindows $ lm { cache = Just ((floating,r),mer) }) <$> runLayout w mer
|
||||
where
|
||||
toRect :: WindowAttributes -> Rectangle
|
||||
toRect wa = let b = fi $ wa_border_width wa
|
||||
|
@ -34,7 +34,6 @@ import XMonad.Layout.LayoutModifier(ModifiedLayout(..),
|
||||
LayoutModifier(handleMessOrMaybeModifyIt, redoLayout))
|
||||
import XMonad(Typeable, LayoutClass, Message, X, fromMessage,
|
||||
sendMessage, windows, withFocused, Window)
|
||||
import Control.Applicative((<$>))
|
||||
import Data.List((\\), union)
|
||||
import Data.Maybe(fromMaybe, listToMaybe, maybeToList)
|
||||
import qualified Data.Map as M
|
||||
|
@ -77,14 +77,14 @@ combineTwo = C2 [] []
|
||||
instance (LayoutClass l (), LayoutClass l1 a, LayoutClass l2 a, Read a, Show a, Eq a, Typeable a)
|
||||
=> LayoutClass (CombineTwo (l ()) l1 l2) a where
|
||||
runLayout (Workspace _ (C2 f w2 super l1 l2) s) rinput = arrange (integrate' s)
|
||||
where arrange [] = do l1' <- maybe l1 id `fmap` handleMessage l1 (SomeMessage ReleaseResources)
|
||||
l2' <- maybe l2 id `fmap` handleMessage l2 (SomeMessage ReleaseResources)
|
||||
super' <- maybe super id `fmap`
|
||||
where arrange [] = do l1' <- maybe l1 id <$> handleMessage l1 (SomeMessage ReleaseResources)
|
||||
l2' <- maybe l2 id <$> handleMessage l2 (SomeMessage ReleaseResources)
|
||||
super' <- maybe super id <$>
|
||||
handleMessage super (SomeMessage ReleaseResources)
|
||||
return ([], Just $ C2 [] [] super' l1' l2')
|
||||
arrange [w] = do l1' <- maybe l1 id `fmap` handleMessage l1 (SomeMessage ReleaseResources)
|
||||
l2' <- maybe l2 id `fmap` handleMessage l2 (SomeMessage ReleaseResources)
|
||||
super' <- maybe super id `fmap`
|
||||
arrange [w] = do l1' <- maybe l1 id <$> handleMessage l1 (SomeMessage ReleaseResources)
|
||||
l2' <- maybe l2 id <$> handleMessage l2 (SomeMessage ReleaseResources)
|
||||
super' <- maybe super id <$>
|
||||
handleMessage super (SomeMessage ReleaseResources)
|
||||
return ([(w,rinput)], Just $ C2 [w] [w] super' l1' l2')
|
||||
arrange origws =
|
||||
@ -106,13 +106,13 @@ instance (LayoutClass l (), LayoutClass l1 a, LayoutClass l2 a, Read a, Show a,
|
||||
handleMessage (C2 f ws2 super l1 l2) m
|
||||
| Just (MoveWindowToWindow w1 w2) <- fromMessage m,
|
||||
w1 `notElem` ws2,
|
||||
w2 `elem` ws2 = do l1' <- maybe l1 id `fmap` handleMessage l1 m
|
||||
l2' <- maybe l2 id `fmap` handleMessage l2 m
|
||||
w2 `elem` ws2 = do l1' <- maybe l1 id <$> handleMessage l1 m
|
||||
l2' <- maybe l2 id <$> handleMessage l2 m
|
||||
return $ Just $ C2 f (w1:ws2) super l1' l2'
|
||||
| Just (MoveWindowToWindow w1 w2) <- fromMessage m,
|
||||
w1 `elem` ws2,
|
||||
w2 `notElem` ws2 = do l1' <- maybe l1 id `fmap` handleMessage l1 m
|
||||
l2' <- maybe l2 id `fmap` handleMessage l2 m
|
||||
w2 `notElem` ws2 = do l1' <- maybe l1 id <$> handleMessage l1 m
|
||||
l2' <- maybe l2 id <$> handleMessage l2 m
|
||||
let ws2' = case delete w1 ws2 of [] -> [w2]
|
||||
x -> x
|
||||
return $ Just $ C2 f ws2' super l1' l2'
|
||||
|
@ -400,7 +400,7 @@ updateDeco sh t fs ((w,_),(Just dw,Just (Rectangle _ _ wh ht))) = do
|
||||
_ | focusw == win -> ac
|
||||
| win `elem` ur -> uc
|
||||
| otherwise -> ic) . W.peek)
|
||||
`fmap` gets windowset
|
||||
<$> gets windowset
|
||||
(bc,borderc,borderw,tc) <-
|
||||
focusColor w (inactiveColor t, inactiveBorderColor t, inactiveBorderWidth t, inactiveTextColor t)
|
||||
(activeColor t, activeBorderColor t, activeBorderWidth t, activeTextColor t)
|
||||
|
@ -30,7 +30,6 @@ import XMonad.Hooks.ManageDocks
|
||||
import XMonad.Util.Font
|
||||
import XMonad.Util.PositionStore
|
||||
|
||||
import Control.Applicative((<$>))
|
||||
import Data.Maybe
|
||||
import qualified Data.Set as S
|
||||
|
||||
|
@ -84,7 +84,7 @@ instance LayoutClass FixedColumn Window where
|
||||
widthCols :: Int -> Int -> Window -> X Int
|
||||
widthCols inc n w = withDisplay $ \d -> io $ do
|
||||
sh <- getWMNormalHints d w
|
||||
bw <- fmap (fromIntegral . wa_border_width) $ getWindowAttributes d w
|
||||
bw <- fromIntegral . wa_border_width <$> getWindowAttributes d w
|
||||
let widthHint f = f sh >>= return . fromIntegral . fst
|
||||
oneCol = fromMaybe inc $ widthHint sh_resize_inc
|
||||
base = fromMaybe 0 $ widthHint sh_base_size
|
||||
|
@ -134,7 +134,7 @@ instance LayoutModifier FullscreenFocus Window where
|
||||
instance LayoutModifier FullscreenFloat Window where
|
||||
handleMess (FullscreenFloat frect fulls) m = case fromMessage m of
|
||||
Just (AddFullscreen win) -> do
|
||||
mrect <- (M.lookup win . W.floating) `fmap` gets windowset
|
||||
mrect <- (M.lookup win . W.floating) <$> gets windowset
|
||||
return $ case mrect of
|
||||
Just rect -> Just $ FullscreenFloat frect $ M.insert win (rect,True) fulls
|
||||
Nothing -> Nothing
|
||||
@ -196,7 +196,7 @@ fullscreenEventHook :: Event -> X All
|
||||
fullscreenEventHook (ClientMessageEvent _ _ _ dpy win typ (action:dats)) = do
|
||||
wmstate <- getAtom "_NET_WM_STATE"
|
||||
fullsc <- getAtom "_NET_WM_STATE_FULLSCREEN"
|
||||
wstate <- fromMaybe [] `fmap` getProp32 wmstate win
|
||||
wstate <- fromMaybe [] <$> getProp32 wmstate win
|
||||
let fi :: (Integral i, Num n) => i -> n
|
||||
fi = fromIntegral
|
||||
isFull = fi fullsc `elem` wstate
|
||||
@ -220,7 +220,7 @@ fullscreenEventHook (DestroyWindowEvent {ev_window = w}) = do
|
||||
-- When a window is destroyed, the layouts should remove that window
|
||||
-- from their states.
|
||||
broadcastMessage $ RemoveFullscreen w
|
||||
cw <- (W.workspace . W.current) `fmap` gets windowset
|
||||
cw <- (W.workspace . W.current) <$> gets windowset
|
||||
sendMessageWithNoRefresh FullscreenChanged cw
|
||||
return $ All True
|
||||
|
||||
@ -241,7 +241,7 @@ fullscreenManageHook' isFull = isFull --> do
|
||||
w <- ask
|
||||
liftX $ do
|
||||
broadcastMessage $ AddFullscreen w
|
||||
cw <- (W.workspace . W.current) `fmap` gets windowset
|
||||
cw <- (W.workspace . W.current) <$> gets windowset
|
||||
sendMessageWithNoRefresh FullscreenChanged cw
|
||||
idHook
|
||||
|
||||
|
@ -61,7 +61,7 @@ import XMonad.Util.Stack
|
||||
import Data.Maybe (isJust, isNothing, fromMaybe, catMaybes, fromJust)
|
||||
import Data.List ((\\))
|
||||
import Control.Arrow ((>>>))
|
||||
import Control.Applicative ((<$>),(<|>),(<$))
|
||||
import Control.Applicative ((<|>))
|
||||
import Control.Monad (forM,void)
|
||||
|
||||
-- $usage
|
||||
|
@ -23,7 +23,6 @@ module XMonad.Layout.IfMax
|
||||
, ifMax
|
||||
) where
|
||||
|
||||
import Control.Applicative((<$>))
|
||||
import Control.Arrow
|
||||
import qualified Data.List as L
|
||||
import qualified Data.Map as M
|
||||
|
@ -29,7 +29,7 @@ module XMonad.Layout.IndependentScreens (
|
||||
) where
|
||||
|
||||
-- for the screen stuff
|
||||
import Control.Applicative((<*), liftA2)
|
||||
import Control.Applicative(liftA2)
|
||||
import Control.Arrow hiding ((|||))
|
||||
import Control.Monad
|
||||
import Data.List (nub, genericLength)
|
||||
@ -121,7 +121,7 @@ onCurrentScreen f vws = screen . current >>= f . flip marshall vws
|
||||
-- > }
|
||||
--
|
||||
countScreens :: (MonadIO m, Integral i) => m i
|
||||
countScreens = liftM genericLength . liftIO $ openDisplay "" >>= liftA2 (<*) getScreenInfo closeDisplay
|
||||
countScreens = fmap genericLength . liftIO $ openDisplay "" >>= liftA2 (<*) getScreenInfo closeDisplay
|
||||
|
||||
-- | This turns a naive pretty-printer into one that is aware of the
|
||||
-- independent screens. That is, you can write your pretty printer to behave
|
||||
|
@ -370,7 +370,7 @@ sendFocus l@(LayoutB subFocus _ _ _ _ _ _) m = do
|
||||
-- | Check to see if the given window is currently focused.
|
||||
isFocus :: (Show a) => Maybe a -> X Bool
|
||||
isFocus Nothing = return False
|
||||
isFocus (Just w) = do ms <- (W.stack . W.workspace . W.current) `fmap` gets windowset
|
||||
isFocus (Just w) = do ms <- (W.stack . W.workspace . W.current) <$> gets windowset
|
||||
return $ maybe False (\s -> show w == show (W.focus s)) ms
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
@ -147,7 +147,7 @@ sendFocus l@(LayoutP subf _ _ _ _ _ _) m = do foc <- isFocus subf
|
||||
|
||||
isFocus :: (Show a) => Maybe a -> X Bool
|
||||
isFocus Nothing = return False
|
||||
isFocus (Just w) = do ms <- (W.stack . W.workspace . W.current) `fmap` gets windowset
|
||||
isFocus (Just w) = do ms <- (W.stack . W.workspace . W.current) <$> gets windowset
|
||||
return $ maybe False (\s -> show w == (show $ W.focus s)) ms
|
||||
|
||||
|
||||
|
@ -234,32 +234,32 @@ instance Message JumpToLayout
|
||||
|
||||
instance (LayoutClass l1 a, LayoutClass l2 a) => LayoutClass (NewSelect l1 l2) a where
|
||||
runLayout (Workspace i (NewSelect True l1 l2) ms) r = do (wrs, ml1') <- runLayout (Workspace i l1 ms) r
|
||||
return (wrs, (\l1' -> NewSelect True l1' l2) `fmap` ml1')
|
||||
return (wrs, (\l1' -> NewSelect True l1' l2) <$> ml1')
|
||||
|
||||
runLayout (Workspace i (NewSelect False l1 l2) ms) r = do (wrs, ml2') <- runLayout (Workspace i l2 ms) r
|
||||
return (wrs, (\l2' -> NewSelect False l1 l2') `fmap` ml2')
|
||||
return (wrs, (\l2' -> NewSelect False l1 l2') <$> ml2')
|
||||
description (NewSelect True l1 _) = description l1
|
||||
description (NewSelect False _ l2) = description l2
|
||||
handleMessage l@(NewSelect False _ _) m
|
||||
| Just Wrap <- fromMessage m = fmap Just $ swap l >>= passOn m
|
||||
| Just Wrap <- fromMessage m = Just <$> (swap l >>= passOn m)
|
||||
handleMessage l@(NewSelect amfirst _ _) m
|
||||
| Just NextLayoutNoWrap <- fromMessage m =
|
||||
if amfirst then when' isNothing (passOnM m l) $
|
||||
fmap Just $ swap l >>= passOn (SomeMessage Wrap)
|
||||
Just <$> (swap l >>= passOn (SomeMessage Wrap))
|
||||
else passOnM m l
|
||||
handleMessage l m
|
||||
| Just NextLayout <- fromMessage m = when' isNothing (passOnM (SomeMessage NextLayoutNoWrap) l) $
|
||||
fmap Just $ swap l >>= passOn (SomeMessage Wrap)
|
||||
Just <$> (swap l >>= passOn (SomeMessage Wrap))
|
||||
handleMessage l@(NewSelect True _ l2) m
|
||||
| Just (JumpToLayout d) <- fromMessage m, d == description l2 = Just `fmap` swap l
|
||||
| Just (JumpToLayout d) <- fromMessage m, d == description l2 = Just <$> swap l
|
||||
handleMessage l@(NewSelect False l1 _) m
|
||||
| Just (JumpToLayout d) <- fromMessage m, d == description l1 = Just `fmap` swap l
|
||||
| Just (JumpToLayout d) <- fromMessage m, d == description l1 = Just <$> swap l
|
||||
handleMessage l m
|
||||
| Just (JumpToLayout _) <- fromMessage m = when' isNothing (passOnM m l) $
|
||||
do ml' <- passOnM m $ sw l
|
||||
case ml' of
|
||||
Nothing -> return Nothing
|
||||
Just l' -> Just `fmap` swap (sw l')
|
||||
Just l' -> Just <$> swap (sw l')
|
||||
handleMessage (NewSelect b l1 l2) m
|
||||
| Just ReleaseResources <- fromMessage m =
|
||||
do ml1' <- handleMessage l1 m
|
||||
@ -270,21 +270,21 @@ instance (LayoutClass l1 a, LayoutClass l2 a) => LayoutClass (NewSelect l1 l2) a
|
||||
handleMessage l m = passOnM m l
|
||||
|
||||
swap :: (LayoutClass l1 a, LayoutClass l2 a) => NewSelect l1 l2 a -> X (NewSelect l1 l2 a)
|
||||
swap l = sw `fmap` passOn (SomeMessage Hide) l
|
||||
swap l = sw <$> passOn (SomeMessage Hide) l
|
||||
|
||||
sw :: NewSelect l1 l2 a -> NewSelect l1 l2 a
|
||||
sw (NewSelect b lt lf) = NewSelect (not b) lt lf
|
||||
|
||||
passOn :: (LayoutClass l1 a, LayoutClass l2 a) =>
|
||||
SomeMessage -> NewSelect l1 l2 a -> X (NewSelect l1 l2 a)
|
||||
passOn m l = maybe l id `fmap` passOnM m l
|
||||
passOn m l = maybe l id <$> passOnM m l
|
||||
|
||||
passOnM :: (LayoutClass l1 a, LayoutClass l2 a) =>
|
||||
SomeMessage -> NewSelect l1 l2 a -> X (Maybe (NewSelect l1 l2 a))
|
||||
passOnM m (NewSelect True lt lf) = do mlt' <- handleMessage lt m
|
||||
return $ (\lt' -> NewSelect True lt' lf) `fmap` mlt'
|
||||
return $ (\lt' -> NewSelect True lt' lf) <$> mlt'
|
||||
passOnM m (NewSelect False lt lf) = do mlf' <- handleMessage lf m
|
||||
return $ (\lf' -> NewSelect False lt lf') `fmap` mlf'
|
||||
return $ (\lf' -> NewSelect False lt lf') <$> mlf'
|
||||
|
||||
when' :: Monad m => (a -> Bool) -> m a -> m a -> m a
|
||||
when' f a b = do a1 <- a; if f a1 then b else return a1
|
||||
|
@ -35,7 +35,6 @@ import XMonad.Layout.Decoration(isInStack)
|
||||
import XMonad.Layout.LayoutModifier(ModifiedLayout(..),
|
||||
LayoutModifier(modifyLayout, redoLayout, modifierDescription))
|
||||
import XMonad.Util.Types(Direction2D(..))
|
||||
import Control.Applicative((<$>))
|
||||
import Control.Arrow(Arrow((***), first, second))
|
||||
import Control.Monad(join)
|
||||
import Data.Function(on)
|
||||
|
@ -122,7 +122,7 @@ class (Show (m a), Read (m a)) => LayoutModifier m a where
|
||||
-> Workspace WorkspaceId (l a) a
|
||||
-> Rectangle
|
||||
-> X (([(a,Rectangle)], Maybe (l a)), Maybe (m a))
|
||||
modifyLayoutWithUpdate m w r = flip (,) Nothing `fmap` modifyLayout m w r
|
||||
modifyLayoutWithUpdate m w r = flip (,) Nothing <$> modifyLayout m w r
|
||||
|
||||
-- | 'handleMess' allows you to spy on messages to the underlying
|
||||
-- layout, in order to have an effect in the X monad, or alter
|
||||
@ -156,7 +156,7 @@ class (Show (m a), Read (m a)) => LayoutModifier m a where
|
||||
-- simply passes on the message to 'handleMess'.
|
||||
handleMessOrMaybeModifyIt :: m a -> SomeMessage -> X (Maybe (Either (m a) SomeMessage))
|
||||
handleMessOrMaybeModifyIt m mess = do mm' <- handleMess m mess
|
||||
return (Left `fmap` mm')
|
||||
return (Left <$> mm')
|
||||
|
||||
-- | 'pureMess' allows you to spy on messages sent to the
|
||||
-- underlying layout, in order to possibly change the layout
|
||||
@ -256,7 +256,7 @@ instance (LayoutModifier m a, LayoutClass l a) => LayoutClass (ModifiedLayout m
|
||||
(ws', mm'') <- redoLayout (maybe m id mm') r ms ws
|
||||
let ml'' = case mm'' `mplus` mm' of
|
||||
Just m' -> Just $ (ModifiedLayout m') $ maybe l id ml'
|
||||
Nothing -> ModifiedLayout m `fmap` ml'
|
||||
Nothing -> ModifiedLayout m <$> ml'
|
||||
return (ws', ml'')
|
||||
|
||||
handleMessage (ModifiedLayout m l) mess =
|
||||
@ -266,7 +266,7 @@ instance (LayoutModifier m a, LayoutClass l a) => LayoutClass (ModifiedLayout m
|
||||
_ -> handleMessage l mess
|
||||
return $ case mm' of
|
||||
Just (Left m') -> Just $ (ModifiedLayout m') $ maybe l id ml'
|
||||
_ -> (ModifiedLayout m) `fmap` ml'
|
||||
_ -> (ModifiedLayout m) <$> ml'
|
||||
description (ModifiedLayout m l) = modifyDescription m l
|
||||
|
||||
-- | A 'ModifiedLayout' is simply a container for a layout modifier
|
||||
|
@ -38,7 +38,6 @@ import XMonad.Layout.LayoutModifier
|
||||
import XMonad
|
||||
import qualified XMonad.StackSet as W
|
||||
import Control.Monad((<=<),guard)
|
||||
import Control.Applicative((<$>))
|
||||
import Data.Maybe(fromJust)
|
||||
|
||||
-- $usage
|
||||
|
@ -105,4 +105,4 @@ followOnlyIf _ _ = return $ All True
|
||||
|
||||
-- | Disables focusFollow on the given workspaces:
|
||||
disableFollowOnWS :: [WorkspaceId] -> X Bool
|
||||
disableFollowOnWS wses = (`notElem` wses) `fmap` gets (W.currentTag . windowset)
|
||||
disableFollowOnWS wses = (`notElem` wses) <$> gets (W.currentTag . windowset)
|
||||
|
@ -90,7 +90,7 @@ data FixMaster a = FixMaster (AddMaster a) deriving (Show, Read)
|
||||
instance LayoutModifier FixMaster Window where
|
||||
modifyLayout (FixMaster (AddMaster k d f)) = applyMaster True k d f
|
||||
modifierDescription (FixMaster a) = "Fix" ++ modifierDescription a
|
||||
pureMess (FixMaster a) m = liftM FixMaster (pureMess a m)
|
||||
pureMess (FixMaster a) m = fmap FixMaster (pureMess a m)
|
||||
|
||||
fixMastered :: (LayoutClass l a) =>
|
||||
Rational -- ^ @delta@, the ratio of the screen to resize by
|
||||
|
@ -32,7 +32,6 @@ import XMonad.StackSet (Workspace(..))
|
||||
import XMonad.Layout.LayoutModifier (LayoutModifier(..), ModifiedLayout(..))
|
||||
|
||||
import Data.Typeable (Typeable)
|
||||
import Control.Applicative ((<$>))
|
||||
import Control.Arrow (second)
|
||||
|
||||
-- $usage
|
||||
|
@ -118,7 +118,7 @@ instance LayoutClass Mosaic a where
|
||||
nextIx (ov,ix,mix)
|
||||
| mix <= 0 || ov = fromIntegral $ nls `div` 2
|
||||
| otherwise = max 0 $ (*fi (pred nls)) $ min 1 $ ix / fi mix
|
||||
rect = rects !! maybe (nls `div` 2) round (nextIx `fmap` state)
|
||||
rect = rects !! maybe (nls `div` 2) round (nextIx <$> state)
|
||||
state' = fmap (\x@(ov,_,_) -> (ov,nextIx x,pred nls)) state
|
||||
`mplus` Just (True,fromIntegral nls / 2,pred nls)
|
||||
ss' = maybe ss (const ss `either` const ssExt) $ zipRemain ss ssExt
|
||||
|
@ -36,7 +36,6 @@ module XMonad.Layout.MouseResizableTile (
|
||||
import XMonad hiding (tile, splitVertically, splitHorizontallyBy)
|
||||
import qualified XMonad.StackSet as W
|
||||
import XMonad.Util.XUtils
|
||||
import Control.Applicative((<$>))
|
||||
|
||||
-- $usage
|
||||
-- You can use this module with the following in your @~\/.xmonad\/xmonad.hs@:
|
||||
|
@ -192,7 +192,7 @@ instance (Typeable a, Show ts, HList ts a, LayoutClass l a) => LayoutClass (Mult
|
||||
description mt = currLayout mt `unEL` \l -> description l
|
||||
|
||||
runLayout (Workspace i mt s) r = case currLayout mt of
|
||||
EL l det -> fmap (fmap . fmap $ (\x -> mt { currLayout = EL x det })) $
|
||||
EL l det -> (fmap . fmap $ (\x -> mt { currLayout = EL x det })) <$>
|
||||
runLayout (Workspace i l s) r
|
||||
|
||||
handleMessage mt m
|
||||
@ -200,7 +200,7 @@ instance (Typeable a, Show ts, HList ts a, LayoutClass l a) => LayoutClass (Mult
|
||||
, i@(Just _) <- find (transformers mt) t
|
||||
= case currLayout mt of
|
||||
EL l det -> do
|
||||
l' <- fromMaybe l `fmap` handleMessage l (SomeMessage ReleaseResources)
|
||||
l' <- fromMaybe l <$> handleMessage l (SomeMessage ReleaseResources)
|
||||
return . Just $
|
||||
mt {
|
||||
currLayout = (if cur then id else transform' t) (EL (det l') id),
|
||||
@ -209,5 +209,5 @@ instance (Typeable a, Show ts, HList ts a, LayoutClass l a) => LayoutClass (Mult
|
||||
where cur = (i == currIndex mt)
|
||||
| otherwise
|
||||
= case currLayout mt of
|
||||
EL l det -> fmap (fmap (\x -> mt { currLayout = EL x det })) $
|
||||
EL l det -> (fmap (\x -> mt { currLayout = EL x det })) <$>
|
||||
handleMessage l m
|
||||
|
@ -42,7 +42,6 @@ import Data.List
|
||||
import Data.Monoid
|
||||
import qualified Data.Map as M
|
||||
import Data.Function (on)
|
||||
import Control.Applicative ((<$>),(<*>),pure)
|
||||
import Control.Monad (guard)
|
||||
|
||||
|
||||
|
@ -71,8 +71,8 @@ instance LayoutClass ResizableTall a where
|
||||
return . (\x->(x,Nothing)) .
|
||||
ap zip (tile frac (mfrac ++ repeat 1) r nmaster . length) . W.integrate
|
||||
handleMessage (ResizableTall nmaster delta frac mfrac) m =
|
||||
do ms <- (W.stack . W.workspace . W.current) `fmap` gets windowset
|
||||
fs <- (M.keys . W.floating) `fmap` gets windowset
|
||||
do ms <- (W.stack . W.workspace . W.current) <$> gets windowset
|
||||
fs <- (M.keys . W.floating) <$> gets windowset
|
||||
return $ ms >>= unfloat fs >>= handleMesg
|
||||
where handleMesg s = msum [fmap resize (fromMessage m)
|
||||
,fmap (\x -> mresize x s) (fromMessage m)
|
||||
|
@ -95,7 +95,7 @@ flashName c (Rectangle sx sy wh ht) wrs = do
|
||||
d <- asks display
|
||||
n <- withWindowSet (return . S.currentTag)
|
||||
f <- initXMF (swn_font c)
|
||||
width <- fmap (\w -> w + w `div` length n) $ textWidthXMF d f n
|
||||
width <- (\w -> w + w `div` length n) <$> textWidthXMF d f n
|
||||
(as,ds) <- textExtentsXMF f n
|
||||
let hight = as + ds
|
||||
y = fi sy + (fi ht - hight + 2) `div` 2
|
||||
|
@ -34,7 +34,7 @@ import qualified XMonad.StackSet as W
|
||||
import XMonad.Util.Stack (findZ)
|
||||
|
||||
import Data.Maybe (fromMaybe)
|
||||
import Control.Applicative ((<|>),(<$>))
|
||||
import Control.Applicative ((<|>))
|
||||
import Control.Monad (join)
|
||||
|
||||
-- $Usage
|
||||
|
@ -121,7 +121,7 @@ instance LayoutModifier Stoppable Window where
|
||||
where run = sigStoppableWorkspacesHook m >> return Nothing
|
||||
handleMess (Stoppable m d _) msg
|
||||
| Just Hide <- fromMessage msg =
|
||||
(Just . Stoppable m d . Just) `liftM` startTimer d
|
||||
(Just . Stoppable m d . Just) <$> startTimer d
|
||||
| otherwise = return Nothing
|
||||
|
||||
-- | Convert a layout to a stoppable layout using the default mark
|
||||
|
@ -51,7 +51,6 @@ import XMonad.Layout.WindowNavigation(Navigate(Apply))
|
||||
import XMonad.Util.Invisible(Invisible(..))
|
||||
import XMonad.Util.Types(Direction2D(..))
|
||||
import XMonad hiding (def)
|
||||
import Control.Applicative((<$>),(<*))
|
||||
import Control.Arrow(Arrow(second, (&&&)))
|
||||
import Control.Monad(MonadPlus(mplus), foldM, guard, when, join)
|
||||
import Data.Function(on)
|
||||
@ -391,7 +390,7 @@ instance (Read (l Window), Show (l Window), LayoutClass l Window) => LayoutModif
|
||||
in fgs $ nxsAdd $ M.insert x zs $ M.delete yf gs
|
||||
|
||||
|
||||
| otherwise = fmap join $ sequenceA $ catchLayoutMess <$> fromMessage m
|
||||
| otherwise = join <$> sequenceA (catchLayoutMess <$> fromMessage m)
|
||||
where gs = toGroups sls
|
||||
fgs gs' = do
|
||||
st <- currentStack
|
||||
@ -429,7 +428,7 @@ updateGroup mst gs =
|
||||
|
||||
-- update the current tab group's order and focus
|
||||
followFocus hs = fromMaybe hs $ do
|
||||
f' <- W.focus `fmap` mst
|
||||
f' <- W.focus <$> mst
|
||||
xs <- find (elem f' . W.integrate) $ M.elems hs
|
||||
xs' <- W.filter (`elem` W.integrate xs) =<< mst
|
||||
return $ M.insert f' xs' $ M.delete (W.focus xs) hs
|
||||
|
@ -42,7 +42,7 @@ import XMonad hiding (focus)
|
||||
import XMonad.StackSet (Workspace(..),integrate',Stack(..))
|
||||
import qualified XMonad.StackSet as W
|
||||
import Data.Maybe (fromJust,isJust)
|
||||
import Control.Monad (join, foldM)
|
||||
import Control.Monad (foldM)
|
||||
|
||||
---------------------------------------------------------------------------------
|
||||
-- $usage
|
||||
|
@ -32,6 +32,7 @@ module XMonad.Layout.TrackFloating
|
||||
UseTransientFor,
|
||||
) where
|
||||
|
||||
import Control.Applicative (liftA2)
|
||||
import Control.Monad
|
||||
import Data.Function
|
||||
import Data.List
|
||||
@ -96,11 +97,11 @@ instance LayoutModifier UseTransientFor Window where
|
||||
modifyLayout _ ws@(W.Workspace{ W.stack = ms }) r = do
|
||||
m <- gets (W.peek . windowset)
|
||||
d <- asks display
|
||||
parent <- fmap join $ T.traverse (io . getTransientForHint d) m
|
||||
parent <- join <$> T.traverse (io . getTransientForHint d) m
|
||||
|
||||
s0 <- get
|
||||
whenJust parent $ \p -> put s0{ windowset = W.focusWindow p (windowset s0) }
|
||||
result <- runLayout ws{ W.stack = fromMaybe ms (liftM2 focusWin ms parent) } r
|
||||
result <- runLayout ws{ W.stack = fromMaybe ms (liftA2 focusWin ms parent) } r
|
||||
|
||||
m' <- gets (W.peek . windowset)
|
||||
|
||||
|
@ -98,7 +98,6 @@ import XMonad.Util.Types
|
||||
import XMonad.Util.XSelection (getSelection)
|
||||
|
||||
import Codec.Binary.UTF8.String (decodeString,isUTF8Encoded)
|
||||
import Control.Applicative ((<$>))
|
||||
import Control.Arrow (first, second, (&&&), (***))
|
||||
import Control.Concurrent (threadDelay)
|
||||
import Control.Exception.Extensible as E hiding (handle)
|
||||
@ -1205,7 +1204,7 @@ pasteString = pasteString' id
|
||||
-- | A variant of 'pasteString' which allows modifying the X selection before
|
||||
-- pasting.
|
||||
pasteString' :: (String -> String) -> XP ()
|
||||
pasteString' f = join $ io $ liftM (insertString . f) getSelection
|
||||
pasteString' f = insertString . f =<< getSelection
|
||||
|
||||
-- | Remove a character at the cursor position
|
||||
deleteString :: Direction1D -> XP ()
|
||||
|
@ -60,7 +60,7 @@ import Control.Exception.Extensible (bracket)
|
||||
-- before saving into the file. Previous example with date can be rewritten as:
|
||||
--
|
||||
-- > , ((modm .|. controlMask, xK_n), do
|
||||
-- > date <- io $ liftM (formatTime defaultTimeLocale "[%Y-%m-%d %H:%M] ") getZonedTime
|
||||
-- > date <- io $ fmap (formatTime defaultTimeLocale "[%Y-%m-%d %H:%M] ") getZonedTime
|
||||
-- > appendFilePrompt' def (date ++) $ "/home/me/NOTES"
|
||||
-- > )
|
||||
--
|
||||
|
@ -26,6 +26,7 @@ module XMonad.Prompt.DirExec
|
||||
|
||||
import Control.Exception as E
|
||||
import System.Directory
|
||||
import Control.Applicative (liftA2)
|
||||
import Control.Monad
|
||||
import Data.List
|
||||
import XMonad
|
||||
@ -100,7 +101,7 @@ getDirectoryExecutables :: FilePath -> IO [String]
|
||||
getDirectoryExecutables path =
|
||||
(getDirectoryContents path >>=
|
||||
filterM (\x -> let x' = path ++ x in
|
||||
liftM2 (&&)
|
||||
liftA2 (&&)
|
||||
(doesFileExist x')
|
||||
(liftM executable (getPermissions x'))))
|
||||
(fmap executable (getPermissions x'))))
|
||||
`E.catch` econst []
|
||||
|
@ -46,7 +46,7 @@ directoryMultipleModes :: String -- ^ Prompt.
|
||||
directoryMultipleModes p f = XPT (Dir p f)
|
||||
|
||||
getDirCompl :: String -> IO [String]
|
||||
getDirCompl s = (filter notboring . lines) `fmap`
|
||||
getDirCompl s = (filter notboring . lines) <$>
|
||||
runProcessWithInput "bash" [] ("compgen -A directory " ++ s ++ "\n")
|
||||
|
||||
notboring :: String -> Bool
|
||||
|
@ -75,7 +75,7 @@ getMans = do
|
||||
mans <- forM (nub dirs) $ \d -> do
|
||||
exists <- doesDirectoryExist d
|
||||
if exists
|
||||
then map (stripExt . stripSuffixes [".gz", ".bz2"]) `fmap`
|
||||
then map (stripExt . stripSuffixes [".gz", ".bz2"]) <$>
|
||||
getDirectoryContents d
|
||||
else return []
|
||||
return $ uniqSort $ concat mans
|
||||
@ -84,7 +84,7 @@ manCompl :: [String] -> String -> IO [String]
|
||||
manCompl mans s | s == "" || last s == ' ' = return []
|
||||
| otherwise = do
|
||||
-- XXX readline instead of bash's compgen?
|
||||
f <- lines `fmap` getCommandOutput ("bash -c 'compgen -A file " ++ s ++ "'")
|
||||
f <- lines <$> getCommandOutput ("bash -c 'compgen -A file " ++ s ++ "'")
|
||||
mkComplFunFromList (f ++ mans) s
|
||||
|
||||
-- | Run a command using shell and return its output.
|
||||
|
@ -27,7 +27,7 @@ import XMonad.Actions.WindowGo (runOrRaise)
|
||||
import XMonad.Util.Run (runProcessWithInput)
|
||||
|
||||
import Control.Exception as E
|
||||
import Control.Monad (liftM, liftM2)
|
||||
import Control.Applicative (liftA2)
|
||||
import System.Directory (doesDirectoryExist, doesFileExist, executable, getPermissions)
|
||||
|
||||
econst :: Monad m => a -> IOException -> m a
|
||||
@ -60,14 +60,14 @@ open path = io (isNormalFile path) >>= \b ->
|
||||
else uncurry runOrRaise . getTarget $ path
|
||||
where
|
||||
isNormalFile f = exists f >>= \e -> if e then notExecutable f else return False
|
||||
exists f = fmap or $ sequence [doesFileExist f,doesDirectoryExist f]
|
||||
exists f = or <$> sequence [doesFileExist f,doesDirectoryExist f]
|
||||
notExecutable = fmap (not . executable) . getPermissions
|
||||
getTarget x = (x,isApp x)
|
||||
|
||||
isApp :: String -> Query Bool
|
||||
isApp "firefox" = className =? "Firefox-bin" <||> className =? "Firefox"
|
||||
isApp "thunderbird" = className =? "Thunderbird-bin" <||> className =? "Thunderbird"
|
||||
isApp x = liftM2 (==) pid $ pidof x
|
||||
isApp x = liftA2 (==) pid $ pidof x
|
||||
|
||||
pidof :: String -> Query Int
|
||||
pidof x = io $ (runProcessWithInput "pidof" [x] [] >>= readIO) `E.catch` econst 0
|
||||
@ -75,7 +75,7 @@ pidof x = io $ (runProcessWithInput "pidof" [x] [] >>= readIO) `E.catch` econst
|
||||
pid :: Query Int
|
||||
pid = ask >>= (\w -> liftX $ withDisplay $ \d -> getPID d w)
|
||||
where getPID d w = getAtom "_NET_WM_PID" >>= \a -> io $
|
||||
liftM getPID' (getWindowProperty32 d a w)
|
||||
fmap getPID' (getWindowProperty32 d a w)
|
||||
getPID' (Just (x:_)) = fromIntegral x
|
||||
getPID' (Just []) = -1
|
||||
getPID' (Nothing) = -1
|
||||
|
@ -27,6 +27,7 @@ import System.Directory
|
||||
import System.Environment
|
||||
import Control.Exception as E
|
||||
|
||||
import Control.Applicative (liftA2)
|
||||
import Control.Monad
|
||||
import Data.Maybe
|
||||
import Data.List(elemIndex)
|
||||
@ -69,7 +70,7 @@ ssh :: String -> X ()
|
||||
ssh = runInTerm "" . ("ssh " ++ )
|
||||
|
||||
sshComplList :: IO [String]
|
||||
sshComplList = uniqSort `fmap` liftM2 (++) sshComplListLocal sshComplListGlobal
|
||||
sshComplList = uniqSort <$> liftA2 (++) sshComplListLocal sshComplListGlobal
|
||||
|
||||
sshComplListLocal :: IO [String]
|
||||
sshComplListLocal = do
|
||||
|
@ -130,7 +130,7 @@ wsWindows :: XWindowMap
|
||||
wsWindows = withWindowSet (return . W.index) >>= winmap
|
||||
where
|
||||
winmap = fmap M.fromList . mapM pair
|
||||
pair w = do name <- fmap show $ getName w
|
||||
pair w = do name <- show <$> getName w
|
||||
return (name, w)
|
||||
|
||||
-- | A Map where keys are pretty printable window names and values are
|
||||
|
@ -63,9 +63,9 @@ debugWindow w = do
|
||||
then s''
|
||||
else tail s''
|
||||
in Just (w'',s')
|
||||
t <- catchX' (wrap `fmap` getEWMHTitle "VISIBLE" w) $
|
||||
catchX' (wrap `fmap` getEWMHTitle "" w) $
|
||||
catchX' (wrap `fmap` getICCCMTitle w) $
|
||||
t <- catchX' (wrap <$> getEWMHTitle "VISIBLE" w) $
|
||||
catchX' (wrap <$> getEWMHTitle "" w) $
|
||||
catchX' (wrap <$> getICCCMTitle w) $
|
||||
return ""
|
||||
h' <- getMachine w
|
||||
let h = if null h' then "" else '@':h'
|
||||
@ -114,14 +114,14 @@ getDecodedStringProp w a = do
|
||||
t@(TextProperty t' _ 8 _) <- withDisplay $ \d -> io $ getTextProperty d w a
|
||||
[s] <- catchX' (tryUTF8 t) $
|
||||
catchX' (tryCompound t) $
|
||||
io ((:[]) `fmap` peekCString t')
|
||||
io ((:[]) <$> peekCString t')
|
||||
return s
|
||||
|
||||
tryUTF8 :: TextProperty -> X [String]
|
||||
tryUTF8 (TextProperty s enc _ _) = do
|
||||
uTF8_STRING <- getAtom "UTF8_STRING"
|
||||
when (enc == uTF8_STRING) $ error "String is not UTF8_STRING"
|
||||
(map decodeString . splitNul) `fmap` io (peekCString s)
|
||||
(map decodeString . splitNul) <$> io (peekCString s)
|
||||
|
||||
tryCompound :: TextProperty -> X [String]
|
||||
tryCompound t@(TextProperty _ enc _ _) = do
|
||||
@ -161,7 +161,7 @@ safeGetWindowAttributes d w = alloca $ \p -> do
|
||||
s <- xGetWindowAttributes d w p
|
||||
case s of
|
||||
0 -> return Nothing
|
||||
_ -> Just `fmap` peek p
|
||||
_ -> Just <$> peek p
|
||||
|
||||
-- and so is getCommand
|
||||
safeGetCommand :: Display -> Window -> X [String]
|
||||
|
@ -24,7 +24,6 @@ import XMonad
|
||||
import qualified XMonad.StackSet as W
|
||||
import qualified Data.Map as M
|
||||
import XMonad.Util.Run
|
||||
import Control.Monad (liftM)
|
||||
|
||||
-- $usage
|
||||
-- You can use this module with the following in your Config.hs file:
|
||||
@ -43,7 +42,7 @@ import Control.Monad (liftM)
|
||||
dmenuXinerama :: [String] -> X String
|
||||
dmenuXinerama opts = do
|
||||
curscreen <-
|
||||
(fromIntegral . W.screen . W.current) `fmap` gets windowset :: X Int
|
||||
(fromIntegral . W.screen . W.current) <$> gets windowset :: X Int
|
||||
_ <-
|
||||
runProcessWithInput "dmenu" ["-xs", show (curscreen+1)] (unlines opts)
|
||||
menuArgs "dmenu" ["-xs", show (curscreen+1)] opts
|
||||
@ -58,7 +57,7 @@ menu menuCmd opts = menuArgs menuCmd [] opts
|
||||
|
||||
-- | Like 'menu' but also takes a list of command line arguments.
|
||||
menuArgs :: MonadIO m => String -> [String] -> [String] -> m String
|
||||
menuArgs menuCmd args opts = liftM (filter (/='\n')) $
|
||||
menuArgs menuCmd args opts = (filter (/='\n')) <$>
|
||||
runProcessWithInput menuCmd args (unlines opts)
|
||||
|
||||
-- | Like 'dmenuMap' but also takes the command to run.
|
||||
|
@ -36,8 +36,8 @@ module XMonad.Util.ExclusiveScratchpads (
|
||||
customFloating
|
||||
) where
|
||||
|
||||
import Control.Applicative ((<$>))
|
||||
import Control.Monad ((<=<),filterM,liftM2)
|
||||
import Control.Applicative (liftA2)
|
||||
import Control.Monad ((<=<),filterM)
|
||||
import Data.Monoid (appEndo)
|
||||
import XMonad
|
||||
import XMonad.Actions.Minimize
|
||||
@ -150,7 +150,7 @@ scratchpadAction xs n =
|
||||
(w:_) -> do toggleWindow w
|
||||
whenX (runQuery isExclusive w) (hideOthers xs n)
|
||||
where
|
||||
toggleWindow w = liftM2 (&&) (runQuery isMaximized w) (onCurrentScreen w) >>= \case
|
||||
toggleWindow w = liftA2 (&&) (runQuery isMaximized w) (onCurrentScreen w) >>= \case
|
||||
True -> whenX (onCurrentScreen w) (minimizeWindow w)
|
||||
False -> do windows (flip W.shiftWin w =<< W.currentTag)
|
||||
maximizeWindowAndFocus w
|
||||
|
@ -118,7 +118,7 @@ initXMF s =
|
||||
return (Xft xftdraw)
|
||||
else
|
||||
#endif
|
||||
fmap Utf8 $ initUtf8Font s
|
||||
Utf8 <$> initUtf8Font s
|
||||
#ifdef XFT
|
||||
where xftPrefix = "xft:"
|
||||
#endif
|
||||
@ -153,8 +153,8 @@ textExtentsXMF (Core fs) s = do
|
||||
return (a,d)
|
||||
#ifdef XFT
|
||||
textExtentsXMF (Xft xftfont) _ = io $ do
|
||||
ascent <- fi `fmap` xftfont_ascent xftfont
|
||||
descent <- fi `fmap` xftfont_descent xftfont
|
||||
ascent <- fi <$> xftfont_ascent xftfont
|
||||
descent <- fi <$> xftfont_descent xftfont
|
||||
return (ascent, descent)
|
||||
#endif
|
||||
|
||||
|
@ -41,8 +41,6 @@ module XMonad.Util.Loggers (
|
||||
, shortenL
|
||||
, dzenColorL, xmobarColorL
|
||||
|
||||
, (<$>)
|
||||
|
||||
) where
|
||||
|
||||
import XMonad (liftIO)
|
||||
@ -52,7 +50,6 @@ import XMonad.Hooks.DynamicLog
|
||||
import XMonad.Util.Font (Align (..))
|
||||
import XMonad.Util.NamedWindows (getName)
|
||||
|
||||
import Control.Applicative ((<$>))
|
||||
import Control.Exception as E
|
||||
import Data.List (isPrefixOf, isSuffixOf)
|
||||
import Data.Maybe (fromMaybe)
|
||||
@ -189,8 +186,8 @@ logCurrent = withWindowSet $ return . Just . W.currentTag
|
||||
-- $format
|
||||
-- Combine logger formatting functions to make your
|
||||
-- 'XMonad.Hooks.DynamicLog.ppExtras' more colorful and readable.
|
||||
-- (For convenience this module exports 'Control.Applicative.<$>' to
|
||||
-- use instead of \'.\' or \'$\' in hard to read formatting lines.
|
||||
-- (For convenience, you can use '<$>' instead of \'.\' or \'$\' in hard to read
|
||||
-- formatting lines.
|
||||
-- For example:
|
||||
--
|
||||
-- > myLogHook = dynamicLogWithPP def {
|
||||
|
@ -53,8 +53,6 @@ import Data.Bits(Bits((.&.), complement))
|
||||
import Data.List (groupBy)
|
||||
import System.Exit(ExitCode(ExitSuccess), exitWith)
|
||||
|
||||
import Control.Applicative ((<*>))
|
||||
|
||||
import qualified Data.Map as M
|
||||
import qualified XMonad.StackSet as W
|
||||
|
||||
|
@ -23,7 +23,6 @@ module XMonad.Util.NamedWindows (
|
||||
unName
|
||||
) where
|
||||
|
||||
import Control.Applicative ( (<$>) )
|
||||
import Control.Exception.Extensible as E
|
||||
import Data.Maybe ( fromMaybe, listToMaybe )
|
||||
|
||||
@ -54,7 +53,7 @@ getName w = withDisplay $ \d -> do
|
||||
|
||||
copy prop = fromMaybe "" . listToMaybe <$> wcTextPropertyToTextList d prop
|
||||
|
||||
io $ getIt `E.catch` \(SomeException _) -> ((`NW` w) . resName) `fmap` getClassHint d w
|
||||
io $ getIt `E.catch` \(SomeException _) -> ((`NW` w) . resName) <$> getClassHint d w
|
||||
|
||||
-- | Get 'NamedWindow' using 'wM_CLASS'
|
||||
getNameWMClass :: Window -> X NamedWindow
|
||||
@ -68,7 +67,7 @@ getNameWMClass w =
|
||||
fromMaybe "" . listToMaybe <$> wcTextPropertyToTextList d prop
|
||||
io $
|
||||
getIt `E.catch` \(SomeException _) ->
|
||||
((`NW` w) . resName) `fmap` getClassHint d w
|
||||
((`NW` w) . resName) <$> getClassHint d w
|
||||
|
||||
unName :: NamedWindow -> Window
|
||||
unName (NW _ w) = w
|
||||
|
@ -54,7 +54,7 @@ import System.Posix.Env
|
||||
-- > { manageHook = manageRemote =<< io getHostName }
|
||||
|
||||
guessHostName :: IO String
|
||||
guessHostName = pickOneMaybe `liftM` (getEnv `mapM` vars)
|
||||
guessHostName = pickOneMaybe <$> (getEnv `mapM` vars)
|
||||
where
|
||||
pickOneMaybe = last . (mzero:) . take 1 . catMaybes
|
||||
vars = ["XAUTHLOCALHOSTNAME","HOST","HOSTNAME"]
|
||||
|
@ -23,7 +23,6 @@ module XMonad.Util.SessionStart
|
||||
where
|
||||
|
||||
import Control.Monad (when)
|
||||
import Control.Applicative ((<$>))
|
||||
|
||||
import XMonad
|
||||
import qualified XMonad.Util.ExtensibleState as XS
|
||||
|
@ -80,8 +80,8 @@ module XMonad.Util.Stack ( -- * Usage
|
||||
) where
|
||||
|
||||
import qualified XMonad.StackSet as W
|
||||
import Control.Applicative ((<|>),(<$>),(<$))
|
||||
import Control.Monad (guard,liftM)
|
||||
import Control.Applicative ((<|>))
|
||||
import Control.Monad (guard)
|
||||
import Data.List (sortBy)
|
||||
|
||||
|
||||
@ -230,7 +230,7 @@ mapZ_ = mapZ . const
|
||||
|
||||
-- | Monadic version of 'mapZ'
|
||||
mapZM :: Monad m => (Bool -> a -> m b) -> Zipper a -> m (Zipper b)
|
||||
mapZM f as = fromTags `liftM` (mapM (mapEM f) . toTags) as
|
||||
mapZM f as = fromTags <$> (mapM (mapEM f) . toTags) as
|
||||
|
||||
|
||||
-- | Monadic version of 'mapZ_'
|
||||
@ -345,8 +345,8 @@ mapE_ = mapE . const
|
||||
|
||||
-- | Monadic version of 'mapE'
|
||||
mapEM :: Monad m => (Bool -> a -> m b) -> Either a a -> m (Either b b)
|
||||
mapEM f (Left a) = Left `liftM` f False a
|
||||
mapEM f (Right a) = Right `liftM` f True a
|
||||
mapEM f (Left a) = Left <$> f False a
|
||||
mapEM f (Right a) = Right <$> f True a
|
||||
|
||||
mapEM_ :: Monad m => (a -> m b) -> Either a a -> m (Either b b)
|
||||
mapEM_ = mapEM . const
|
||||
|
@ -20,8 +20,6 @@ module XMonad.Util.StringProp (
|
||||
) where
|
||||
|
||||
import XMonad
|
||||
import Control.Monad(liftM)
|
||||
import Control.Applicative((<$>))
|
||||
import Foreign.C.String (castCCharToChar,castCharToCChar)
|
||||
|
||||
type StringProp = String
|
||||
@ -48,7 +46,7 @@ getStringProp dpy prop =
|
||||
-- | Given a property name, returns its contents as a list. It uses the empty
|
||||
-- list as default value.
|
||||
getStringListProp :: (MonadIO m) => Display -> StringProp -> m [String]
|
||||
getStringListProp dpy prop = maybe [] words `liftM` getStringProp dpy prop
|
||||
getStringListProp dpy prop = maybe [] words <$> getStringProp dpy prop
|
||||
|
||||
-- | Given a property name and a list, sets the value of this property with
|
||||
-- the list given as argument.
|
||||
|
@ -79,7 +79,7 @@ propertyToQuery (Role s) = stringProperty "WM_WINDOW_ROLE" =? s
|
||||
propertyToQuery (Machine s) = stringProperty "WM_CLIENT_MACHINE" =? s
|
||||
propertyToQuery (And p1 p2) = propertyToQuery p1 <&&> propertyToQuery p2
|
||||
propertyToQuery (Or p1 p2) = propertyToQuery p1 <||> propertyToQuery p2
|
||||
propertyToQuery (Not p) = not `fmap` propertyToQuery p
|
||||
propertyToQuery (Not p) = not <$> propertyToQuery p
|
||||
propertyToQuery (Const b) = return b
|
||||
propertyToQuery (Tagged s) = ask >>= \w -> liftX (hasTag s w)
|
||||
|
||||
|
@ -27,7 +27,6 @@ import XMonad hiding (get, put, modify)
|
||||
import Control.Monad.Reader(ReaderT(..))
|
||||
import Control.Monad.State.Class
|
||||
import Data.Typeable (typeOf)
|
||||
import Control.Applicative((<$>), Applicative)
|
||||
-- $usage
|
||||
--
|
||||
-- This module allow to store state data with some 'Window'.
|
||||
|
@ -23,7 +23,6 @@ module XMonad.Util.XSelection ( -- * Usage
|
||||
transformSafePromptSelection) where
|
||||
|
||||
import Control.Exception.Extensible as E (catch,SomeException(..))
|
||||
import Control.Monad (liftM, join)
|
||||
import Data.Maybe (fromMaybe)
|
||||
import XMonad
|
||||
import XMonad.Util.Run (safeSpawn, unsafeSpawn)
|
||||
@ -85,8 +84,8 @@ getSelection = io $ do
|
||||
details on the advantages and disadvantages of using safeSpawn. -}
|
||||
promptSelection, safePromptSelection, unsafePromptSelection :: String -> X ()
|
||||
promptSelection = unsafePromptSelection
|
||||
safePromptSelection app = join $ io $ liftM (safeSpawn app . return) getSelection
|
||||
unsafePromptSelection app = join $ io $ liftM unsafeSpawn $ fmap (\x -> app ++ " " ++ x) getSelection
|
||||
safePromptSelection app = safeSpawn app . return =<< getSelection
|
||||
unsafePromptSelection app = unsafeSpawn . (\x -> app ++ " " ++ x) =<< getSelection
|
||||
|
||||
{- | A wrapper around 'promptSelection' and its safe variant. They take two parameters, the
|
||||
first is a function that transforms strings, and the second is the application to run.
|
||||
@ -94,5 +93,5 @@ unsafePromptSelection app = join $ io $ liftM unsafeSpawn $ fmap (\x -> app ++ "
|
||||
One example is to wrap code, such as a command line action copied out of the browser
|
||||
to be run as @"sudo" ++ cmd@ or @"su - -c \""++ cmd ++"\""@. -}
|
||||
transformPromptSelection, transformSafePromptSelection :: (String -> String) -> String -> X ()
|
||||
transformPromptSelection f app = join $ io $ liftM (safeSpawn app . return) (fmap f getSelection)
|
||||
transformSafePromptSelection f app = join $ io $ liftM unsafeSpawn $ fmap (\x -> app ++ " " ++ x) (fmap f getSelection)
|
||||
transformPromptSelection f app = (safeSpawn app . return . f) =<< getSelection
|
||||
transformSafePromptSelection f app = unsafeSpawn . (\x -> app ++ " " ++ x) . f =<< getSelection
|
||||
|
@ -6,7 +6,7 @@ import Foreign.C.Types
|
||||
import Properties
|
||||
|
||||
instance Arbitrary CLong where
|
||||
arbitrary = fromIntegral `fmap` (arbitrary :: Gen Int)
|
||||
arbitrary = fromIntegral <$> (arbitrary :: Gen Int)
|
||||
instance Arbitrary RectC where
|
||||
arbitrary = do
|
||||
(x,y) <- arbitrary
|
||||
|
@ -8,7 +8,6 @@ module Selective where
|
||||
|
||||
import XMonad.Layout.LimitWindows
|
||||
import XMonad.StackSet hiding (focusUp, focusDown, filter)
|
||||
import Control.Applicative ((<$>))
|
||||
import Test.QuickCheck
|
||||
import Control.Arrow (second)
|
||||
|
||||
|
@ -28,7 +28,7 @@ main = do
|
||||
guard $ f `notElem` ["Main.hs", "Common.hs", "Properties.hs"]
|
||||
let b = takeBaseName f
|
||||
nesting <- io $ newIORef 0
|
||||
decl : _ <- ListT $ (map words . lines) `fmap` readFile f
|
||||
decl : _ <- ListT $ (map words . lines) <$> readFile f
|
||||
case decl of
|
||||
"{-" -> io $ modifyIORef nesting succ
|
||||
"-}" -> io $ modifyIORef nesting pred
|
||||
@ -37,7 +37,7 @@ main = do
|
||||
guard $ "prop_" `isPrefixOf` decl
|
||||
io $ modifyIORef imports (S.insert b)
|
||||
return (b ++ "." ++ decl)
|
||||
imports <- S.toList `fmap` readIORef imports
|
||||
imports <- S.toList <$> readIORef imports
|
||||
print $ genModule imports props
|
||||
|
||||
genModule :: [String] -> [String] -> Doc
|
||||
@ -56,7 +56,7 @@ genModule imports props = vcat [header,imports', main ]
|
||||
hang (text "let props = ") 8
|
||||
(brackets $ foldr1 (\x xs -> x <> comma $$ xs) props')
|
||||
$$
|
||||
text "(results, passed) <- liftM unzip $ \
|
||||
text "(results, passed) <- fmap unzip $ \
|
||||
\mapM (\\(s,a) -> printf \"%-40s: \" s >> a n) props"
|
||||
$$
|
||||
text "printf \"Passed %d tests!\\n\" (sum passed)"
|
||||
|
Loading…
x
Reference in New Issue
Block a user