conduit 0.5.2.4 → 0.5.2.5
raw patch · 3 files changed
+36/−3 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- Data/Conduit/Internal.hs +14/−1
- conduit.cabal +1/−1
- test/main.hs +21/−1
Data/Conduit/Internal.hs view
@@ -440,7 +440,20 @@ transPipe f (HaveOutput p c o) = HaveOutput (transPipe f p) (f c) o transPipe f (NeedInput p c) = NeedInput (transPipe f . p) (transPipe f . c) transPipe _ (Done r) = Done r-transPipe f (PipeM mp) = PipeM (f $ liftM (transPipe f) mp)+transPipe f (PipeM mp) =+ PipeM (f $ liftM (transPipe f) $ collapse mp)+ where+ -- Combine a series of monadic actions into a single action. Since we+ -- throw away side effects between different actions, an arbitrary break+ -- between actions will lead to a violation of the monad transformer laws.+ -- Example available at:+ --+ -- http://hpaste.org/75520+ collapse mpipe = do+ pipe <- mpipe+ case pipe of+ PipeM mpipe' -> collapse mpipe'+ _ -> return pipe transPipe f (Leftover p i) = Leftover (transPipe f p) i -- | Apply a function to all the output values of a @Pipe@.
conduit.cabal view
@@ -1,5 +1,5 @@ Name: conduit-Version: 0.5.2.4+Version: 0.5.2.5 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 brief tutorial, please see the "Data.Conduit" module.
test/main.hs view
@@ -27,7 +27,8 @@ import Control.Concurrent (threadDelay, killThread) import Control.Monad.IO.Class (liftIO) import Control.Monad.Trans.Class (lift)-import Control.Monad.Trans.Writer (execWriter, tell)+import Control.Monad.Trans.Writer (execWriter, tell, runWriterT)+import Control.Monad.Trans.State (evalStateT, get, put) import Control.Applicative (pure, (<$>), (<*>)) import Data.Functor.Identity (runIdentity) import Control.Monad (forever)@@ -794,6 +795,25 @@ it "conduit" $ do let run p = execWriter $ src C.$$ p C.=$ printer run ((p3 C.=$= p2) C.=$= p1) `shouldBe` run (p3 C.=$= (p2 C.=$= p1))+ describe "monad transformer laws" $ do+ it "transPipe" $ do+ let source = CL.sourceList $ replicate 10 ()+ let tell' x = tell [x :: Int]++ let replaceNum1 = C.awaitForever $ \() -> do+ i <- lift get+ lift $ (put $ i + 1) >> (get >>= lift . tell')+ C.yield i++ let replaceNum2 = C.awaitForever $ \() -> do+ i <- lift get+ lift $ put $ i + 1+ lift $ get >>= lift . tell'+ C.yield i++ x <- runWriterT $ source C.$$ C.transPipe (`evalStateT` 1) replaceNum1 C.=$ CL.consume+ y <- runWriterT $ source C.$$ C.transPipe (`evalStateT` 1) replaceNum2 C.=$ CL.consume+ x `shouldBe` y it' :: String -> IO () -> Spec it' = it