diff options
| author | Josh Rahm <rahm@google.com> | 2022-11-21 12:05:03 -0700 |
|---|---|---|
| committer | Josh Rahm <rahm@google.com> | 2022-11-21 12:05:03 -0700 |
| commit | ee9be16599f20aef6d1d3fd15666c00452f85aba (patch) | |
| tree | 1aed66c1de2ce201463e3becc2d452d4a8aa2992 /src/Rahm/Desktop/History.hs | |
| parent | a1636c65e05d02f7d4fc408137e1d37b412ce890 (diff) | |
| download | rde-ee9be16599f20aef6d1d3fd15666c00452f85aba.tar.gz rde-ee9be16599f20aef6d1d3fd15666c00452f85aba.tar.bz2 rde-ee9be16599f20aef6d1d3fd15666c00452f85aba.zip | |
Format with ormolu.
Diffstat (limited to 'src/Rahm/Desktop/History.hs')
| -rw-r--r-- | src/Rahm/Desktop/History.hs | 41 |
1 files changed, 20 insertions, 21 deletions
diff --git a/src/Rahm/Desktop/History.hs b/src/Rahm/Desktop/History.hs index 516cd94..c5bc72d 100644 --- a/src/Rahm/Desktop/History.hs +++ b/src/Rahm/Desktop/History.hs @@ -1,19 +1,18 @@ module Rahm.Desktop.History where -import XMonad -import Text.Printf -import qualified Rahm.Desktop.StackSet as W -import Data.IntMap (IntMap) -import qualified Data.IntMap as IntMap import Data.Default -import qualified XMonad.Util.ExtensibleState as XS - import Data.Foldable (toList) -import Rahm.Desktop.Hooks.WindowChange +import Data.IntMap (IntMap) +import qualified Data.IntMap as IntMap +import Data.Sequence (Seq (..)) +import qualified Data.Sequence as Seq import Rahm.Desktop.Common +import Rahm.Desktop.Hooks.WindowChange import Rahm.Desktop.Logger -import Data.Sequence (Seq(..)) -import qualified Data.Sequence as Seq +import qualified Rahm.Desktop.StackSet as W +import Text.Printf +import XMonad +import qualified XMonad.Util.ExtensibleState as XS data BoundedSeqZipper a = BoundedSeqZipper Int (Seq a) (Seq a) deriving (Eq, Show, Ord, Read) @@ -24,15 +23,15 @@ instance Functor BoundedSeqZipper where zipperDbgPrint :: (Show a) => BoundedSeqZipper a -> String zipperDbgPrint (BoundedSeqZipper _ h (c :<| t)) = concat $ - map (printf " %s " . show) (toList h) ++ - [printf "[%s]" (show c)] ++ - map (printf " %s " . show) (toList t) + map (printf " %s " . show) (toList h) + ++ [printf "[%s]" (show c)] + ++ map (printf " %s " . show) (toList t) zipperDbgPrint _ = "<empty>" pushZipper :: a -> BoundedSeqZipper a -> BoundedSeqZipper a pushZipper e (BoundedSeqZipper maxSize _ (tail :|> _)) - | maxSize <= Seq.length tail = - BoundedSeqZipper maxSize mempty (e :<| tail) + | maxSize <= Seq.length tail = + BoundedSeqZipper maxSize mempty (e :<| tail) pushZipper e (BoundedSeqZipper maxSize _ tail) = BoundedSeqZipper maxSize mempty (e :<| tail) @@ -48,16 +47,18 @@ zipperForward :: BoundedSeqZipper a -> BoundedSeqZipper a zipperForward (BoundedSeqZipper s (e :<| h) t) = BoundedSeqZipper s h (e :<| t) zipperForward b = b -newtype History = History { - currentZipper :: BoundedSeqZipper Location -} deriving (Read, Show) +newtype History = History + { currentZipper :: BoundedSeqZipper Location + } + deriving (Read, Show) instance Default History where def = History (BoundedSeqZipper 1000 mempty mempty) instance ExtensionClass History where initialValue = def - -- extensionType = PersistentExtension + +-- extensionType = PersistentExtension pastHistory :: Int -> X (Maybe Location) pastHistory i = do @@ -72,7 +73,6 @@ getMostRecentLocationInHistory = do (BoundedSeqZipper _ _ (t :<| _)) -> return $ Just t _ -> return Nothing - historyBack :: X () historyBack = do History z <- XS.get @@ -101,5 +101,4 @@ historyHook Nothing loc = XS.modify $ \(History z) -> History (pushZipper loc z) historyHook (Just (Location ws _)) l@(Location ws' _) | ws /= ws' = do XS.modify $ \(History z) -> History (pushZipper l z) - historyHook _ _ = return () |