packages feed

control-monad-exception 0.8.0.2 → 0.8.0.3

raw patch · 5 files changed

+28/−37 lines, 5 filesdep −prettyPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

Dependencies removed: pretty

API changes (from Hackage documentation)

- Control.Monad.Exception: type AnyException = Caught SomeException
- Control.Monad.Exception.Base: type AnyException = Caught SomeException
+ Control.Monad.Exception: data AnyException
+ Control.Monad.Exception.Base: data AnyException
+ Control.Monad.Exception.Base: instance (Exception e) => Throws e AnyException
+ Control.Monad.Exception.Base: tryEMTWithLoc :: (Monad m) => EMT AnyException m a -> m (Either (CallTrace, SomeException) a)
+ Control.Monad.Exception.Base: tryEMWithLoc :: EM AnyException a -> Either (CallTrace, SomeException) a
- Control.Monad.Exception: tryEM :: EM (AnyException l) a -> Either SomeException a
+ Control.Monad.Exception: tryEM :: EM AnyException a -> Either SomeException a
- Control.Monad.Exception: tryEMT :: (Monad m) => EMT (AnyException l) m a -> m (Either SomeException a)
+ Control.Monad.Exception: tryEMT :: (Monad m) => EMT AnyException m a -> m (Either SomeException a)
- Control.Monad.Exception.Base: tryEM :: EM (AnyException l) a -> Either SomeException a
+ Control.Monad.Exception.Base: tryEM :: EM AnyException a -> Either SomeException a
- Control.Monad.Exception.Base: tryEMT :: (Monad m) => EMT (AnyException l) m a -> m (Either SomeException a)
+ Control.Monad.Exception.Base: tryEMT :: (Monad m) => EMT AnyException m a -> m (Either SomeException a)

Files

