conduit 0.1.0 → 0.1.1
raw patch · 2 files changed
+38/−17 lines, 2 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Data.Conduit.Binary: sinkIOHandle :: ResourceIO m => IO Handle -> Sink ByteString m ()
+ Data.Conduit.Binary: sourceIOHandle :: ResourceIO m => IO Handle -> Source m ByteString
Files
- Data/Conduit/Binary.hs +37/−16
- conduit.cabal +1/−1
Data/Conduit/Binary.hs view
@@ -4,9 +4,11 @@ module Data.Conduit.Binary ( sourceFile , sourceHandle+ , sourceIOHandle , sourceFileRange , sinkFile , sinkHandle+ , sinkIOHandle , conduitFile , isolate , openFile@@ -54,19 +56,13 @@ sourceFile :: ResourceIO m => FilePath -> Source m S.ByteString-sourceFile fp = sourceIO+sourceFile fp = #if CABAL_OS_WINDOWS || NO_HANDLES- (F.openRead fp)- F.close- (liftIO . F.read)+ sourceIO (F.openRead fp)+ F.close+ (liftIO . F.read) #else- (IO.openBinaryFile fp IO.ReadMode)- IO.hClose- (\handle -> do- bs <- liftIO $ S.hGetSome handle 4096- if S.null bs- then return Closed- else return $ Open bs)+ sourceIOHandle (IO.openBinaryFile fp IO.ReadMode) #endif -- | Stream the contents of a 'IO.Handle' as binary data. Note that this@@ -86,6 +82,22 @@ , sourceClose = return () } +-- | An alternative to 'sourceHandle'.+-- Instead of taking a pre-opened 'IO.Handle', it takes an action that opens+-- a 'IO.Handle' (in read mode), so that it can open it only when needed+-- and close it as soon as possible.+--+-- Since 0.1.1+sourceIOHandle :: ResourceIO m+ => IO IO.Handle+ -> Source m S.ByteString+sourceIOHandle alloc = sourceIO alloc IO.hClose+ (\handle -> do+ bs <- liftIO (S.hGetSome handle 4096)+ if S.null bs+ then return Closed+ else return $ Open bs)+ -- | Stream all incoming data to the given 'IO.Handle'. Note that this function -- will /not/ automatically close the @Handle@ when processing completes. --@@ -98,6 +110,19 @@ , sinkClose = return () } +-- | An alternative to 'sinkHandle'.+-- Instead of taking a pre-opened 'IO.Handle', it takes an action that opens+-- a 'IO.Handle' (in write mode), so that it can open it only when needed+-- and close it as soon as possible.+--+-- Since 0.1.1+sinkIOHandle :: ResourceIO m+ => IO IO.Handle+ -> Sink S.ByteString m ()+sinkIOHandle alloc = sinkIO alloc IO.hClose+ (\handle bs -> liftIO (S.hPut handle bs) >> return Processing)+ (const $ return ())+ -- | Stream the contents of a file as binary data, starting from a certain -- offset and only consuming up to a certain number of bytes. --@@ -149,11 +174,7 @@ sinkFile :: ResourceIO m => FilePath -> Sink S.ByteString m ()-sinkFile fp = sinkIO- (IO.openBinaryFile fp IO.WriteMode)- IO.hClose- (\handle bs -> liftIO (S.hPut handle bs) >> return Processing)- (const $ return ())+sinkFile fp = sinkIOHandle (IO.openBinaryFile fp IO.WriteMode) -- | Stream the contents of the input to a file, and also send it along the -- pipeline. Similar in concept to the Unix command @tee@.
conduit.cabal view
@@ -1,5 +1,5 @@ Name: conduit-Version: 0.1.0+Version: 0.1.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>.