<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Thu, Dec 31, 2015 at 5:53 PM, Adam Sjøgren <span dir="ltr"><<a href="mailto:asjo@koldfront.dk" target="_blank">asjo@koldfront.dk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">  -- manage a new window<br>
  handle (MapRequestEvent    {ev_window = w}) = withDisplay $ \dpy -> do<br>
      wa <- io $ getWindowAttributes dpy w -- ignore override windows<br>
      -- need to ignore mapping requests by managed windows not on the current workspace<br>
      managed <- isClient w<br>
      when (not (wa_override_redirect wa) && not managed) $ do manage w<br>
<br>
What needs to happen is that I need to wrap this, so if<br>
getWindowAttributes throws an exception, something reasonable happens.<br></blockquote><div><br></div><div>What exceptions are you expecting? The only one I'd expect is no such window, in which case you kinda want to abort anyway.</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">I've tried a number of combinations of wrapping C.handle around this,<br>
similar to what I have found before², but I certainly need (to read a<br>
lot more, or, some) help - I keep getting IO () when I need X (), or the<br>
opposite, and stuff like that.<br></blockquote><div><br></div><div><a href="http://xmonad.org/xmonad-docs/xmonad/XMonad-Core.html#v:catchX">http://xmonad.org/xmonad-docs/xmonad/XMonad-Core.html#v:catchX</a> to catch exceptions from code producing X something.<br></div><div><a href="http://xmonad.org/xmonad-docs/xmonad/XMonad-Core.html#v:catchIO">http://xmonad.org/xmonad-docs/xmonad/XMonad-Core.html#v:catchIO</a> to catch exceptions from code producing IO something.<br></div><div><br></div><div>(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.)</div><div><br></div></div>-- <br><div class="gmail_signature"><div dir="ltr"><div>brandon s allbery kf8nh                               sine nomine associates</div><div><a href="mailto:allbery.b@gmail.com" target="_blank">allbery.b@gmail.com</a>                                  <a href="mailto:ballbery@sinenomine.net" target="_blank">ballbery@sinenomine.net</a></div><div>unix, openafs, kerberos, infrastructure, xmonad        <a href="http://sinenomine.net" target="_blank">http://sinenomine.net</a></div></div></div>
</div></div>