From 69c51b662a5a98769d302c2cca35e5942ec184a3 Mon Sep 17 00:00:00 2001 From: Devin Mullins Date: Sat, 6 Oct 2007 07:41:04 +0200 Subject: (cleanup) extract mapWorkspace out of renameTag darcs-hash:20071006054104-78224-364be3b89447beadba7438f7ebe3f867f4677a61 --- StackSet.hs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/StackSet.hs b/StackSet.hs index 8b8d123..e5eef97 100644 --- a/StackSet.hs +++ b/StackSet.hs @@ -410,11 +410,8 @@ tagMember t = elem t . map tag . workspaces -- | Rename a given tag if present in the StackSet. renameTag :: Eq i => i -> i -> StackSet i l a s sd -> StackSet i l a s sd -renameTag o n s = s { current = rs $ current s - , visible = map rs $ visible s - , hidden = map rw $ hidden s } - where rs scr = scr { workspace = rw $ workspace scr } - rw w = if tag w == o then w { tag = n } else w +renameTag o n = mapWorkspace rename + where rename w = if tag w == o then w { tag = n } else w -- | Ensure that a given set of tags is present. ensureTags :: Eq i => l -> [i] -> StackSet i l a s sd -> StackSet i l a s sd @@ -424,6 +421,14 @@ ensureTags l allt st = et allt (map tag (workspaces st) \\ allt) st et (i:is) [] s = et is [] (s { hidden = Workspace i l Nothing : hidden s }) et (i:is) (r:rs) s = et is rs $ renameTag r i s +-- | Map a function on all the workspaces in the StackSet. +mapWorkspace :: (Workspace i l a -> Workspace i l a) -> StackSet i l a s sd -> StackSet i l a s sd +mapWorkspace f s = s { current = updScr $ current s + , visible = map updScr $ visible s + , hidden = map f $ hidden s } + where updScr scr = scr { workspace = f $ workspace scr } + +-- | Map a function on all the layouts in the StackSet. mapLayout :: (l -> l') -> StackSet i l a s sd -> StackSet i l' a s sd mapLayout f (StackSet v vs hs m) = StackSet (fScreen v) (map fScreen vs) (map fWorkspace hs) m where -- cgit v1.2.3