From 29ac61273049a8c3298f3ca834deb3e743fcb4c7 Mon Sep 17 00:00:00 2001 From: Don Stewart Date: Sun, 1 Apr 2007 02:47:26 +0200 Subject: formatting only darcs-hash:20070401004726-9c5c1-ffe359da72bfe742bd6c6855e8451c0ea8a8938f.gz --- StackSet.hs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'StackSet.hs') diff --git a/StackSet.hs b/StackSet.hs index 2e02468..2fc8020 100644 --- a/StackSet.hs +++ b/StackSet.hs @@ -158,9 +158,13 @@ insert k n old = new { cache = M.insert k n (cache new) -- If the element doesn't exist, the original StackSet is returned unmodified. delete :: Ord a => a -> StackSet a -> StackSet a delete k w = maybe w tweak (M.lookup k (cache w)) - where tweak i = w { cache = M.delete k (cache w) - , stacks = M.adjust (L.delete k) i (stacks w) - , focus = M.update (\k' -> if k == k' then elemAfter k (stacks w M.! i) else Just k') i (focus w) } + where + tweak i = w { cache = M.delete k (cache w) + , stacks = M.adjust (L.delete k) i (stacks w) + , focus = M.update (\k' -> if k == k' then elemAfter k (stacks w M.! i) + else Just k') i + (focus w) + } -- | /O(log n)/. If the given window is contained in a workspace, make it the -- focused window of that workspace, and make that workspace the current one. @@ -175,5 +179,6 @@ promote k w = case M.lookup k (cache w) of Nothing -> w Just i -> w { stacks = M.adjust (\ks -> k : filter (/= k) ks) i (stacks w) } +-- | elemAfter :: Eq a => a -> [a] -> Maybe a elemAfter w ws = listToMaybe . filter (/= w) . dropWhile (/= w) $ ws ++ ws -- cgit v1.2.3