packages feed

concurrent-state 0.3.2.0 → 0.3.3.0

raw patch · 3 files changed

+24/−2 lines, 3 filesdep +exceptions

Dependencies added: exceptions

Files

concurrent-state.cabal view
@@ -1,5 +1,5 @@ name:                concurrent-state-version:             0.3.2.0+version:             0.3.3.0 synopsis:            MTL-like library using TVars description:         State backed by TVar. homepage:            https://github.com/joelteon/concurrent-state@@ -15,7 +15,7 @@   exposed-modules:     Control.Monad.State.Concurrent                        Control.Monad.State.Concurrent.Lazy                        Control.Monad.State.Concurrent.Strict-  build-depends:       base >=4.6 && <4.7, mtl >= 2.1, stm, transformers+  build-depends:       base >=4.6 && <4.7, exceptions >= 0.3, mtl >= 2.1, stm, transformers   hs-source-dirs:      src   default-language:    Haskell2010 
src/Control/Monad/State/Concurrent/Lazy.hs view
@@ -28,7 +28,9 @@  import Control.Applicative import Control.Concurrent.STM+import Control.Exception (throwIO) import Control.Monad+import Control.Monad.Catch import Control.Monad.State  -- ---------------------------------------------------------------------------@@ -89,6 +91,15 @@     liftIO i = StateC $ \s -> do         a <- liftIO i         return (a, s)++instance (MonadIO m, MonadCatch m) => MonadCatch (StateC s m) where+    throwM = liftIO . throwIO+    catch = liftCatchC catch+    mask a = StateC $ \tv -> mask $ \u -> _runStateC (a $ q u) tv where+        q u (StateC f) = StateC (u . f)+    uninterruptibleMask a =+        StateC $ \tv -> uninterruptibleMask $ \u -> _runStateC (a $ q u) tv where+        q u (StateC f) = StateC (u . f)  -- | Unwrap a concurrent state monad computation as a function. runStateC :: MonadIO m
src/Control/Monad/State/Concurrent/Strict.hs view
@@ -29,7 +29,9 @@ import Control.Applicative import Control.Arrow (first) import Control.Concurrent.STM+import Control.Exception (throwIO) import Control.Monad+import Control.Monad.Catch import Control.Monad.State  -- ---------------------------------------------------------------------------@@ -90,6 +92,15 @@     liftIO i = StateC $ \s -> do         a <- liftIO i         return (a, s)++instance (MonadIO m, MonadCatch m) => MonadCatch (StateC s m) where+    throwM = liftIO . throwIO+    catch = liftCatchC catch+    mask a = StateC $ \tv -> mask $ \u -> _runStateC (a $ q u) tv where+        q u (StateC f) = StateC (u . f)+    uninterruptibleMask a =+        StateC $ \tv -> uninterruptibleMask $ \u -> _runStateC (a $ q u) tv where+        q u (StateC f) = StateC (u . f)  -- | Unwrap a concurrent state monad computation as a function. runStateC :: MonadIO m