git.iko.soy/distributed-process
on master help sign in
Add try
commit49ae85ee217b97c021c9980e42401d5a9b6ebe98 authorSimon Marlow <marlowsd@gmail.com> dateWed 12 Dec 2012, 13:37 (14 years ago) parent305a3dc
2 files changed+11−2
distributed-process/src/Control/Distributed/Process.hs+2 distributed-process/src/Control/Distributed/Process/Internal/Primitives.hs+9−2
distributed-process/src/Control/Distributed/Process.hs+2
@@ -96,6 +96,7 @@ module Control.Distributed.Process
9696 , RegisterReply(..)
9797 -- * Exception handling
9898 , catch
99+ , try
99100 , mask
100101 , onException
101102 , bracket
@@ -226,6 +227,7 @@ import Control.Distributed.Process.Internal.Primitives
226227 , unClosure
227228 -- Exception handling
228229 , catch
230+ , try
229231 , mask
230232 , onException
231233 , bracket
distributed-process/src/Control/Distributed/Process/Internal/Primitives.hs+9−2
@@ -55,6 +55,7 @@ module Control.Distributed.Process.Internal.Primitives
5555 , unStatic
5656 -- * Exception handling
5757 , catch
58+ , try
5859 , mask
5960 , onException
6061 , bracket
@@ -89,7 +90,7 @@ import Control.Monad.Reader (ask)
8990import Control.Monad.IO.Class (MonadIO, liftIO)
9091import Control.Applicative ((<$>))
9192import Control.Exception (Exception, throwIO, SomeException)
92−import qualified Control.Exception as Ex (catch, mask)
93+import qualified Control.Exception as Ex (catch, mask, try)
9394import Control.Distributed.Process.Internal.StrictMVar
9495 ( StrictMVar
9596 , modifyMVar
@@ -504,7 +505,13 @@ catch p h = do
504505 lproc <- ask
505506 liftIO $ Ex.catch (runLocalProcess lproc p) (runLocalProcess lproc . h)
506507
507−-- | Lift 'Control.Exception.mask'
508+-- | Lift 'Control.Exception.try'
509+try :: Exception e => Process a -> Process (Either e a)
510+try p = do
511+ lproc <- ask
512+ liftIO $ Ex.try (runLocalProcess lproc p)
513+
514+-- | Lift 'Control.Exception.mask'
508515mask :: ((forall a. Process a -> Process a) -> Process b) -> Process b
509516mask p = do
510517 lproc <- ask