explicit-exception 0.1.8 → 0.1.9
raw patch · 2 files changed
+26/−14 lines, 2 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
- Control.Monad.Exception.Asynchronous.Lazy: instance (GHC.Show.Show e, GHC.Show.Show a) => GHC.Show.Show (Control.Monad.Exception.Asynchronous.Lazy.Exceptional e a)
- Control.Monad.Exception.Asynchronous.Strict: instance (GHC.Show.Show e, GHC.Show.Show a) => GHC.Show.Show (Control.Monad.Exception.Asynchronous.Strict.Exceptional e a)
+ Control.Monad.Exception.Asynchronous.Lazy: infixl 1 `bindT`
+ Control.Monad.Exception.Asynchronous.Lazy: infixr 1 `continueM`
+ Control.Monad.Exception.Asynchronous.Lazy: instance (GHC.Show.Show a, GHC.Show.Show e) => GHC.Show.Show (Control.Monad.Exception.Asynchronous.Lazy.Exceptional e a)
+ Control.Monad.Exception.Asynchronous.Strict: infixl 1 `bindT`
+ Control.Monad.Exception.Asynchronous.Strict: infixr 1 `continueM`
+ Control.Monad.Exception.Asynchronous.Strict: instance (GHC.Show.Show a, GHC.Show.Show e) => GHC.Show.Show (Control.Monad.Exception.Asynchronous.Strict.Exceptional e a)
+ Control.Monad.Exception.Synchronous: alternative :: Exceptional e a -> Exceptional e a -> Exceptional e a
+ Control.Monad.Exception.Synchronous: alternativeT :: (Monad m) => ExceptionalT e m a -> ExceptionalT e m a -> ExceptionalT e m a
+ Control.Monad.Exception.Synchronous: infixl 3 `alternativeT`
+ Control.Monad.Exception.Synchronous: infixl 4 `mergeT`
+ Control.Monad.Exception.Synchronous: liftT :: (Monad m) => Exceptional e a -> ExceptionalT e m a
Files
explicit-exception.cabal view
@@ -1,5 +1,5 @@ Name: explicit-exception-Version: 0.1.8+Version: 0.1.9 License: BSD3 License-File: LICENSE Author: Henning Thielemann <haskell@henning-thielemann.de>@@ -28,13 +28,7 @@ I have tried to adopt it for this library, in order to let Haskell programmers get accustomed easily to it. .- To do:- Because many people requested it,- we will provide a @bracket@ function that frees a resource- both when an exception and an error occurs,- that is, it combines exception handling and debugging.- However note that freeing resources in case of an error is dangerous- and may cause further damage.+ See also: @unexceptionalio@ Tested-With: GHC==6.8.2 Tested-With: GHC==7.4.2, GHC==7.6.1, GHC==7.8.2 Tested-With: GHC==8.0.1@@ -48,7 +42,7 @@ Source-Repository this type: darcs location: http://code.haskell.org/explicit-exception/- tag: 0.1.8+ tag: 0.1.9 Flag buildTests description: Build executables that demonstrate some space leaks
src/Control/Monad/Exception/Synchronous.hs view
@@ -42,12 +42,14 @@ catch, resolve, merge,+ alternative, ExceptionalT(..), fromMaybeT, toMaybeT, fromErrorT, toErrorT, fromEitherT, toEitherT, fromExitCodeT, toExitCodeT,+ liftT, switchT, forceT, mapExceptionT,@@ -61,6 +63,7 @@ manyT, manyMonoidT, mergeT,+ alternativeT, ) where import Control.Applicative (Applicative(pure, (<*>)))@@ -197,8 +200,16 @@ Success a -> a Exception e -> handler e +-- like Applicative.<|>+infixl 3 `alternative`, `alternativeT` +alternative, _alternative ::+ Exceptional e a -> Exceptional e a -> Exceptional e a+alternative x y = catch x (const y)+_alternative x y = switch (const y) Success x ++ -- like Applicative.<*> infixl 4 `merge`, `mergeT` @@ -317,6 +328,10 @@ ExceptionalT $ fmap fromExitCode act +liftT :: (Monad m) => Exceptional e a -> ExceptionalT e m a+liftT = ExceptionalT . return++ switchT :: (Monad m) => (e -> m b) -> (a -> m b) ->@@ -358,11 +373,7 @@ (e0 -> ExceptionalT e1 m a) -> ExceptionalT e1 m a catchT action handler =- ExceptionalT $- runExceptionalT action >>= \x ->- case x of- Success a -> return $ Success a- Exception e -> runExceptionalT $ handler e+ ExceptionalT $ switchT (runExceptionalT . handler) (return . Success) action {- | If the enclosed monad has custom exception facilities,@@ -444,6 +455,13 @@ mergeT mf ma = ExceptionalT $ liftM2 merge (runExceptionalT mf) (runExceptionalT ma)++alternativeT, _alternativeT ::+ (Monad m) =>+ ExceptionalT e m a -> ExceptionalT e m a -> ExceptionalT e m a+alternativeT x y = catchT x (const y)+_alternativeT x y =+ ExceptionalT $ switchT (const $ runExceptionalT y) (return . Success) x instance Functor m => Functor (ExceptionalT e m) where