blaze-builder-conduit 0.5.0.3 → 1.0.0
raw patch · 2 files changed
+15/−16 lines, 2 filesdep ~conduit
Dependency ranges changed: conduit
Files
- Data/Conduit/Blaze.hs +13/−14
- blaze-builder-conduit.cabal +2/−2
Data/Conduit/Blaze.hs view
@@ -42,7 +42,7 @@ , reuseBufferStrategy ) where -import Data.Conduit hiding (Source, Conduit, Sink, Pipe)+import Data.Conduit import Control.Monad (unless, liftM) import Control.Monad.Trans.Class (lift, MonadTrans) @@ -54,14 +54,14 @@ -- | Incrementally execute builders and pass on the filled chunks as -- bytestrings.-builderToByteString :: MonadUnsafeIO m => GInfConduit Builder m S.ByteString+builderToByteString :: MonadUnsafeIO m => Conduit Builder m S.ByteString builderToByteString = builderToByteStringWith (allNewBuffersStrategy defaultBufferSize) -- | -- -- Since 0.0.2-builderToByteStringFlush :: MonadUnsafeIO m => GInfConduit (Flush Builder) m (Flush S.ByteString)+builderToByteStringFlush :: MonadUnsafeIO m => Conduit (Flush Builder) m (Flush S.ByteString) builderToByteStringFlush = builderToByteStringWithFlush (allNewBuffersStrategy defaultBufferSize) @@ -74,7 +74,7 @@ -- as control is returned from the inner sink! unsafeBuilderToByteString :: MonadUnsafeIO m => IO Buffer -- action yielding the inital buffer.- -> GInfConduit Builder m S.ByteString+ -> Conduit Builder m S.ByteString unsafeBuilderToByteString = builderToByteStringWith . reuseBufferStrategy @@ -84,9 +84,9 @@ -- INV: All bytestrings passed to the inner sink are non-empty. builderToByteStringWith :: MonadUnsafeIO m => BufferAllocStrategy- -> GInfConduit Builder m S.ByteString+ -> Conduit Builder m S.ByteString builderToByteStringWith =- helper (liftM (fmap Chunk) awaitE) yield'+ helper (liftM (fmap Chunk) await) yield' where yield' Flush = return () yield' (Chunk bs) = yield bs@@ -97,27 +97,26 @@ builderToByteStringWithFlush :: MonadUnsafeIO m => BufferAllocStrategy- -> GInfConduit (Flush Builder) m (Flush S.ByteString)-builderToByteStringWithFlush = helper awaitE yield+ -> Conduit (Flush Builder) m (Flush S.ByteString)+builderToByteStringWithFlush = helper await yield helper :: (MonadUnsafeIO m, Monad (t m), MonadTrans t)- => t m (Either term (Flush Builder))+ => t m (Maybe (Flush Builder)) -> (Flush S.ByteString -> t m ()) -> BufferAllocStrategy- -> t m term-helper awaitE' yield' (ioBufInit, nextBuf) =+ -> t m ()+helper await' yield' (ioBufInit, nextBuf) = loop ioBufInit where loop ioBuf = do- awaitE' >>= either (close ioBuf) (cont' ioBuf)+ await' >>= maybe (close ioBuf) (cont' ioBuf) cont' ioBuf Flush = push ioBuf flush $ \ioBuf' -> yield' Flush >> loop ioBuf' cont' ioBuf (Chunk builder) = push ioBuf builder loop - close ioBuf r = do+ close ioBuf = do buf <- lift $ unsafeLiftIO $ ioBuf maybe (return ()) (yield' . Chunk) (unsafeFreezeNonEmptyBuffer buf)- return r push ioBuf0 x continue = do go (unBuilder x (buildStep finalStep)) ioBuf0
blaze-builder-conduit.cabal view
@@ -1,5 +1,5 @@ Name: blaze-builder-conduit-Version: 0.5.0.3+Version: 1.0.0 Synopsis: Convert streams of builders to streams of bytestrings. Description: Convert streams of builders to streams of bytestrings. License: BSD3@@ -20,7 +20,7 @@ , bytestring >= 0.9 , text >= 0.11 , blaze-builder >= 0.2.1.4 && < 0.4- , conduit >= 0.5 && < 0.6+ , conduit >= 1.0 && < 1.1 ghc-options: -Wall test-suite test