MonadIO needs catch?

John Meacham john@repetae.net
Mon, 27 Jan 2003 22:35:01 -0800


while genericizing my utility libraries to work within any MonadIO
(http://haskell.cs.yale.edu/ghc/docs/latest/html/base/Control.Monad.Trans.html)
I ran into a problem, 'liftIO' is not powerful enough to catch
exceptions in a MonadIO. 
the closest one can get is 

> genCatch :: MonadIO m => IO a -> (Exception -> IO a) -> m a
when we want..
> genCatch :: MonadIO m => m a -> (Exception -> m a) -> m a

The only way i can think of to solve this is add 'catch' (perhaps
'catchIO'? 'genCatch'?) to the MonadIO class. 

some open questions are whether it is possible to implement catch for
any MonadIO? I would think so, since you need only store the 'internal
state' of your monad at the genCatch and continue with that if an
exception was raised. (this might mix badly with other extensions
though?) at worst a MonadIOCatchable deriving from MonadIO could be
added... 

	John


-- 
---------------------------------------------------------------------------
John Meacham - California Institute of Technology, Alum. - john@foo.net
---------------------------------------------------------------------------