[Haskell-cafe] converting IOException to Either in ErrorT

2009-05-03 Thread brian
I wrote this to make it a little nicer to catch IO exceptions and convert them to ErrorT failure: onExceptionThrowError :: (Error ce) => IO a -> (String -> ce) -> ErrorT ce IO a onExceptionThrowError a ce = liftIO (try a) >>= either (\(e :: IOException) -> throwError (

Re: [Haskell-cafe] converting IOException to Either in ErrorT

2009-05-03 Thread David Menendez
On Sun, May 3, 2009 at 6:36 PM, wrote: > I wrote this to make it a little nicer to catch IO exceptions and > convert them to ErrorT failure: > > onExceptionThrowError >  :: (Error ce) => >     IO a >  -> (String -> ce) >  -> ErrorT ce IO a > onExceptionThrowError a ce = >    liftIO (try a) >>= >