[Haskell] Re: generic catch in a MonadIO

Ashley Yakeley ashley at semantic.org
Wed Feb 8 14:56:17 EST 2006


Taral wrote:
> On 2/8/06, Ashley Yakeley <ashley at semantic.org> wrote:
> 
>>IIRC, that subset is types that can implement this:
>>
>>   class (MonadIO m) => StrictMonadIO m where
>>       getUnliftIO :: m (m a -> IO a)
> 
> 
> You probably mean "m (forall a. m a -> IO a)" and that is not allowed.

Actually, I think what I have is sufficient:

   -- liftIO :: (MonadIO m) => IO a -> m a
   -- catch :: IO a -> (Exception -> IO a) -> IO a

   gcatch :: (StrictMonadIO m) => m a -> (Exception -> m a) -> m a
   gcatch ma cc = do
       unliftIO <- getUnliftIO
       liftIO (catch (unliftIO ma) (\ex -> unliftIO (cc ex)))



More information about the Haskell mailing list