Replaced throw to throwIO where type is IO

Bas van Dijk v.dijk.bas at
Sat Sep 25 05:08:45 EDT 2010

On Sat, Sep 25, 2010 at 2:21 AM, Antoine Latter <aslatter at> wrote:
> Why is this patch a good thing?

Maybe it isn't.

However the documentation of throwIO states that it should be used in
preference of throw because it guarantees ordering with respect to
other IO actions:

Now the question is does it matter whether we use throw or throwIO in
(for example):

        :: Exception e
        => (e -> Maybe b)         -- ^ Predicate to select exceptions
        -> IO a                   -- ^ Computation to run
        -> (b -> IO a)            -- ^ Handler
        -> IO a
catchJust p a handler = catch a handler'
  where handler' e = case p e of
                        Nothing -> throwIO e
                        Just b  -> handler b

Maybe I'm missing something obvious. In that case, sorry for the noise.



More information about the Libraries mailing list