summaryrefslogtreecommitdiffstats
path: root/StackSet.hs
diff options
context:
space:
mode:
authorMichael G. Sloan <mgsloan@gmail.com>2007-07-22 22:53:37 +0200
committerMichael G. Sloan <mgsloan@gmail.com>2007-07-22 22:53:37 +0200
commit3db17331b1d1308f8d9ceb336d1bfef7a91fadc5 (patch)
treec40f28b3da216af314feed897813a8d0ea8814d5 /StackSet.hs
parente0f1d01bd6551dd3282a580c83fa359d2348320e (diff)
downloadmetatile-3db17331b1d1308f8d9ceb336d1bfef7a91fadc5.tar
metatile-3db17331b1d1308f8d9ceb336d1bfef7a91fadc5.zip
Cleanup of shift code
darcs-hash:20070722205337-0d649-35419b898df5fc30d9a48bde46f8ede66e39c009
Diffstat (limited to 'StackSet.hs')
-rw-r--r--StackSet.hs8
1 files changed, 4 insertions, 4 deletions
diff --git a/StackSet.hs b/StackSet.hs
index 037b124..265359c 100644
--- a/StackSet.hs
+++ b/StackSet.hs
@@ -487,7 +487,7 @@ swapMaster = modify' $ \c -> case c of
-- element on the current stack, the original stackSet is returned.
--
shift :: (Ord a, Eq s, Integral i) => i -> StackSet i a s sd -> StackSet i a s sd
-shift n s = if and [n >= 0,n `tagMember` s, n /= tag (workspace (current s))]
- then maybe s go (peek s) else s
- where go w = foldr ($) s [view (tag (workspace (current s))),insertUp w,view n,delete w]
- -- ^^ poor man's state monad :-)
+shift n s = if n >= 0 && n `tagMember` s && n /= curtag
+ then maybe s go (peek s) else s
+ where go w = view curtag . insertUp w . view n . delete w $ s
+ curtag = tag (workspace (current s))