packages feed

MonadCatchIO-transformers 0.1.0.1 → 0.2.0.0

raw patch · 2 files changed

+20/−21 lines, 2 filesdep ~basedep ~transformersPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: base, transformers

API changes (from Hackage documentation)

- Control.Monad.CatchIO: try :: (MonadCatchIO m, Exception e) => m a -> m (Either e a)
+ Control.Monad.CatchIO: try :: (MonadCatchIO m, Functor m, Exception e) => m a -> m (Either e a)
- Control.Monad.CatchIO: tryJust :: (MonadCatchIO m, Exception e) => (e -> Maybe b) -> m a -> m (Either b a)
+ Control.Monad.CatchIO: tryJust :: (MonadCatchIO m, Functor m, Exception e) => (e -> Maybe b) -> m a -> m (Either b a)

Files

MonadCatchIO-transformers.cabal view
@@ -1,5 +1,5 @@ Name:            MonadCatchIO-transformers-Version:         0.1.0.1+Version:         0.2.0.0 Cabal-Version:   >= 1.6 License:         PublicDomain Description:@@ -17,7 +17,7 @@   Build-Depends:     base == 4.*,     extensible-exceptions == 0.1.*,-    transformers == 0.1.*+    transformers == 0.2.*   Exposed-Modules:     Control.Monad.CatchIO   Hs-Source-Dirs:  src
src/Control/Monad/CatchIO.hs view
@@ -15,17 +15,18 @@  where -import Prelude hiding ( catch )+import           Prelude hiding ( catch ) +import           Control.Applicative        ((<$>)) import qualified Control.Exception.Extensible as E -import Control.Monad.Trans        (MonadIO,liftIO)-import Control.Monad.Trans.Error  (ErrorT          ,runErrorT ,mapErrorT ,Error)-import Control.Monad.Trans.Reader (ReaderT(ReaderT),runReaderT,mapReaderT)-import Control.Monad.Trans.State  (StateT(StateT)  ,runStateT ,mapStateT )-import Control.Monad.Trans.Writer (WriterT(WriterT),runWriterT,mapWriterT)-import Control.Monad.Trans.RWS    (RWST(RWST)      ,runRWST   ,mapRWST   )-import Data.Monoid                (Monoid)+import           Control.Monad.IO.Class     (MonadIO,liftIO)  +import           Control.Monad.Trans.Error  (ErrorT          ,runErrorT ,mapErrorT ,Error)+import           Control.Monad.Trans.Reader (ReaderT(ReaderT),runReaderT,mapReaderT)+import           Control.Monad.Trans.State  (StateT(StateT)  ,runStateT ,mapStateT )+import           Control.Monad.Trans.Writer (WriterT(WriterT),runWriterT,mapWriterT)+import           Control.Monad.Trans.RWS    (RWST(RWST)      ,runRWST   ,mapRWST   )+import           Data.Monoid                (Monoid)   class MonadIO m => MonadCatchIO m where@@ -45,22 +46,22 @@   unblock = E.unblock  instance MonadCatchIO m => MonadCatchIO (ReaderT r m) where-  m `catch` f = ReaderT $ \r -> (runReaderT m r) `catch` (\e -> runReaderT (f e) r)+  m `catch` f = ReaderT $ \r -> runReaderT m r `catch` \e -> runReaderT (f e) r   block       = mapReaderT block   unblock     = mapReaderT unblock  instance MonadCatchIO m => MonadCatchIO (StateT s m) where-  m `catch` f = StateT $ \s -> (runStateT m s) `catch` (\e -> runStateT (f e) s)+  m `catch` f = StateT $ \s -> runStateT m s `catch` \e -> runStateT (f e) s   block       = mapStateT block   unblock     = mapStateT unblock  instance (MonadCatchIO m, Error e) => MonadCatchIO (ErrorT e m) where-  m `catch` f = mapErrorT (\m' -> m' `catch` (\e -> runErrorT $ f e)) m+  m `catch` f = mapErrorT (\m' -> m' `catch` \e -> runErrorT $ f e) m   block       = mapErrorT block   unblock     = mapErrorT unblock  instance (Monoid w, MonadCatchIO m) => MonadCatchIO (WriterT w m) where-  m `catch` f = WriterT $ runWriterT m `catch` \e -> runWriterT (f e)+  m `catch` f = WriterT $ runWriterT m `catch` \e -> runWriterT $ f e   block       = mapWriterT block   unblock     = mapWriterT unblock @@ -75,18 +76,18 @@ throw = liftIO . E.throwIO  -- | Generalized version of 'E.try'-try :: (MonadCatchIO m, E.Exception e) => m a -> m (Either e a)-try a = catch (a >>= \ v -> return (Right v)) (\e -> return (Left e))+try :: (MonadCatchIO m, Functor m, E.Exception e) => m a -> m (Either e a)+try a = catch (Right <$> a) (return . Left)  -- | Generalized version of 'E.tryJust'-tryJust :: (MonadCatchIO m, E.Exception e)+tryJust :: (MonadCatchIO m, Functor m, E.Exception e)         => (e -> Maybe b) -> m a -> m (Either b a) tryJust p a = do   r <- try a   case r of     Right v -> return (Right v)     Left  e -> case p e of-      Nothing -> throw e `asTypeOf` (return $ Left undefined)+      Nothing -> throw e `asTypeOf` return (Left undefined)       Just b  -> return (Left b)  -- | Generalized version of 'E.Handler'@@ -96,9 +97,7 @@ catches :: MonadCatchIO m => m a -> [Handler m a] -> m a catches a handlers = a `catch` handler where   handler e = foldr tryH (throw e) handlers where-    tryH (Handler h) res = case E.fromException e of-      Just e' -> h e'-      Nothing -> res+    tryH (Handler h) res = maybe res h $ E.fromException e  -- | Generalized version of 'E.bracket' bracket :: MonadCatchIO m => m a -> (a -> m b) -> (a -> m c) -> m c