packages feed

conduit 1.1.5 → 1.1.6

raw patch · 3 files changed

+39/−3 lines, 3 filesdep ~exceptionsPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: exceptions

API changes (from Hackage documentation)

+ Data.Conduit.Internal: instance MonadCatch m => MonadCatch (ConduitM i o m)
+ Data.Conduit.Internal: instance MonadCatch m => MonadCatch (Pipe l i o u m)

Files

Data/Conduit/Internal.hs view
@@ -92,6 +92,9 @@ import qualified GHC.Exts import qualified Data.IORef as I import Control.Monad.Morph (MFunctor (..))+#if MIN_VERSION_exceptions(0, 6, 0)+import qualified Control.Monad.Catch as Catch+#endif  -- | The underlying datatype for all the types in this package.  In has six -- type parameters:@@ -161,6 +164,19 @@ instance MonadThrow m => MonadThrow (Pipe l i o u m) where     throwM = lift . throwM +#if MIN_VERSION_exceptions(0, 6, 0)+instance Catch.MonadCatch m => Catch.MonadCatch (Pipe l i o u m) where+    catch p0 onErr =+        go p0+      where+        go (Done r) = Done r+        go (PipeM mp) = PipeM $ Catch.catch (liftM go mp) (return . onErr)+        go (Leftover p i) = Leftover (go p) i+        go (NeedInput x y) = NeedInput (go . x) (go . y)+        go (HaveOutput p c o) = HaveOutput (go p) c o+    {-# INLINE catch #-}+#endif+ instance Monad m => Monoid (Pipe l i o u m ()) where     mempty = return ()     mappend = (>>)@@ -230,7 +246,11 @@ -- -- Since 1.0.0 newtype ConduitM i o m r = ConduitM { unConduitM :: Pipe i i o () m r }-    deriving (Functor, Applicative, Monad, MonadIO, MonadTrans, MonadThrow, MFunctor)+    deriving (Functor, Applicative, Monad, MonadIO, MonadTrans, MonadThrow, MFunctor+#if MIN_VERSION_exceptions(0, 6, 0)+    , Catch.MonadCatch+#endif+    )  instance MonadReader r m => MonadReader r (ConduitM i o m) where     ask = ConduitM ask
conduit.cabal view
@@ -1,5 +1,5 @@ Name:                conduit-Version:             1.1.5+Version:             1.1.6 Synopsis:            Streaming data processing library. Description:     @conduit@ is a solution to the streaming data problem, allowing for production, transformation, and consumption of streams of data in constant memory. It is an alternative to lazy I\/O which guarantees deterministic resource handling, and fits in the same general solution space as @enumerator@\/@iteratee@ and @pipes@. For a tutorial, please visit <https://haskell.fpcomplete.com/user/snoyberg/library-documentation/conduit-overview>.@@ -47,6 +47,7 @@                    , resourcet                    , void                    , containers+                   , exceptions >= 0.6     ghc-options:     -Wall  --test-suite doctests
test/main.hs view
@@ -1,5 +1,6 @@ {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE CPP #-}+{-# LANGUAGE DeriveDataTypeable #-} import Test.Hspec import Test.Hspec.QuickCheck (prop) import Test.QuickCheck.Monadic (assert, monadicIO, run)@@ -8,6 +9,7 @@ import qualified Data.Conduit.Lift as C import qualified Data.Conduit.Internal as CI import qualified Data.Conduit.List as CL+import Data.Typeable (Typeable) import Control.Monad.Trans.Resource as C (runResourceT) import Data.Maybe   (fromMaybe,catMaybes,fromJust) import qualified Data.List as DL@@ -22,6 +24,7 @@ import Control.Monad.Trans.State (evalStateT, get, put, modify) import Control.Monad.Trans.Maybe (MaybeT (..)) import Control.Applicative (pure, (<$>), (<*>))+import qualified Control.Monad.Catch as Catch import Data.Functor.Identity (Identity,runIdentity) import Control.Monad (forever, void) import Data.Void (Void)@@ -899,11 +902,23 @@                 return (x, y, z)             res `shouldBe` (sum [1..5], ["hello"], [6..10]) +    describe "catching exceptions" $ do+        it "works" $ do+            let src = do+                    C.yield 1+                    () <- Catch.throwM DummyError+                    C.yield 2+                src' = do+                    Catch.catch src (\DummyError -> C.yield (3 :: Int))+            res <- src' C.$$ CL.consume+            res `shouldBe` [1, 3]+     ZipConduit.spec  it' :: String -> IO () -> Spec it' = it  data DummyError = DummyError-    deriving (Show, Eq)+    deriving (Show, Eq, Typeable) instance Error DummyError+instance Catch.Exception DummyError