[darcs-devel] [patch602] Fix a couple of GHC 7 deprecation warnings.

Gabriel Kerneis kerneis at pps.jussieu.fr
Wed Apr 27 07:36:57 UTC 2011


On Wed, Apr 27, 2011 at 01:25:14AM +0000, Petr Ročkai wrote:
> Not screening. This one is tricky, because I don't really understand the
> semantics of either the old or the new functions very well,

Well, mask is defined in terms of block anyway, it's just a restriction
to make sure the programmer does screw things up with unbalanced
block/unblock (in the case of libraries in particular):

-- from IO.hs
mask io = do
  b <- getMaskingState
  case b of
    Unmasked -> block $ io unblock
    _        -> io id

>  and I also don't know whether mask is supported by all the
>  build-depends versions we need to support.

No idea, sorry.


> hunk ./src/Darcs/Global.hs 66
> -    exit = block $ do
> +    exit = mask $ \unmask -> do
>          Just actions <- swapMVar atexitActions Nothing
>          -- from now on atexit will not register new actions
> hunk ./src/Darcs/Global.hs 69
> -        mapM_ runAction actions
> -    runAction action = do
> -        catch (unblock action) $ \(exn :: SomeException) -> do
> +        mapM_ (runAction unmask) actions
> +    runAction unmask action = do
> +        catch (unmask action) $ \(exn :: SomeException) -> do

This one looks good to me.  It changes the semantics, of course, but the
new semantics is supposed to be safer and in that case I cannot see how
it would hurt the computation in any way (it only about error reporting
after all, which could be caught at a higher level now but for good
reasons).

>  
> hunk ./src/Darcs/IO.hs 18
>  withSignalsBlocked :: IO a -> IO a
> -withSignalsBlocked job = block (job >>= \r ->
> -                           unblock(return r) `catchSignal` couldnt_do r)
> +withSignalsBlocked job = mask $ \unmask -> (job >>= \r ->
> +                                           unmask (return r) `catchSignal` couldnt_do r)

I am sure that this one is correct.  I remember I rewrote the code that
way to allow such easy block/mask substitution.

I think you can screen this patch.

Best,
-- 
Gabriel


More information about the darcs-devel mailing list