control-monad-exception-mtl 0.8.0.3 → 0.8.0.4
raw patch · 3 files changed
+76/−73 lines, 3 filesdep ~control-monad-exceptionPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: control-monad-exception
API changes (from Hackage documentation)
Files
- control-monad-exception-mtl.cabal +7/−4
- extensions/Control/Monad/Exception/MTL.hs +69/−0
- src-mtl/Control/Monad/Exception/MTL.hs +0/−69
control-monad-exception-mtl.cabal view
@@ -1,22 +1,25 @@ name: control-monad-exception-mtl-version: 0.8.0.3+version: 0.8.0.4 Cabal-Version: >= 1.6 build-type: Simple license: PublicDomain author: Pepe Iborra maintainer: pepeiborra@gmail.com homepage: http://pepeiborra.github.com/control-monad-exception-description: MTL instances for the EMT exceptions monad transformer synopsis: MTL instances for the EMT exceptions monad transformer category: Control, Monads, Failure stability: experimental tested-with: GHC == 6.12.1 bug-reports: http://github.com/pepeiborra/control-monad-exception/issues+description: + MTL instances for the EMT exceptions monad transformer+ .+ /This package is only applicable for the now-deprecated mtl v1. Since mtl v2 is compatible with the transformers package, users of mtl2 should simply use the control-monad-exception package. Library buildable: True build-depends: base > 4 && < 5- , control-monad-exception >= 0.8.0+ , control-monad-exception >= 0.8.0 && <= 0.9.0 , mtl @@ -30,7 +33,7 @@ exposed-modules: Control.Monad.Exception.MTL - hs-source-dirs: src-mtl+ hs-source-dirs: extensions ghc-options: -Wall -fno-warn-name-shadowing -fno-warn-orphans
+ extensions/Control/Monad/Exception/MTL.hs view
@@ -0,0 +1,69 @@+{-# LANGUAGE ScopedTypeVariables #-}+{-# LANGUAGE TypeSynonymInstances #-}+{-# LANGUAGE PackageImports #-}+{-# LANGUAGE UndecidableInstances #-}++-- | 'EMT' liftings for the classes in the Monad Transformer Library+module Control.Monad.Exception.MTL (module Control.Monad.Exception, Control.Monad.Exception.catch) where++import qualified Control.Exception as CE++import qualified Control.Monad.Exception+import Control.Monad.Exception hiding (catch, Error)+import Control.Monad.Exception.Catch as Catch+import "mtl" Control.Monad.Cont.Class+import "mtl" Control.Monad.Error+import "mtl" Control.Monad.List+import "mtl" Control.Monad.Reader+import "mtl" Control.Monad.State+import "mtl" Control.Monad.Writer+import "mtl" Control.Monad.RWS+import Prelude hiding (catch)++instance MonadTrans (EMT l) where lift = EMT . liftM Right++instance (Throws SomeException l, MonadIO m) => MonadIO (EMT l m) where+ liftIO m = EMT (liftIO m') where+ m' = liftM Right m+ `CE.catch`+ \(e::SomeException) -> return (Left ([], CheckedException e))++instance MonadCont m => MonadCont (EMT l m) where+ callCC f = EMT $ callCC $ \c -> unEMT (f (\a -> EMT $ c (Right a)))++instance MonadReader r m => MonadReader r (EMT l m) where+ ask = lift ask+ local f m = EMT (local f (unEMT m))++instance MonadState s m => MonadState s (EMT l m) where+ get = lift get+ put = lift . put++instance (Monoid w, MonadWriter w m) => MonadWriter w (EMT l m) where+ tell = lift . tell+ listen m = EMT $ do+ (res, w) <- listen (unEMT m)+ return (fmap (\x -> (x,w)) res)+ pass m = EMT $ pass $ do+ a <- unEMT m+ case a of+ Left l -> return (Left l, id)+ Right (r,f) -> return (Right r, f)++instance (Monoid w, MonadRWS r w s m) => MonadRWS r w s (EMT l m)++++-- MonadCatch Instances+-- -------------------------------------------------------------------------+instance (Error e) => MonadCatch e (Either e) (Either e) where catch m h = either h Right m+instance (Error e, Monad m) => MonadCatch e (ErrorT e m) (ErrorT e m) where catch = catchError++instance MonadCatch e m m' => MonadCatch e (ListT m) (ListT m') where catch (ListT m) h = ListT (Catch.catch m (runListT . h))+instance MonadCatch e m m' => MonadCatch e (ReaderT r m) (ReaderT r m') where catch (ReaderT m) h = ReaderT (\s -> Catch.catch (m s) ((`runReaderT` s) . h))++instance (Monoid w, MonadCatch e m m') => MonadCatch e (WriterT w m) (WriterT w m') where catch (WriterT m) h = WriterT (Catch.catch m (runWriterT . h))++instance MonadCatch e m m' => MonadCatch e (StateT s m) (StateT s m') where catch (StateT m) h = StateT (\s -> Catch.catch (m s) ((`runStateT` s) . h))++instance (Monoid w, MonadCatch e m m') => MonadCatch e (RWST r w s m) (RWST r w s m') where catch (RWST m) h = RWST (\r s -> Catch.catch (m r s) ((\m -> runRWST m r s) . h))
− src-mtl/Control/Monad/Exception/MTL.hs
@@ -1,69 +0,0 @@-{-# LANGUAGE ScopedTypeVariables #-}-{-# LANGUAGE TypeSynonymInstances #-}-{-# LANGUAGE PackageImports #-}-{-# LANGUAGE UndecidableInstances #-}---- | 'EMT' liftings for the classes in the Monad Transformer Library-module Control.Monad.Exception.MTL (module Control.Monad.Exception, Control.Monad.Exception.catch) where--import qualified Control.Exception as CE--import qualified Control.Monad.Exception-import Control.Monad.Exception hiding (catch, Error)-import Control.Monad.Exception.Catch as Catch-import "mtl" Control.Monad.Cont.Class-import "mtl" Control.Monad.Error-import "mtl" Control.Monad.List-import "mtl" Control.Monad.Reader-import "mtl" Control.Monad.State-import "mtl" Control.Monad.Writer-import "mtl" Control.Monad.RWS-import Prelude hiding (catch)--instance MonadTrans (EMT l) where lift = EMT . liftM Right--instance (Throws SomeException l, MonadIO m) => MonadIO (EMT l m) where- liftIO m = EMT (liftIO m') where- m' = liftM Right m- `CE.catch`- \(e::SomeException) -> return (Left ([], CheckedException e))--instance MonadCont m => MonadCont (EMT l m) where- callCC f = EMT $ callCC $ \c -> unEMT (f (\a -> EMT $ c (Right a)))--instance MonadReader r m => MonadReader r (EMT l m) where- ask = lift ask- local f m = EMT (local f (unEMT m))--instance MonadState s m => MonadState s (EMT l m) where- get = lift get- put = lift . put--instance (Monoid w, MonadWriter w m) => MonadWriter w (EMT l m) where- tell = lift . tell- listen m = EMT $ do- (res, w) <- listen (unEMT m)- return (fmap (\x -> (x,w)) res)- pass m = EMT $ pass $ do- a <- unEMT m- case a of- Left l -> return (Left l, id)- Right (r,f) -> return (Right r, f)--instance (Monoid w, MonadRWS r w s m) => MonadRWS r w s (EMT l m)------ MonadCatch Instances--- --------------------------------------------------------------------------instance (Error e) => MonadCatch e (Either e) (Either e) where catch m h = either h Right m-instance (Error e, Monad m) => MonadCatch e (ErrorT e m) (ErrorT e m) where catch = catchError--instance MonadCatch e m m' => MonadCatch e (ListT m) (ListT m') where catch (ListT m) h = ListT (Catch.catch m (runListT . h))-instance MonadCatch e m m' => MonadCatch e (ReaderT r m) (ReaderT r m') where catch (ReaderT m) h = ReaderT (\s -> Catch.catch (m s) ((`runReaderT` s) . h))--instance (Monoid w, MonadCatch e m m') => MonadCatch e (WriterT w m) (WriterT w m') where catch (WriterT m) h = WriterT (Catch.catch m (runWriterT . h))--instance MonadCatch e m m' => MonadCatch e (StateT s m) (StateT s m') where catch (StateT m) h = StateT (\s -> Catch.catch (m s) ((`runStateT` s) . h))--instance (Monoid w, MonadCatch e m m') => MonadCatch e (RWST r w s m) (RWST r w s m') where catch (RWST m) h = RWST (\r s -> Catch.catch (m r s) ((\m -> runRWST m r s) . h))