Throwing exceptions from a xmonad-contrib module

Hi all, A beginner XMonad hacker question: on reading the sources for the CycleSelectedLayouts extension I found one thing to be slightly weird. Check the following snippet: cycleToNext :: (Eq a) => [a] -> a -> Maybe a cycleToNext lst a = do -- not beautiful but simple and readable ind <- findIndex (a==) lst return $ lst !! if ind == length lst - 1 then 0 else ind+1 -- | If the current layout is in the list, cycle to the next layout. Otherwise, -- apply the first layout from list. cycleThroughLayouts :: [String] -> X () cycleThroughLayouts lst = do winset <- gets windowset let ld = description . S.layout . S.workspace . S.current $ winset let newld = fromMaybe (head lst) (cycleToNext lst ld) sendMessage $ JumpToLayout newld If you apply cycleThroughLayouts on an empty list, it will try to take the list's head. That doesn't crash xmonad, though, because the exception is swallowed by sendMessage. Would throwing an exception "needlessly" like that just because it will be caught later on count as a bug or is it something not worth bothering about? Daniel
participants (1)
-
Daniel Mlot