Proposal: add handleError to mtl
Erik de Castro Lopo
mle+hs at mega-nerd.com
Wed Jun 5 05:04:38 CEST 2013
Hi all,
I would like to propose the following convenience function (with
implementation) for the mtl library:
handleError :: MonadError e m => (e -> m a) -> m a -> m a
handleError = flip catchError
which follows the handle function from Control.Exception.Base:
handle :: Exception e => (e -> IO a) -> IO a -> IO a
Like the handle function, handleError allows the handling of
exceptions to be expressed in a more natural way, turning:
catchError
( do
mumble
something
mumble
)
handler
into:
handlerError handler $ do
mumble
something
mumble
--
----------------------------------------------------------------------
Erik de Castro Lopo
http://www.mega-nerd.com/
More information about the Libraries
mailing list