summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDon Stewart <dons@cse.unsw.edu.au>2007-04-30 04:17:58 +0200
committerDon Stewart <dons@cse.unsw.edu.au>2007-04-30 04:17:58 +0200
commit240245e14604399f52a364377585d7520a41a540 (patch)
tree1f0757ef01f7cf169ddb5ac0255abd5cf98c3d03
parentcb713dde064fc505a191cd39c3714fc2dd5e7f43 (diff)
downloadmetatile-240245e14604399f52a364377585d7520a41a540.tar
metatile-240245e14604399f52a364377585d7520a41a540.zip
move size into Properties.hs
darcs-hash:20070430021758-9c5c1-f1ae3d5c2639b9c3ee91ccdebaefe0cf4a2c6df5
-rw-r--r--StackSet.hs5
-rw-r--r--tests/Properties.hs5
2 files changed, 6 insertions, 4 deletions
diff --git a/StackSet.hs b/StackSet.hs
index 9666d6a..b052141 100644
--- a/StackSet.hs
+++ b/StackSet.hs
@@ -107,8 +107,6 @@ index k w = fromJust (M.lookup k (stacks w))
-- visible on the current screen. If the index is out of range an exception is
-- thrown.
view :: (Integral i, Integral j) => i -> StackSet i j a -> StackSet i j a
--- view n w | n >= 0 && n < fromIntegral (M.size (stacks w)) -- coerce
-
view n w | M.member n (stacks w)
= if M.member n (ws2screen w) then w { current = n }
else tweak (fromJust $ screen (current w) w)
@@ -116,8 +114,7 @@ view n w | M.member n (stacks w)
where
tweak sc = w { screen2ws = M.insert sc n (screen2ws w)
, ws2screen = M.insert n sc (M.filter (/=sc) (ws2screen w))
- , current = n
- }
+ , current = n }
-- | That screen that workspace 'n' is visible on, if any.
screen :: Integral i => i -> StackSet i j a -> Maybe j
diff --git a/tests/Properties.hs b/tests/Properties.hs
index 83aba87..19ccf49 100644
--- a/tests/Properties.hs
+++ b/tests/Properties.hs
@@ -17,6 +17,7 @@ import System.Random
import Text.Printf
import Data.List (nub,sort,group,sort,intersperse,genericLength)
import Data.Map (keys,elems)
+import qualified Data.Map as M
-- ---------------------------------------------------------------------
-- QuickCheck properties for the StackSet
@@ -40,6 +41,10 @@ fromList (o,m,xs) = view o $ foldr (\(i,ys) s ->
-- ---------------------------------------------------------------------
+-- | /O(n)/. Number of stacks
+size :: T -> Int
+size = M.size . stacks
+
-- | Height of stack 'n'
height :: Int -> T -> Int
height i w = length (index i w)