packages feed

chp 1.3.0 → 1.3.1

raw patch · 4 files changed

+26/−26 lines, 4 filesdep +extensible-exceptionsPVP ok

version bump matches the API change (PVP)

Dependencies added: extensible-exceptions

API changes (from Hackage documentation)

Files

Control/Concurrent/CHP/Base.hs view
@@ -36,13 +36,6 @@ import Control.Applicative import Control.Arrow import Control.Concurrent.STM--- #if __GLASGOW_HASKELL__ >= 609--- I can't figure out the new Exception system in GHC 6.10 and how I catch all--- exceptions (see GHC bug #2655), so I'm just going to use the old system:---import qualified Control.OldException as C--- #else---import qualified Control.Exception as C--- #endif import Control.Monad.Error import Control.Monad.Reader import Control.Monad.State
Control/Concurrent/CHP/Console.hs view
@@ -32,13 +32,7 @@  import Control.Concurrent import Control.Concurrent.STM-#if __GLASGOW_HASKELL__ >= 609--- I can't figure out the new Exception system in GHC 6.10 and how I catch all--- exceptions (see GHC bug #2655), so I'm just going to use the old system:-import qualified Control.OldException as C-#else-import qualified Control.Exception as C-#endif+import qualified Control.Exception.Extensible as C import Control.Monad import Control.Monad.Trans import Data.Maybe@@ -85,8 +79,17 @@      -- Like liftIO, but turns any caught exceptions into throwing poison     liftIO' :: IO a -> CHP a-    liftIO' m = liftIO (liftM Just m `C.catch` const (return Nothing))+    liftIO' m = liftIO (liftM Just m `C.catches` handlers)       >>= maybe throwPoison return+      where+        response :: C.Exception e => e -> IO (Maybe a)+        response = const $ return Nothing++        handlers = [C.Handler (response :: C.IOException -> IO (Maybe a))+                   ,C.Handler (response :: C.AsyncException -> IO (Maybe a))+                   ,C.Handler (response :: C.BlockedIndefinitely -> IO (Maybe a))+                   ,C.Handler (response :: C.Deadlock -> IO (Maybe a))+                   ]          inHandler :: TVar (Maybe ThreadId) -> Chanout Char -> CHP ()     inHandler tv c
Control/Concurrent/CHP/Parallel.hs view
@@ -32,13 +32,7 @@  import Control.Concurrent import Control.Concurrent.STM-#if __GLASGOW_HASKELL__ >= 609--- I can't figure out the new Exception system in GHC 6.10 and how I catch all--- exceptions (see GHC bug #2655), so I'm just going to use the old system:-import qualified Control.OldException as C-#else-import qualified Control.Exception as C-#endif+import qualified Control.Exception.Extensible as C import Control.Monad.Error import Control.Monad.Reader import Control.Monad.State@@ -104,12 +98,22 @@   a, st)) -> IO (Maybe (Either st (a, st))) wrapProcess (PoisonT proc) unwrapInner   = do let inner = runErrorT proc-       x <- liftM Just (unwrapInner inner) `C.catch` (\x -> liftIO (hPutStrLn-         stderr $ "Thread terminated with: " ++ show x) >> return Nothing)+       x <- liftM Just (unwrapInner inner) `C.catches` allHandlers        case x of          Nothing -> return Nothing          Just (Left _, st) -> return $ Just $ Left st          Just (Right y, st) -> return $ Just $ Right (y, st)+  where+    response :: C.Exception e => e -> IO (Maybe a)+    response x = liftIO (hPutStrLn stderr $ "Thread terminated with: " ++ show x)+                   >> return Nothing++    allHandlers = [C.Handler (response :: C.IOException -> IO (Maybe a))+                  ,C.Handler (response :: C.AsyncException -> IO (Maybe a))+                  ,C.Handler (response :: C.NonTermination -> IO (Maybe a))+                  ,C.Handler (response :: C.BlockedIndefinitely -> IO (Maybe a))+                  ,C.Handler (response :: C.Deadlock -> IO (Maybe a))+                  ]  -- | Runs all the processes in parallel and returns their results once they -- have all finished.  The length and ordering of the results reflects the
chp.cabal view
@@ -1,5 +1,5 @@ Name:            chp-Version:         1.3.0+Version:         1.3.1 Synopsis:        An implementation of concurrency ideas from Communicating Sequential Processes License:         BSD3 License-file:    LICENSE@@ -18,7 +18,7 @@ Category:        Concurrency  Build-Type:      Simple-Build-Depends:   base >= 3 && < 5, containers, mtl, parallel, pretty, stm+Build-Depends:   base >= 3 && < 5, extensible-exceptions >= 0.1.1.0, containers, mtl, parallel, pretty, stm  Exposed-modules: Control.Concurrent.CHP                  Control.Concurrent.CHP.Actions