cereal-conduit 0.6 → 0.7
raw patch · 4 files changed
+25/−20 lines, 4 filesdep ~basedep ~cerealdep ~conduitPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: base, cereal, conduit, transformers
API changes (from Hackage documentation)
- Data.Conduit.Cereal: conduitGet :: MonadThrow m => Get o -> GLConduit ByteString m o
+ Data.Conduit.Cereal: conduitGet :: MonadThrow m => Get o -> Conduit ByteString m o
- Data.Conduit.Cereal: conduitPut :: Monad m => Putter a -> GInfConduit a m ByteString
+ Data.Conduit.Cereal: conduitPut :: Monad m => Putter a -> Conduit a m ByteString
- Data.Conduit.Cereal: sinkGet :: MonadThrow m => Get r -> GLSink ByteString m r
+ Data.Conduit.Cereal: sinkGet :: MonadThrow m => Get r -> Consumer ByteString m r
- Data.Conduit.Cereal: sourcePut :: Monad m => Put -> GSource m ByteString
+ Data.Conduit.Cereal: sourcePut :: Monad m => Put -> Producer m ByteString
- Data.Conduit.Cereal.Internal: mkConduitGet :: MonadThrow m => ConduitErrorHandler m o -> Get o -> GLConduit ByteString m o
+ Data.Conduit.Cereal.Internal: mkConduitGet :: Monad m => ConduitErrorHandler m o -> Get o -> Conduit ByteString m o
- Data.Conduit.Cereal.Internal: mkSinkGet :: Monad m => SinkErrorHandler m r -> SinkTerminationHandler m r -> Get r -> GLSink ByteString m r
+ Data.Conduit.Cereal.Internal: mkSinkGet :: Monad m => SinkErrorHandler m r -> SinkTerminationHandler m r -> Get r -> Consumer ByteString m r
- Data.Conduit.Cereal.Internal: type ConduitErrorHandler m o = String -> GLConduit ByteString m o
+ Data.Conduit.Cereal.Internal: type ConduitErrorHandler m o = String -> Conduit ByteString m o
- Data.Conduit.Cereal.Internal: type SinkErrorHandler m r = String -> GLSink ByteString m r
+ Data.Conduit.Cereal.Internal: type SinkErrorHandler m r = String -> Consumer ByteString m r
- Data.Conduit.Cereal.Internal: type SinkTerminationHandler m r = (ByteString -> Result r) -> GLSink ByteString m r
+ Data.Conduit.Cereal.Internal: type SinkTerminationHandler m r = (ByteString -> Result r) -> Consumer ByteString m r
Files
- Data/Conduit/Cereal.hs +4/−4
- Data/Conduit/Cereal/Internal.hs +8/−8
- Test/Main.hs +1/−1
- cereal-conduit.cabal +12/−7
Data/Conduit/Cereal.hs view
@@ -34,7 +34,7 @@ instance Exception GetException -- | Run a 'Get' repeatedly on the input stream, producing an output stream of whatever the 'Get' outputs.-conduitGet :: C.MonadThrow m => Get o -> C.GLConduit BS.ByteString m o+conduitGet :: C.MonadThrow m => Get o -> C.Conduit BS.ByteString m o conduitGet = mkConduitGet errorHandler where errorHandler msg = pipeError $ GetException msg @@ -42,7 +42,7 @@ -- -- If 'Get' succeed it will return the data read and unconsumed part of the input stream. -- If the 'Get' fails due to deserialization error or early termination of the input stream it raise an error.-sinkGet :: C.MonadThrow m => Get r -> C.GLSink BS.ByteString m r+sinkGet :: C.MonadThrow m => Get r -> C.Consumer BS.ByteString m r sinkGet = mkSinkGet errorHandler terminationHandler where errorHandler msg = pipeError $ GetException msg terminationHandler f = let Fail msg = f BS.empty in pipeError $ GetException msg @@ -51,9 +51,9 @@ pipeError e = lift $ C.monadThrow e -- | Convert a 'Put' into a 'Source'. Runs in constant memory.-sourcePut :: Monad m => Put -> C.GSource m BS.ByteString+sourcePut :: Monad m => Put -> C.Producer m BS.ByteString sourcePut put = CL.sourceList $ LBS.toChunks $ runPutLazy put -- | Run a 'Putter' repeatedly on the input stream, producing a concatenated 'ByteString' stream.-conduitPut :: Monad m => Putter a -> C.GInfConduit a m BS.ByteString+conduitPut :: Monad m => Putter a -> C.Conduit a m BS.ByteString conduitPut p = CL.map $ runPut . p
Data/Conduit/Cereal/Internal.hs view
@@ -10,23 +10,23 @@ , mkSinkGet ) where -import Control.Monad (when)+import Control.Monad (forever, when) import qualified Data.ByteString as BS import qualified Data.Conduit as C import Data.Serialize hiding (get, put) -- | What should we do if the Get fails?-type ConduitErrorHandler m o = String -> C.GLConduit BS.ByteString m o-type SinkErrorHandler m r = String -> C.GLSink BS.ByteString m r+type ConduitErrorHandler m o = String -> C.Conduit BS.ByteString m o+type SinkErrorHandler m r = String -> C.Consumer BS.ByteString m r -- | What should we do if the stream is done before the Get is done?-type SinkTerminationHandler m r = (BS.ByteString -> Result r) -> C.GLSink BS.ByteString m r+type SinkTerminationHandler m r = (BS.ByteString -> Result r) -> C.Consumer BS.ByteString m r -- | Construct a conduitGet with the specified 'ErrorHandler'-mkConduitGet :: C.MonadThrow m+mkConduitGet :: Monad m => ConduitErrorHandler m o -> Get o- -> C.GLConduit BS.ByteString m o+ -> C.Conduit BS.ByteString m o mkConduitGet errorHandler get = consume True (runGetPartial get) [] BS.empty where pull f b s | BS.null s = C.await >>= maybe (when (not $ null b) (C.leftover $ BS.concat $ reverse b)) (pull f b)@@ -38,7 +38,7 @@ Partial p -> pull p consumed BS.empty Done a s' -> case initial of -- this only works because the Get will either _always_ consume no input, or _never_ consume no input.- True -> sequence_ $ repeat $ C.yield a+ True -> forever $ C.yield a False -> C.yield a >> pull (runGetPartial get) [] s' -- False -> C.yield a >> C.leftover s' >> mkConduitGet errorHandler get where consumed = s : b@@ -48,7 +48,7 @@ => SinkErrorHandler m r -> SinkTerminationHandler m r -> Get r- -> C.GLSink BS.ByteString m r+ -> C.Consumer BS.ByteString m r mkSinkGet errorHandler terminationHandler get = consume (runGetPartial get) [] BS.empty where pull f b s | BS.null s = C.await >>= \ x -> case x of
Test/Main.hs view
@@ -79,7 +79,7 @@ -- Current sink implementation will terminate the pipe in case of error. -- One may need non-terminating version like one defined below to get access to Leftovers -sinkGetMaybe :: Get Word8 -> C.GLSink BS.ByteString (ExceptionT Identity) Word8+sinkGetMaybe :: Get Word8 -> C.Consumer BS.ByteString (ExceptionT Identity) Word8 sinkGetMaybe = mkSinkGet errorHandler terminationHandler where errorHandler _ = return 34 terminationHandler _ = return 114
cereal-conduit.cabal view
@@ -1,20 +1,25 @@ name: cereal-conduit-version: 0.6+version: 0.7 license: BSD3 license-file: LICENSE author: Myles C. Maxfield <myles.maxfield@gmail.com> maintainer: Myles C. Maxfield <myles.maxfield@gmail.com> synopsis: Turn Data.Serialize Gets and Puts into Sources, Sinks, and Conduits-description: Turn Data.Serialize Gets and Puts into Sources, Sinks, and Conduits+description:+ Turn Data.Serialize Gets and Puts into Sources, Sinks, and Conduits.+ .+ [0.7]+ Upgrade to conduit 1.0.0 category: Conduit stability: Experimental cabal-version: >= 1.8 build-type: Simple homepage: https://github.com/litherum/cereal-conduit+bug-reports: https://github.com/litherum/cereal-conduit/issues library build-depends: base >= 4 && < 5- , conduit >= 0.5.0 && < 0.6.0+ , conduit >= 1.0.0 && < 1.1 , cereal >= 0.3.1.0 , bytestring , transformers >= 0.2.0.0@@ -25,15 +30,15 @@ Test-Suite test-cereal-conduit type: exitcode-stdio-1.0 main-is: Test/Main.hs- build-depends: base >= 4 && < 5- , conduit >= 0.5.0 && < 0.6.0- , cereal >= 0.3.1.0+ build-depends: base+ , conduit+ , cereal , bytestring --, test-framework-hunit , HUnit , resourcet , mtl- , transformers >= 0.2.0.0+ , transformers source-repository head type: git