packages feed

explicit-exception 0.1.0.1 → 0.1.1

raw patch · 3 files changed

+104/−7 lines, 3 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Control.Monad.Exception.Asynchronous: appendM :: (Monad m, Monoid a) => m (Exceptional e a) -> m (Exceptional e a) -> m (Exceptional e a)
+ Control.Monad.Exception.Asynchronous: continueM :: (Monad m, Monoid a) => m (Maybe e) -> m (Exceptional e a) -> m (Exceptional e a)
+ Control.Monad.Exception.Asynchronous: instance (Monoid a) => Monoid (Exceptional e a)
+ Control.Monad.Exception.Asynchronous: sequenceF :: (Functor f) => Exceptional e (f a) -> f (Exceptional e a)

Files

explicit-exception.cabal view
@@ -1,5 +1,5 @@ Name:             explicit-exception-Version:          0.1.0.1+Version:          0.1.1 License:          BSD3 License-File:     LICENSE Author:           Henning Thielemann <haskell@henning-thielemann.de>@@ -46,7 +46,7 @@ Source-Repository this   type:     darcs   location: http://code.haskell.org/explicit-exception/-  tag:      0.1.0.1+  tag:      0.1.1  Library   Build-Depends: base >= 2, transformers >=0.0 && <0.2
src/Control/Monad/Exception/Asynchronous.hs view
@@ -7,8 +7,39 @@  * Check whether laziness behaviour is reasonable. -}-module Control.Monad.Exception.Asynchronous where+module Control.Monad.Exception.Asynchronous (+   Exceptional(..),+   pure,+   broken,+   fromSynchronous,+   fromSynchronousNull,+   fromSynchronousMonoid,+   toSynchronous,+   throw,+   throwMonoid,+   manySynchronousT,+   processToSynchronousT_,+   zipWith,+   append,+   continue,+   maybeAbort,+   force,+   mapException,+   mapExceptional,+   simultaneousBind,+   simultaneousBindM,+   sequenceF,+   traverse,+   sequenceA,+   mapM,+   sequence,+   swapToSynchronousAsynchronous,+   swapToAsynchronousSynchronous, +   appendM,+   continueM,+   ) where+ import qualified Control.Monad.Exception.Synchronous as Sync  import Control.Monad (mplus, liftM, )@@ -19,7 +50,7 @@ -} import Data.Monoid(Monoid, mappend, mempty, ) -import Prelude hiding (sequence)+import Prelude hiding (zipWith, sequence, mapM, )   -- * Plain monad@@ -194,6 +225,11 @@    Exceptional (mplus ea eb) a  +instance Monoid a => Monoid (Exceptional e a) where+   mempty = pure mempty+   mappend = append++ {- | construct Exceptional constructor lazily -} force :: Exceptional e a -> Exceptional e a force ~(Exceptional e a) = Exceptional e a@@ -235,6 +271,12 @@       return (Exceptional (mplus meb mea) b)  +-- | Is there a better name?+{-# INLINE sequenceF #-}+sequenceF :: Functor f => Exceptional e (f a) -> f (Exceptional e a)+sequenceF ~(Exceptional e a) =+   fmap (Exceptional e) a+ -- instance Foldable (Exceptional e) where  -- instance Traversable (Exceptional e) where@@ -298,6 +340,8 @@ Surprisingly, both orders of nesting these two kinds of exceptional actions are equally expressive. This function converts to the form where the synchronous exception is the outer one.++This is a specialisation of 'sequence' and friends. -} swapToSynchronousAsynchronous :: Exceptional e0 (Sync.Exceptional e1 a) -> Sync.Exceptional e1 (Exceptional e0 a) swapToSynchronousAsynchronous ~(Exceptional e0 x) =@@ -305,13 +349,13 @@  swapToAsynchronousSynchronous :: Sync.Exceptional e1 (Exceptional e0 a) -> Exceptional e0 (Sync.Exceptional e1 a) swapToAsynchronousSynchronous x =+--   Traversable.sequenceA x    force $    case x of-      Sync.Exception e1 -> pure $ Sync.throw e1+      Sync.Exception e1 -> pure $ Sync.Exception e1       Sync.Success s -> fmap Sync.Success s  - {- -- * Monad transformer @@ -349,3 +393,32 @@          Exceptional ey y <- runExceptionalT (f x)          return $ Exceptional (ex ++ ey) y -}++infixr 1 {- `bindM`, -} `appendM`, `continueM`++{-+bindM :: (Monad m, Monoid b) => SynchronousExceptional m a -> (a -> AsynchronousExceptional m b) -> AsynchronousExceptional m b+bindM x y =+   Sync.tryT x >>= \result ->+      liftM Async.force+      (case result of+         Sync.Exception e -> return $ Async.throwMonoid e+         Sync.Success s -> y s)+-}++appendM :: (Monad m, Monoid a) =>+   m (Exceptional e a) -> m (Exceptional e a) -> m (Exceptional e a)+appendM x y =+   do r <- x+      liftM (fmap (mappend (result r))) $+         continueMPlain (exception r) y++continueM :: (Monad m, Monoid a) =>+   m (Maybe e) -> m (Exceptional e a) -> m (Exceptional e a)+continueM mx y =+   mx >>= \x -> continueMPlain x y++continueMPlain :: (Monad m, Monoid a) =>+   Maybe e -> m (Exceptional e a) -> m (Exceptional e a)+continueMPlain x y =+   maybe y (return . throwMonoid) x
src/Control/Monad/Exception/Synchronous.hs view
@@ -2,7 +2,31 @@ Synchronous exceptions immediately abort a series of computations. We provide monads for describing this behaviour. -}-module Control.Monad.Exception.Synchronous where+module Control.Monad.Exception.Synchronous (+   Exceptional(..),+   fromMaybe,+   fromEither, toEither,+   getExceptionNull,+   force,+   mapException,+   mapExceptional,+   throw,+   catch,+   resolve,++   ExceptionalT(..),+   fromErrorT,  toErrorT,+   fromEitherT, toEitherT,+   forceT,+   mapExceptionT,+   mapExceptionalT,+   throwT,+   catchT,+   bracketT,+   resolveT,+   tryT,+   manyT,+   ) where  import Control.Applicative (Applicative(pure, (<*>))) import Control.Monad (liftM, {- MonadPlus(mzero, mplus), -})