summaryrefslogtreecommitdiffstats
path: root/StackSet.hs
diff options
context:
space:
mode:
authorDon Stewart <dons@cse.unsw.edu.au>2007-04-19 06:08:33 +0200
committerDon Stewart <dons@cse.unsw.edu.au>2007-04-19 06:08:33 +0200
commite2e8381eade4c9f7e90476e93b920f0d9e5ab9d1 (patch)
tree76417b8821a4fc4801dd775ce3e5a4f220c3a783 /StackSet.hs
parent169cc9b32475c25bc5a7e9342aa3098ee776c0ad (diff)
downloadmetatile-e2e8381eade4c9f7e90476e93b920f0d9e5ab9d1.tar
metatile-e2e8381eade4c9f7e90476e93b920f0d9e5ab9d1.zip
add 8 new QC tests, including tests of the layout algorithm
darcs-hash:20070419040833-9c5c1-9d8965bf22113a8aec47244eab7c769affb75951
Diffstat (limited to 'StackSet.hs')
-rw-r--r--StackSet.hs8
1 files changed, 6 insertions, 2 deletions
diff --git a/StackSet.hs b/StackSet.hs
index 5dc95b1..07a8424 100644
--- a/StackSet.hs
+++ b/StackSet.hs
@@ -25,7 +25,7 @@ module StackSet (
screen, peekStack, index, empty, peek, push, delete, member,
raiseFocus, rotate, promote, shift, view, workspace, fromList,
- toList, size, visibleWorkspaces
+ toList, size, visibleWorkspaces, swap {- helper -}
) where
import Data.Maybe
@@ -219,12 +219,16 @@ promote :: (Integral i, Ord a) => StackSet i j a -> StackSet i j a
promote w = maybe w id $ do
a <- peek w -- fail if null
let w' = w { stacks = M.adjust (\s -> swap a (head s) s) (current w) (stacks w) }
- return $ insert a (current w) w' -- and maintain focus
+ return $ insert a (current w) w' -- and maintain focus (?)
--
-- | Swap first occurences of 'a' and 'b' in list.
-- If both elements are not in the list, the list is unchanged.
--
+-- Given a set as a list (no duplicates)
+--
+-- > swap a b . swap a b == id
+--
swap :: Eq a => a -> a -> [a] -> [a]
swap a b xs
| a == b = xs -- do nothing