Replaced throw to throwIO where type is IO

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


On Sat, Sep 25, 2010 at 2:21 AM, Antoine Latter <aslatter at gmail.com> 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:

http://haskell.org/ghc/docs/6.12.1/html/libraries/base-4.2.0.0/Control-Exception.html#v:throwIO

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

catchJust
        :: 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.

Regards,

Bas


More information about the Libraries mailing list