machines-io 0.2.0.6 → 0.2.0.8
raw patch · 2 files changed
+13/−4 lines, 2 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
+ System.IO.Machine: byChunk :: IOData a => IODataMode a
+ System.IO.Machine: byChunkOf :: Int -> IODataMode ByteString
- System.IO.Machine: sinkHandle :: IOData a => IODataMode a -> Handle -> SinkIO m a
+ System.IO.Machine: sinkHandle :: IODataMode a -> Handle -> SinkIO m a
- System.IO.Machine: sinkHandleWith :: IOData a => (Handle -> a -> IO ()) -> Handle -> SinkIO m a
+ System.IO.Machine: sinkHandleWith :: (Handle -> a -> IO ()) -> Handle -> SinkIO m a
Files
- machines-io.cabal +1/−1
- src/System/IO/Machine.hs +12/−3
machines-io.cabal view
@@ -1,5 +1,5 @@ name: machines-io-version: 0.2.0.6+version: 0.2.0.8 synopsis: IO utilities for the machines library homepage: http://github.com/aloiscochard/machines-io license: Apache-2.0
src/System/IO/Machine.hs view
@@ -1,9 +1,12 @@+{-# LANGUAGE CPP #-} {-# LANGUAGE Rank2Types #-} module System.IO.Machine where +#if !MIN_VERSION_base(4,8,0) import Control.Applicative ((<$>))+#endif import Control.Monad.IO.Class (MonadIO, liftIO)-import Data.IOData (IOData, hGetLine, hPutStrLn)+import Data.IOData (IOData, hGetChunk, hGetLine, hPut, hPutStrLn) import Data.Machine import Data.Word (Word8) import System.IO (Handle, hIsEOF)@@ -22,6 +25,12 @@ byChar :: IODataMode Char byChar = (\h -> BSC8.head <$> BSC8.hGet h 1, \h w -> BSC8.hPut h $ BSC8.pack [w]) +byChunk :: IOData a => IODataMode a+byChunk = (\h -> hGetChunk h, \h xs -> hPut h xs)++byChunkOf :: Int -> IODataMode BS.ByteString+byChunkOf n = (\h -> BS.hGet h n, \h xs -> BS.hPut h xs)+ byWord8 :: IODataMode Word8 byWord8 = (\h -> BS.head <$> BS.hGet h 1, \h w -> BS.hPut h $ BS.pack [w]) @@ -50,10 +59,10 @@ sinkIO :: (a -> IO ()) -> SinkIO m a sinkIO f = repeatedly $ await >>= liftIO . f -sinkHandle :: IOData a => IODataMode a -> Handle -> SinkIO m a+sinkHandle :: IODataMode a -> Handle -> SinkIO m a sinkHandle (_, w) h = repeatedly $ await >>= liftIO . w h -sinkHandleWith :: IOData a => (Handle -> a -> IO ()) -> Handle -> SinkIO m a+sinkHandleWith :: (Handle -> a -> IO ()) -> Handle -> SinkIO m a sinkHandleWith f h = repeatedly $ await >>= liftIO . f h filteredIO :: (a -> IO Bool) -> ProcessT IO a a