From ee9be16599f20aef6d1d3fd15666c00452f85aba Mon Sep 17 00:00:00 2001 From: Josh Rahm Date: Mon, 21 Nov 2022 12:05:03 -0700 Subject: Format with ormolu. --- src/Rahm/Desktop/Layout/Flip.hs | 57 ++++++++++++++++++++++------------------- 1 file changed, 31 insertions(+), 26 deletions(-) (limited to 'src/Rahm/Desktop/Layout/Flip.hs') diff --git a/src/Rahm/Desktop/Layout/Flip.hs b/src/Rahm/Desktop/Layout/Flip.hs index fe425e9..5942a4a 100644 --- a/src/Rahm/Desktop/Layout/Flip.hs +++ b/src/Rahm/Desktop/Layout/Flip.hs @@ -1,27 +1,27 @@ {-# LANGUAGE DeriveAnyClass #-} -- Layout modifier to flip a layout either horizontally or vertically or both. -module Rahm.Desktop.Layout.Flip ( - Flip(..), +module Rahm.Desktop.Layout.Flip + ( Flip (..), flippable, flipVertically, flipHorizontally, - DoFlip - ) where - -import XMonad -import XMonad.Layout.LayoutModifier + DoFlip, + ) +where import Control.Arrow (second) +import Data.Default (Default (..)) import Data.List (intercalate) -import Data.Default (Default(..)) +import XMonad +import XMonad.Layout.LayoutModifier -- A flipped layout is either flipped horizontally or vertically. -data Flip a = - Flip { - horiz :: Bool - , vert :: Bool - } deriving (Eq, Show, Ord, Read) +data Flip a = Flip + { horiz :: Bool, + vert :: Bool + } + deriving (Eq, Show, Ord, Read) -- Default instance for Flip. Both are set to false. instance Default (Flip a) where @@ -31,11 +31,12 @@ instance Default (Flip a) where data DoFlip where -- Contains a function to modify Flip DoFlip :: (forall k (a :: k). Flip a -> Flip a) -> DoFlip - deriving Message + deriving (Message) -- DoFlip is a monoid. instance Semigroup DoFlip where - (<>) = mappend + (<>) = mappend + instance Monoid DoFlip where mempty = DoFlip id mappend (DoFlip a) (DoFlip b) = DoFlip (a . b) @@ -46,14 +47,13 @@ flippable = ModifiedLayout def -- Message to send a flipVertically message flipVertically :: DoFlip -flipVertically = DoFlip $ \f -> f { vert = not (vert f) } +flipVertically = DoFlip $ \f -> f {vert = not (vert f)} -- Message to send a flipHorizontally message. flipHorizontally :: DoFlip -flipHorizontally = DoFlip $ \f -> f { horiz = not (horiz f) } +flipHorizontally = DoFlip $ \f -> f {horiz = not (horiz f)} instance LayoutModifier Flip a where - -- Modifies the layout. For each rectangle returned from the underlying -- layout, flip it relative to the screen. pureModifier flip (Rectangle sx sy sw sh) stack returned = @@ -62,8 +62,8 @@ instance LayoutModifier Flip a where -- doFlip -- the composition of maybe flipping horizontally and -- vertically. doFlip = - (if horiz flip then flipHoriz else id) . - (if vert flip then flipVert else id) + (if horiz flip then flipHoriz else id) + . (if vert flip then flipVert else id) flipVert (Rectangle x y w h) = Rectangle ((sx + fromIntegral sw) - x - fromIntegral w + sx) y w h @@ -78,10 +78,15 @@ instance LayoutModifier Flip a where modifyDescription flip (description -> descr) = (++) descr $ if horiz flip || vert flip - then intercalate " and " ( - map snd $ - filter fst [ - (horiz flip, "Horizontally"), - (vert flip, "Vertically")]) - ++ " Flipped" + then + intercalate + " and " + ( map snd $ + filter + fst + [ (horiz flip, "Horizontally"), + (vert flip, "Vertically") + ] + ) + ++ " Flipped" else "" -- cgit