From bc0db7c00b01ee9f16bdce040ff1298b25a3a1b6 Mon Sep 17 00:00:00 2001 From: Spencer Janssen Date: Tue, 8 May 2007 16:39:51 +0200 Subject: StackSet.view: ignore invalid indices darcs-hash:20070508143951-a5988-5b1aea6415436bc5cee632a60efc42300cfbf1e9 --- StackSet.hs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/StackSet.hs b/StackSet.hs index 7883daa..74d63eb 100644 --- a/StackSet.hs +++ b/StackSet.hs @@ -104,13 +104,13 @@ index k w = uncurry (++) $ fromJust $ 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 --- visible on the current screen. If the index is out of range an exception is --- thrown. +-- visible on the current screen. If the index is out of range 'view' returns +-- the initial 'StackSet' unchanged. view :: (Integral i, Integral j) => i -> StackSet i j a -> StackSet i j a 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) - | otherwise = error $ "view: index out of bounds: " ++ show n + | otherwise = w where tweak sc = w { screen2ws = M.insert sc n (screen2ws w) , ws2screen = M.insert n sc (M.filter (/=sc) (ws2screen w)) -- cgit v1.2.3