From c5b25d0fb00ff878886df89842c4a442819a0800 Mon Sep 17 00:00:00 2001 From: Adam Vogt Date: Fri, 16 Apr 2010 23:29:39 +0200 Subject: Use imported `fi' alias for fromIntegral more often. Ignore-this: 51040e693066fd7803cc1b108c1a13d5 Also moves `fi' into U.Image to avoid cyclic imports, though XUtils sill exports that definition. darcs-hash:20100416212939-1499c-a12428074d873b1eaea197e1b79c0ca07a96b05f.gz --- XMonad/Actions/FlexibleResize.hs | 4 +--- XMonad/Actions/UpdatePointer.hs | 4 +--- XMonad/Hooks/ManageDocks.hs | 4 +--- XMonad/Hooks/Place.hs | 3 +-- XMonad/Layout/Gaps.hs | 4 +--- XMonad/Layout/Magnifier.hs | 4 +--- XMonad/Layout/Reflect.hs | 3 +-- XMonad/Util/Image.hs | 5 ++++- XMonad/Util/XUtils.hs | 3 --- 9 files changed, 11 insertions(+), 23 deletions(-) diff --git a/XMonad/Actions/FlexibleResize.hs b/XMonad/Actions/FlexibleResize.hs index a387c19..05f232f 100644 --- a/XMonad/Actions/FlexibleResize.hs +++ b/XMonad/Actions/FlexibleResize.hs @@ -20,6 +20,7 @@ module XMonad.Actions.FlexibleResize ( ) where import XMonad +import XMonad.Util.XUtils (fi) import Foreign.C.Types -- $usage @@ -76,6 +77,3 @@ mouseResizeEdgeWindow edge w = whenX (isClient w) $ withDisplay $ \d -> do Just True -> (0, (fi k + fi p -).fi, (fi k + fi p -).fi) Nothing -> (k `div` 2, const p, const $ fi k) Just False -> (k, const p, subtract (fi p) . fi) - -fi :: (Num b, Integral a) => a -> b -fi = fromIntegral diff --git a/XMonad/Actions/UpdatePointer.hs b/XMonad/Actions/UpdatePointer.hs index 7fff869..4eed35d 100644 --- a/XMonad/Actions/UpdatePointer.hs +++ b/XMonad/Actions/UpdatePointer.hs @@ -24,6 +24,7 @@ module XMonad.Actions.UpdatePointer where import XMonad +import XMonad.Util.XUtils (fi) import Control.Monad import XMonad.StackSet (member, peek, screenDetail, current) import Data.Maybe @@ -102,6 +103,3 @@ moveWithin now lower upper = else if now > upper then upper else now - -fi :: (Num b, Integral a) => a -> b -fi = fromIntegral diff --git a/XMonad/Hooks/ManageDocks.hs b/XMonad/Hooks/ManageDocks.hs index 084b02c..5f7577b 100644 --- a/XMonad/Hooks/ManageDocks.hs +++ b/XMonad/Hooks/ManageDocks.hs @@ -33,6 +33,7 @@ import Foreign.C.Types (CLong) import XMonad.Layout.LayoutModifier import XMonad.Util.Types import XMonad.Util.WindowProperties (getProp32s) +import XMonad.Util.XUtils (fi) import qualified Data.Set as S @@ -211,9 +212,6 @@ type Strut = (Direction2D, CLong, CLong, CLong) type RectC = (CLong, CLong, CLong, CLong) -fi :: (Integral a, Num b) => a -> b -fi = fromIntegral - -- | Invertible conversion. r2c :: Rectangle -> RectC diff --git a/XMonad/Hooks/Place.hs b/XMonad/Hooks/Place.hs index b3b8ad2..98f7dc1 100644 --- a/XMonad/Hooks/Place.hs +++ b/XMonad/Hooks/Place.hs @@ -38,6 +38,7 @@ import qualified XMonad.StackSet as S import XMonad.Layout.WindowArranger import XMonad.Actions.FloatKeys +import XMonad.Util.XUtils import qualified Data.Map as M import Data.Ratio ((%)) @@ -262,8 +263,6 @@ checkBounds (Rectangle x1 y1 w1 h1) (Rectangle x2 y2 w2 h2) scale :: (RealFrac a, Integral b) => a -> b -> b -> b scale r n1 n2 = truncate $ r * fi n2 + (1 - r) * fi n1 -fi :: (Integral a, Num b) => a -> b -fi = fromIntegral r2rr :: Rectangle -> Rectangle -> S.RationalRect r2rr (Rectangle x0 y0 w0 h0) (Rectangle x y w h) diff --git a/XMonad/Layout/Gaps.hs b/XMonad/Layout/Gaps.hs index 76dd57c..f672ea5 100644 --- a/XMonad/Layout/Gaps.hs +++ b/XMonad/Layout/Gaps.hs @@ -38,6 +38,7 @@ import Graphics.X11 (Rectangle(..)) import XMonad.Layout.LayoutModifier import XMonad.Util.Types (Direction2D(..)) +import XMonad.Util.XUtils (fi) import Data.List (delete) @@ -133,9 +134,6 @@ toggleGap conf cur d | d `elem` cur = delete d cur incGap :: GapSpec -> Direction2D -> Int -> GapSpec incGap gs d i = map (\(dir,j) -> if dir == d then (dir,max (j+i) 0) else (dir,j)) gs -fi :: (Num b, Integral a) => a -> b -fi = fromIntegral - -- | Add togglable manual gaps to a layout. gaps :: GapSpec -- ^ The gaps to allow, paired with their initial sizes. -> l a -- ^ The layout to modify. diff --git a/XMonad/Layout/Magnifier.hs b/XMonad/Layout/Magnifier.hs index 7f812ce..6113412 100644 --- a/XMonad/Layout/Magnifier.hs +++ b/XMonad/Layout/Magnifier.hs @@ -32,6 +32,7 @@ module XMonad.Layout.Magnifier import XMonad import XMonad.StackSet import XMonad.Layout.LayoutModifier +import XMonad.Util.XUtils -- $usage -- You can use this module with the following in your @~\/.xmonad\/xmonad.hs@: @@ -159,6 +160,3 @@ fit (Rectangle sx sy sw sh) (Rectangle x y w h) = Rectangle x' y' w' h' y' = max sy (y - (max 0 (y + fi h - sy - fi sh))) w' = min sw w h' = min sh h - -fi :: (Num b, Integral a) => a -> b -fi = fromIntegral diff --git a/XMonad/Layout/Reflect.hs b/XMonad/Layout/Reflect.hs index bd127ea..19f6200 100644 --- a/XMonad/Layout/Reflect.hs +++ b/XMonad/Layout/Reflect.hs @@ -29,6 +29,7 @@ import Control.Arrow (second) import XMonad.Layout.LayoutModifier import XMonad.Layout.MultiToggle +import XMonad.Util.XUtils (fi) -- $usage -- You can use this module by importing it into your @~\/.xmonad\/xmonad.hs@ file: @@ -85,8 +86,6 @@ reflectRect Horiz (Rectangle sx _ sw _) (Rectangle rx ry rw rh) = reflectRect Vert (Rectangle _ sy _ sh) (Rectangle rx ry rw rh) = Rectangle rx (2*sy + fi sh - ry - fi rh) rw rh -fi :: (Integral a, Num b) => a -> b -fi = fromIntegral data Reflect a = Reflect ReflectDir deriving (Show, Read) diff --git a/XMonad/Util/Image.hs b/XMonad/Util/Image.hs index 92ef76c..472586f 100644 --- a/XMonad/Util/Image.hs +++ b/XMonad/Util/Image.hs @@ -17,7 +17,9 @@ module XMonad.Util.Image -- $usage Placement(..), iconPosition, - drawIcon + drawIcon, + + fi, ) where import XMonad @@ -86,6 +88,7 @@ drawIcon dpy drw gc fc bc x y icon = do io $ setForeground dpy gc fcolor io $ drawPoints dpy drw gc (movePoints x y (iconToPoints icon)) coordModeOrigin + -- | Short-hand for 'fromIntegral' fi :: (Integral a, Num b) => a -> b fi = fromIntegral diff --git a/XMonad/Util/XUtils.hs b/XMonad/Util/XUtils.hs index acc4558..8ea3653 100644 --- a/XMonad/Util/XUtils.hs +++ b/XMonad/Util/XUtils.hs @@ -204,6 +204,3 @@ mkWindow d s rw x y w h p o = do createWindow d rw x y w h 0 (defaultDepthOfScreen s) inputOutput visual attrmask attributes --- | Short-hand for 'fromIntegral' -fi :: (Integral a, Num b) => a -> b -fi = fromIntegral -- cgit v1.2.3