summaryrefslogtreecommitdiffstats
path: root/StackSet.hs
diff options
context:
space:
mode:
authorDavid Roundy <droundy@darcs.net>2007-10-17 22:14:06 +0200
committerDavid Roundy <droundy@darcs.net>2007-10-17 22:14:06 +0200
commit7d65f3be35e75ce8f99b26a7ddc47a30c93574a5 (patch)
treed86783436bd7df040b8484ed1165277cbdf2da98 /StackSet.hs
parent50de8ecdeda61e4637b12a250ea79d5e4723fb1e (diff)
downloadmetatile-7d65f3be35e75ce8f99b26a7ddc47a30c93574a5.tar
metatile-7d65f3be35e75ce8f99b26a7ddc47a30c93574a5.zip
remove StackOrNot type synonymn.
darcs-hash:20071017201406-72aca-2845317199eb5888392c1b2fa9004d29f59d6c5c
Diffstat (limited to 'StackSet.hs')
-rw-r--r--StackSet.hs14
1 files changed, 6 insertions, 8 deletions
diff --git a/StackSet.hs b/StackSet.hs
index 90609ee..e9006f7 100644
--- a/StackSet.hs
+++ b/StackSet.hs
@@ -14,7 +14,7 @@
module StackSet (
-- * Introduction
-- $intro
- StackSet(..), Workspace(..), Screen(..), StackOrNot, Stack(..), RationalRect(..),
+ StackSet(..), Workspace(..), Screen(..), Stack(..), RationalRect(..),
-- * Construction
-- $construction
new, view, greedyView,
@@ -169,7 +169,7 @@ data Screen i l a sid sd = Screen { workspace :: !(Workspace i l a)
-- |
-- A workspace is just a tag - its index - and a stack
--
-data Workspace i l a = Workspace { tag :: !i, layout :: l, stack :: StackOrNot a }
+data Workspace i l a = Workspace { tag :: !i, layout :: l, stack :: Maybe (Stack a) }
deriving (Show, Read, Eq)
-- | A structure for window geometries
@@ -194,8 +194,6 @@ data RationalRect = RationalRect Rational Rational Rational Rational
-- structures, it is the differentiation of a [a], and integrating it
-- back has a natural implementation used in 'index'.
--
-type StackOrNot a = Maybe (Stack a)
-
data Stack a = Stack { focus :: !a -- focused thing in this set
, up :: [a] -- clowns to the left
, down :: [a] } -- jokers to the right
@@ -294,7 +292,7 @@ with dflt f = maybe dflt f . stack . workspace . current
-- |
-- Apply a function, and a default value for Nothing, to modify the current stack.
--
-modify :: StackOrNot a -> (Stack a -> StackOrNot a) -> StackSet i l a s sd -> StackSet i l a s sd
+modify :: Maybe (Stack a) -> (Stack a -> Maybe (Stack a)) -> StackSet i l a s sd -> StackSet i l a s sd
modify d f s = s { current = (current s)
{ workspace = (workspace (current s)) { stack = with d f s }}}
@@ -320,13 +318,13 @@ integrate (Stack x l r) = reverse l ++ x : r
-- |
-- /O(n)/ Flatten a possibly empty stack into a list.
-integrate' :: StackOrNot a -> [a]
+integrate' :: Maybe (Stack a) -> [a]
integrate' = maybe [] integrate
-- |
-- /O(n)/. Texture a list.
--
-differentiate :: [a] -> StackOrNot a
+differentiate :: [a] -> Maybe (Stack a)
differentiate [] = Nothing
differentiate (x:xs) = Just $ Stack x [] xs
@@ -334,7 +332,7 @@ differentiate (x:xs) = Just $ Stack x [] xs
-- /O(n)/. 'filter p s' returns the elements of 's' such that 'p' evaluates to
-- True. Order is preserved, and focus moves as described for 'delete'.
--
-filter :: (a -> Bool) -> Stack a -> StackOrNot a
+filter :: (a -> Bool) -> Stack a -> Maybe (Stack a)
filter p (Stack f ls rs) = case L.filter p (f:rs) of
f':rs' -> Just $ Stack f' (L.filter p ls) rs' -- maybe move focus down
[] -> case L.filter p ls of -- filter back up