Control/Monad/Exception.hs view
@@ -1,7 +1,10 @@  {-|-A Monad Transformer for explicitly typed checked exceptions.+A Monad Transformer for explicitly typed checked exceptions, described in detail by: +  * Jose Iborra, \"Explicitly Typed Exceptions for Haskell",+    PADL'10, January 2010, <http://safe-tools.dsic.upv.es/mediawiki/index.php/Jose_Iborra/Papers/Exceptions>+ The exceptions thrown by a computation are inferred by the typechecker and appear in the type signature of the computation as 'Throws' constraints. @@ -84,15 +87,8 @@  {- $hierarchies  If your sets of exceptions are hierarchical then you need to-   teach 'Throws' about the hierarchy.-->                                                            --   TopException->                                                            --         |->   instance Throws MidException   (Caught TopException l)   --         |->                                                            --   MidException->   instance Throws ChildException (Caught MidException l)   --         |->   instance Throws ChildException (Caught TopException l)   --         |->                                                            --  ChildException+   teach 'Throws' about the hierarchy. See the documentation of+   'Throws' for more info. -} {- $unchecked An exception @E@ can be declared as unchecked by making @E@ an instance of
Control/Monad/Exception/Base.hs view
@@ -50,7 +50,6 @@ import Control.Failure import Control.Monad.Fix import Data.Typeable-import Text.PrettyPrint import Prelude hiding (catch)  type CallTrace = [String]@@ -58,21 +57,25 @@ -- | A Monad Transformer for explicitly typed checked exceptions. newtype EMT l m a = EMT {unEMT :: m (Either (CallTrace, CheckedException l) a)} -type AnyException = Caught SomeException- -- | Run a computation explicitly handling exceptions-tryEMT :: Monad m => EMT (AnyException l) m a -> m (Either SomeException a)+tryEMT :: Monad m => EMT AnyException m a -> m (Either SomeException a) tryEMT (EMT m) = mapLeft (checkedException.snd) `liftM` m +tryEMTWithLoc :: Monad m => EMT AnyException m a -> m (Either (CallTrace, SomeException) a)+tryEMTWithLoc = liftM (mapLeft (\(l,ce) -> (l, checkedException ce))) . unEMT+ runEMT_gen :: forall l m a . Monad m => EMT l m a -> m a runEMT_gen (EMT m) = m >>= \x ->                      case x of                        Right x -> return x                        Left (loc,e) -> error (showExceptionWithTrace loc (checkedException e)) +data AnyException data NoExceptions data ParanoidMode +instance Exception e => Throws e AnyException+ -- | Run a safe computation runEMT :: Monad m => EMT NoExceptions m a -> m a runEMT = runEMT_gen@@ -184,13 +187,10 @@  showExceptionWithTrace :: Exception e => [String] -> e -> String showExceptionWithTrace [] e = show e-showExceptionWithTrace trace e = render$-             text (show e) $$-             text " in" <+> (vcat (map text $ reverse trace))-{---}+showExceptionWithTrace trace e = concat ( show e+                                        : [ " in " ++ show loc | loc <- reverse trace]) --- | Uncaught Exceptions model unchecked exceptions+-- | UncaughtException models unchecked exceptions -- --   In order to declare an unchecked exception @E@, --   all that is needed is to make @e@ an instance of 'UncaughtException'@@ -198,12 +198,7 @@ --  > instance UncaughtException E -- --   Note that declaring an exception E as unchecked does not automatically---   turn its children as unchecked too. This is a shortcoming of the current encoding.------   If that is what you want, then declare E as unchecked and unexplicit---    using an instance of 'Throws':------  > instance Throws E l+--   turn its children unchecked too. This is a shortcoming of the current encoding.  class Exception e => UncaughtException e instance UncaughtException e => Throws e NoExceptions@@ -217,8 +212,11 @@ type EM l = EMT l Identity  -- | Run a computation explicitly handling exceptions-tryEM :: EM (AnyException l) a -> Either SomeException a+tryEM :: EM AnyException a -> Either SomeException a tryEM = runIdentity . tryEMT++tryEMWithLoc :: EM AnyException a -> Either (CallTrace, SomeException) a+tryEMWithLoc = runIdentity . tryEMTWithLoc  -- | Run a safe computation runEM :: EM NoExceptions a -> a
Control/Monad/Exception/Catch.hs view
@@ -39,6 +39,3 @@  instance Exception e => MonadCatch e IO IO where    catch   = Control.Exception.catch---- Throw and Catch instances for the Either and ErrorT monads--- -----------------------------------------------------------
Control/Monad/Exception/Throws.hs view
@@ -25,8 +25,9 @@     used to model a list of exceptions.      There is only one case in which the user must-    add further instances to @Throws@, and that is-    to encode the hierarchy of exceptions.+    add further instances to @Throws@.+    If your sets of exceptions are hierarchical then you need to+   teach 'Throws' about the hierarchy.      [/Subtyping/]      As there is no way to automatically infer@@ -50,8 +51,7 @@ >   instance Throws ChildException (Caught TopException l)   --         | >                                                            --  ChildException -     'SomeException' is automatically-      an ancestor of every other exception type.+     Note that 'SomeException' is automatically an ancestor of every other exception type.  -} 
control-monad-exception.cabal view
@@ -1,5 +1,5 @@ name: control-monad-exception-version: 0.8.0.2+version: 0.8.0.3 Cabal-Version:  >= 1.6 build-type: Simple license: PublicDomain@@ -65,7 +65,8 @@ synopsis: Explicitly typed, checked exceptions with stack traces category: Control, Monads, Failure stability: experimental-tested-with: GHC ==6.10.3+tested-with: GHC == 6.12.1+bug-reports: http://github.com/pepeiborra/control-monad-exception/issues  Flag extensibleExceptions   description: Use extensible-exception package@@ -75,7 +76,6 @@   buildable: True    build-depends: failure                , monadloc-               , pretty    if flag(extensibleExceptions)     build-depends: