On Thu, Dec 31, 2015 at 5:53 PM, Adam Sjøgren <asjo@koldfront.dk> wrote:
  -- manage a new window
  handle (MapRequestEvent    {ev_window = w}) = withDisplay $ \dpy -> do
      wa <- io $ getWindowAttributes dpy w -- ignore override windows
      -- need to ignore mapping requests by managed windows not on the current workspace
      managed <- isClient w
      when (not (wa_override_redirect wa) && not managed) $ do manage w

What needs to happen is that I need to wrap this, so if
getWindowAttributes throws an exception, something reasonable happens.

What exceptions are you expecting? The only one I'd expect is no such window, in which case you kinda want to abort anyway.

I've tried a number of combinations of wrapping C.handle around this,
similar to what I have found before², but I certainly need (to read a
lot more, or, some) help - I keep getting IO () when I need X (), or the
opposite, and stuff like that.

http://xmonad.org/xmonad-docs/xmonad/XMonad-Core.html#v:catchX to catch exceptions from code producing X something.
http://xmonad.org/xmonad-docs/xmonad/XMonad-Core.html#v:catchIO to catch exceptions from code producing IO something.

(Don't feel too bad about this, it's actually a surprisingly hard problem in the general case. MonadBaseControl grew out of trying to deal with it in various situations, because it's hard to do "catch" properly in a monad over IO and impossible to do "bracket" properly. Specific cases can be done, as above catchX / catchIO, but even then require some thinking to write in the first place.)

--
brandon s allbery kf8nh                               sine nomine associates
allbery.b@gmail.com                                  ballbery@sinenomine.net
unix, openafs, kerberos, infrastructure, xmonad        http://sinenomine.net