[Haskell] generic catch in a MonadIO

Andrew Pimlott andrew at pimlott.net
Wed Feb 8 17:05:44 EST 2006

On Wed, Feb 08, 2006 at 12:59:48AM -0500, David Menendez wrote:
> Since the monad transformers in MTL all promote MonadError, you can also
> use throwError and catchError with instances of MonadIO. Currently, the
> error type associated with IO is IOError, not Exception, but it should
> be possible to work around that with a wrapper:

That's still not the same, because the point of Oleg's code seems to be
to catch Exceptions within any CaughtMonadIO.  With your approach, if
there is any ErrorT transformer involved, catchError will catch the
error from the outermost ErrorT, and general Exceptions will escape.
See for example Oleg's test2.


More information about the Haskell mailing list