packages feed

conduit 1.2.11 → 1.2.12

raw patch · 3 files changed

+65/−1 lines, 3 filesdep +transformers-compatPVP ok

version bump matches the API change (PVP)

Dependencies added: transformers-compat

API changes (from Hackage documentation)

+ Data.Conduit.Lift: catchExceptC :: Monad m => ConduitM i o (ExceptT e m) r -> (e -> ConduitM i o (ExceptT e m) r) -> ConduitM i o (ExceptT e m) r
+ Data.Conduit.Lift: exceptC :: (Monad m, Monad (t (ExceptT e m)), MonadTrans t, MFunctor t) => t m (Either e b) -> t (ExceptT e m) b
+ Data.Conduit.Lift: runExceptC :: Monad m => ConduitM i o (ExceptT e m) r -> ConduitM i o m (Either e r)

Files

ChangeLog.md view
@@ -1,3 +1,7 @@+## 1.2.12++* Add `exceptC`, `runExceptC` and `catchExceptC` to `Data.Conduit.Lift`+ ## 1.2.11  * Add `unfoldEither` and `unfoldEitherM` to `Data.Conduit.List`
Data/Conduit/Lift.hs view
@@ -8,6 +8,11 @@ -- -- This module was added in conduit 1.0.11. module Data.Conduit.Lift (+    -- * ExceptT+    exceptC,+    runExceptC,+    catchExceptC,+     -- * ErrorT     errorC,     runErrorC,@@ -75,6 +80,7 @@ import Data.Monoid (Monoid(..))  +import qualified Control.Monad.Trans.Except as Ex import qualified Control.Monad.Trans.Error as E import qualified Control.Monad.Trans.Maybe as M import qualified Control.Monad.Trans.Reader as R@@ -121,6 +127,59 @@       MFunctor t) =>      ConduitM b o (t m) () -> t (ConduitM b o m) () distribute p = catAwaitLifted =$= hoist (hoist lift) p $$ catYieldLifted++-- | Wrap the base monad in 'Ex.ExceptT'+--+-- Since 1.2.12+exceptC+  :: (Monad m, Monad (t (Ex.ExceptT e m)), MonadTrans t, MFunctor t) =>+     t m (Either e b) -> t (Ex.ExceptT e m) b+exceptC p = do+    x <- hoist lift p+    lift $ Ex.ExceptT (return x)++-- | Run 'Ex.ExceptT' in the base monad+--+-- Since 1.2.12+runExceptC+  :: Monad m =>+     ConduitM i o (Ex.ExceptT e m) r -> ConduitM i o m (Either e r)+runExceptC (ConduitM c0) =+    ConduitM $ \rest ->+        let go (Done r) = rest (Right r)+            go (PipeM mp) = PipeM $ do+                eres <- Ex.runExceptT mp+                return $ case eres of+                    Left e -> rest $ Left e+                    Right p -> go p+            go (Leftover p i) = Leftover (go p) i+            go (HaveOutput p f o) = HaveOutput (go p) (Ex.runExceptT f >> return ()) o+            go (NeedInput x y) = NeedInput (go . x) (go . y)+         in go (c0 Done)+{-# INLINABLE runExceptC #-}++-- | Catch an error in the base monad+--+-- Since 1.2.12+catchExceptC+  :: Monad m =>+     ConduitM i o (Ex.ExceptT e m) r+     -> (e -> ConduitM i o (Ex.ExceptT e m) r)+     -> ConduitM i o (Ex.ExceptT e m) r+catchExceptC c0 h =+    ConduitM $ \rest ->+        let go (Done r) = rest r+            go (PipeM mp) = PipeM $ do+                eres <- lift $ Ex.runExceptT mp+                return $ case eres of+                    Left e -> unConduitM (h e) rest+                    Right p -> go p+            go (Leftover p i) = Leftover (go p) i+            go (HaveOutput p f o) = HaveOutput (go p) f o+            go (NeedInput x y) = NeedInput (go . x) (go . y)+         in go $ unConduitM c0 Done+  where+{-# INLINABLE catchExceptC #-}  -- | Wrap the base monad in 'E.ErrorT' --
conduit.cabal view
@@ -1,5 +1,5 @@ Name:                conduit-Version:             1.2.11+Version:             1.2.12 Synopsis:            Streaming data processing library. description:     `conduit` is a solution to the streaming data problem, allowing for production,@@ -39,6 +39,7 @@                      , lifted-base              >= 0.1                      , transformers-base        >= 0.4.1        && < 0.5                      , transformers             >= 0.2.2+                     , transformers-compat      >= 0.3                      , mtl                      , mmorph                      , monad-control