conduit 0.4.0 → 0.4.0.1
raw patch · 4 files changed
+39/−43 lines, 4 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- Data/Conduit/Internal.hs +13/−10
- Data/Conduit/Text.hs +21/−31
- conduit.cabal +2/−2
- test/main.hs +3/−0
Data/Conduit/Internal.hs view
@@ -186,15 +186,6 @@ Nothing -> left Just i -> HaveOutput left (pipeClose left) i --- Left pipe needs more input, ask for it.-pipeResume (NeedInput p c) right = NeedInput- (\a -> pipeResume (p a) right)- (do- (left, res) <- pipeResume c right- lift $ pipeClose left- return (mempty, res)- )- -- Left pipe has output, right pipe wants it. pipeResume (HaveOutput lp _ a) (NeedInput rp _) = pipeResume lp (rp a) @@ -209,6 +200,18 @@ (((,) left) `liftM` c) o +-- Now we've dealt with all right constructor except for NeedInput. Since the+-- right pipe needs more input, we can process the left pipe.++-- Left pipe needs more input, ask for it.+pipeResume (NeedInput p c) right@NeedInput{} = NeedInput+ (\a -> pipeResume (p a) right)+ (do+ (left, res) <- pipeResume c right+ lift $ pipeClose left+ return (mempty, res)+ )+ -- Left pipe is done, right pipe needs input. In such a case, tell the right -- pipe there is no more input, and eventually replace its leftovers with the -- left pipe's leftover.@@ -216,7 +219,7 @@ -- Left pipe needs to run a monadic action.-pipeResume (PipeM mp c) right = PipeM+pipeResume (PipeM mp c) right@NeedInput{} = PipeM ((`pipeResume` right) `liftM` mp) (c >> liftM ((,) mempty) (pipeClose right))
Data/Conduit/Text.hs view
@@ -78,40 +78,30 @@ -- -- Since 0.3.0 decode :: MonadThrow m => Codec -> C.Conduit B.ByteString m T.Text-decode codec = C.conduitState- Nothing- push- close+decode codec =+ C.NeedInput push (close B.empty) where- push mb input = do- (mb', ts) <- go' mb input- return $ C.StateProducing mb' ts- close mb =- case mb of- Nothing -> return []- Just b- | B.null b -> error "Data.Conduit.Text.decode: Received a null chunk"- | otherwise -> monadThrow $ DecodeException codec (B.head b)-- go' mb input = do -- FIXME This can be simplified significantly since input is now only a single BS- let bss = maybe id (:) mb [input]- either monadThrow return $ go bss id-- go [] front = Right (Nothing, front [])- go (x:xs) front- | B.null x = go xs front- go (x:xs) front =+ push bs = case extra of- Left (exc, _) -> Left exc- Right bs- | B.null bs -> go xs front'- | otherwise ->- case xs of- y:ys -> go (B.append bs y:ys) front'- [] -> Right (Just bs, front' [])+ Left (exc, _) -> C.PipeM (monadThrow exc) (monadThrow exc)+ Right bs' ->+ let push' = if B.null bs' then push else push . B.append bs'+ close' = close bs'+ in C.HaveOutput (C.NeedInput push' close') (close2 bs') text where- (text, extra) = codecDecode codec x- front' = front . (text:)+ (text, extra) = codecDecode codec bs++ close bs =+ case B.uncons bs of+ Nothing -> C.Done Nothing ()+ Just (w, _) ->+ let exc = monadThrow $ DecodeException codec w+ in C.PipeM exc exc++ close2 bs =+ case B.uncons bs of+ Nothing -> return ()+ Just (w, _) -> monadThrow $ DecodeException codec w -- | -- Since 0.3.0
conduit.cabal view
@@ -1,12 +1,12 @@ Name: conduit-Version: 0.4.0+Version: 0.4.0.1 Synopsis: Streaming data processing library. Description: Conduits are an approach to the streaming data problem. It is meant as an alternative to enumerators\/iterators, hoping to address the same issues with different trade-offs based on real-world experience with enumerators. For more information, see <http://www.yesodweb.com/book/conduit>. . Release history: .- [0.4] Inspired by the design of the pipes package: we now have a single unified type underlying @Source@, @Sink@, and @Conduit@. This type is named @Pipe@. There are type synonyms provided for the other three types. Additionally, @BufferedSource@ is no longer provided. Instead, the connect-and-resume operator, @$$&@, can be used for the same purpose.+ [0.4] Inspired by the design of the pipes package: we now have a single unified type underlying @Source@, @Sink@, and @Conduit@. This type is named @Pipe@. There are type synonyms provided for the other three types. Additionally, @BufferedSource@ is no longer provided. Instead, the connect-and-resume operator, @$$+@, can be used for the same purpose. . [0.3] ResourceT has been greatly simplified, specialized for IO, and moved into a separate package. Instead of hard-coding ResourceT into the conduit datatypes, they can now live around any monad. The Conduit datatype has been enhanced to better allow generation of streaming output. The SourceResult, SinkResult, and ConduitResult datatypes have been removed entirely. .
test/main.hs view
@@ -343,6 +343,9 @@ go "utf16_be" TLE.encodeUtf16BE CT.utf16_be go "utf32_le" TLE.encodeUtf32LE CT.utf32_le go "utf32_be" TLE.encodeUtf32BE CT.utf32_be+ it "is not too eager" $ do+ x <- CL.sourceList ["foobarbaz", error "ignore me"] C.$$ CT.decode CT.utf8 C.=$ CL.head+ x @?= Just "foobarbaz" describe "binary isolate" $ do it "works" $ do