diff options
author | Spencer Janssen <sjanssen@cse.unl.edu> | 2007-05-08 17:12:00 +0200 |
---|---|---|
committer | Spencer Janssen <sjanssen@cse.unl.edu> | 2007-05-08 17:12:00 +0200 |
commit | f4c2b23fecc863218a395d731bd18c2afd164db4 (patch) | |
tree | 497c519fa8f5bf9670d0b36338e2917c7b631130 /StackSet.hs | |
parent | 22db9163bf3b003162ccdf3272a27b77f89ad7a0 (diff) | |
download | xmonad-f4c2b23fecc863218a395d731bd18c2afd164db4.tar.gz xmonad-f4c2b23fecc863218a395d731bd18c2afd164db4.tar.xz xmonad-f4c2b23fecc863218a395d731bd18c2afd164db4.zip |
Make 'index' return Nothing, rather than error
darcs-hash:20070508151200-a5988-3da2bb925de6c610ed9b7a5ab5bccedb3483d032.gz
Diffstat (limited to '')
-rw-r--r-- | StackSet.hs | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/StackSet.hs b/StackSet.hs index 3f615bf..38baca2 100644 --- a/StackSet.hs +++ b/StackSet.hs @@ -98,9 +98,9 @@ peekStack :: Integral i => i -> StackSet i j a -> Maybe a peekStack i w = M.lookup i (focus w) -- | /O(log s)/. Index. Extract the stack at workspace 'n'. --- If the index is invalid, an exception is thrown. -index :: Integral i => i -> StackSet i j a -> [a] -index k w = uncurry (++) $ fromJust $ M.lookup k (stacks w) +-- If the index is invalid, returns Nothing. +index :: Integral i => i -> StackSet i j a -> Maybe [a] +index k w = fmap (uncurry (++)) $ M.lookup k (stacks w) -- | view. Set the stack specified by the argument as being visible and the -- current StackSet. If the stack wasn't previously visible, it will become @@ -173,7 +173,7 @@ delete k w = maybe w del (M.lookup k (cache w)) where del i = w { cache = M.delete k (cache w) , stacks = M.adjust (\(xs, ys) -> (L.delete k xs, L.delete k ys)) i (stacks w) - , focus = M.update (\k' -> if k == k' then elemAfter k (index i w) + , focus = M.update (\k' -> if k == k' then elemAfter k =<< index i w else Just k') i (focus w) } -- | /O(log n)/. If the given window is contained in a workspace, make it the |