packages feed

io-streams 1.3.2.0 → 1.3.3.0

raw patch · 4 files changed

+66/−2 lines, 4 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

- System.IO.Streams.ByteString: instance Exception RateTooSlowException
- System.IO.Streams.ByteString: instance Exception ReadTooShortException
- System.IO.Streams.ByteString: instance Exception TooFewBytesWrittenException
- System.IO.Streams.ByteString: instance Exception TooManyBytesReadException
- System.IO.Streams.ByteString: instance Exception TooManyBytesWrittenException
- System.IO.Streams.ByteString: instance Show RateTooSlowException
- System.IO.Streams.ByteString: instance Show ReadTooShortException
- System.IO.Streams.ByteString: instance Show TooFewBytesWrittenException
- System.IO.Streams.ByteString: instance Show TooManyBytesReadException
- System.IO.Streams.ByteString: instance Show TooManyBytesWrittenException
- System.IO.Streams.ByteString: instance Typeable RateTooSlowException
- System.IO.Streams.ByteString: instance Typeable ReadTooShortException
- System.IO.Streams.ByteString: instance Typeable TooFewBytesWrittenException
- System.IO.Streams.ByteString: instance Typeable TooManyBytesReadException
- System.IO.Streams.ByteString: instance Typeable TooManyBytesWrittenException
- System.IO.Streams.Internal: _read :: InputStream a -> IO (Maybe a)
- System.IO.Streams.Internal: _unRead :: InputStream a -> a -> IO ()
- System.IO.Streams.Internal: _write :: OutputStream a -> Maybe a -> IO ()
- System.IO.Streams.Internal: instance Applicative (Consumer r)
- System.IO.Streams.Internal: instance Applicative (Generator r)
- System.IO.Streams.Internal: instance BufferedIO (InputStream ByteString)
- System.IO.Streams.Internal: instance BufferedIO (OutputStream ByteString)
- System.IO.Streams.Internal: instance BufferedIO (StreamPair ByteString)
- System.IO.Streams.Internal: instance Functor (Consumer r)
- System.IO.Streams.Internal: instance Functor (Generator r)
- System.IO.Streams.Internal: instance IODevice (InputStream ByteString)
- System.IO.Streams.Internal: instance IODevice (OutputStream ByteString)
- System.IO.Streams.Internal: instance IODevice (StreamPair ByteString)
- System.IO.Streams.Internal: instance Monad (Consumer c)
- System.IO.Streams.Internal: instance Monad (Generator r)
- System.IO.Streams.Internal: instance MonadIO (Consumer c)
- System.IO.Streams.Internal: instance MonadIO (Generator r)
- System.IO.Streams.Internal: instance RawIO (InputStream ByteString)
- System.IO.Streams.Internal: instance RawIO (OutputStream ByteString)
- System.IO.Streams.Internal: instance RawIO (StreamPair ByteString)
- System.IO.Streams.Internal: instance Typeable Consumer
- System.IO.Streams.Internal: instance Typeable Generator
- System.IO.Streams.Internal: instance Typeable InputStream
- System.IO.Streams.Internal: instance Typeable OutputStream
- System.IO.Streams.Internal: instance Typeable SP
- System.IO.Streams.Zlib: instance Eq CompressionLevel
- System.IO.Streams.Zlib: instance Num CompressionLevel
- System.IO.Streams.Zlib: instance Read CompressionLevel
- System.IO.Streams.Zlib: instance Show CompressionLevel
+ System.IO.Streams.ByteString: instance GHC.Exception.Exception System.IO.Streams.ByteString.RateTooSlowException
+ System.IO.Streams.ByteString: instance GHC.Exception.Exception System.IO.Streams.ByteString.ReadTooShortException
+ System.IO.Streams.ByteString: instance GHC.Exception.Exception System.IO.Streams.ByteString.TooFewBytesWrittenException
+ System.IO.Streams.ByteString: instance GHC.Exception.Exception System.IO.Streams.ByteString.TooManyBytesReadException
+ System.IO.Streams.ByteString: instance GHC.Exception.Exception System.IO.Streams.ByteString.TooManyBytesWrittenException
+ System.IO.Streams.ByteString: instance GHC.Show.Show System.IO.Streams.ByteString.RateTooSlowException
+ System.IO.Streams.ByteString: instance GHC.Show.Show System.IO.Streams.ByteString.ReadTooShortException
+ System.IO.Streams.ByteString: instance GHC.Show.Show System.IO.Streams.ByteString.TooFewBytesWrittenException
+ System.IO.Streams.ByteString: instance GHC.Show.Show System.IO.Streams.ByteString.TooManyBytesReadException
+ System.IO.Streams.ByteString: instance GHC.Show.Show System.IO.Streams.ByteString.TooManyBytesWrittenException
+ System.IO.Streams.Internal: [_read] :: InputStream a -> IO (Maybe a)
+ System.IO.Streams.Internal: [_unRead] :: InputStream a -> a -> IO ()
+ System.IO.Streams.Internal: [_write] :: OutputStream a -> Maybe a -> IO ()
+ System.IO.Streams.Internal: instance Control.Monad.IO.Class.MonadIO (System.IO.Streams.Internal.Consumer c)
+ System.IO.Streams.Internal: instance Control.Monad.IO.Class.MonadIO (System.IO.Streams.Internal.Generator r)
+ System.IO.Streams.Internal: instance GHC.Base.Applicative (System.IO.Streams.Internal.Consumer r)
+ System.IO.Streams.Internal: instance GHC.Base.Applicative (System.IO.Streams.Internal.Generator r)
+ System.IO.Streams.Internal: instance GHC.Base.Functor (System.IO.Streams.Internal.Consumer r)
+ System.IO.Streams.Internal: instance GHC.Base.Functor (System.IO.Streams.Internal.Generator r)
+ System.IO.Streams.Internal: instance GHC.Base.Monad (System.IO.Streams.Internal.Consumer c)
+ System.IO.Streams.Internal: instance GHC.Base.Monad (System.IO.Streams.Internal.Generator r)
+ System.IO.Streams.Internal: instance GHC.IO.BufferedIO.BufferedIO (System.IO.Streams.Internal.InputStream Data.ByteString.Internal.ByteString)
+ System.IO.Streams.Internal: instance GHC.IO.BufferedIO.BufferedIO (System.IO.Streams.Internal.OutputStream Data.ByteString.Internal.ByteString)
+ System.IO.Streams.Internal: instance GHC.IO.BufferedIO.BufferedIO (System.IO.Streams.Internal.StreamPair Data.ByteString.Internal.ByteString)
+ System.IO.Streams.Internal: instance GHC.IO.Device.IODevice (System.IO.Streams.Internal.InputStream Data.ByteString.Internal.ByteString)
+ System.IO.Streams.Internal: instance GHC.IO.Device.IODevice (System.IO.Streams.Internal.OutputStream Data.ByteString.Internal.ByteString)
+ System.IO.Streams.Internal: instance GHC.IO.Device.IODevice (System.IO.Streams.Internal.StreamPair Data.ByteString.Internal.ByteString)
+ System.IO.Streams.Internal: instance GHC.IO.Device.RawIO (System.IO.Streams.Internal.InputStream Data.ByteString.Internal.ByteString)
+ System.IO.Streams.Internal: instance GHC.IO.Device.RawIO (System.IO.Streams.Internal.OutputStream Data.ByteString.Internal.ByteString)
+ System.IO.Streams.Internal: instance GHC.IO.Device.RawIO (System.IO.Streams.Internal.StreamPair Data.ByteString.Internal.ByteString)
+ System.IO.Streams.List: chunkListWith :: (a -> Int -> Bool) -> InputStream a -> IO (InputStream [a])
+ System.IO.Streams.Zlib: instance GHC.Classes.Eq System.IO.Streams.Zlib.CompressionLevel
+ System.IO.Streams.Zlib: instance GHC.Num.Num System.IO.Streams.Zlib.CompressionLevel
+ System.IO.Streams.Zlib: instance GHC.Read.Read System.IO.Streams.Zlib.CompressionLevel
+ System.IO.Streams.Zlib: instance GHC.Show.Show System.IO.Streams.Zlib.CompressionLevel
- System.IO.Streams.Combinators: maximum :: Ord a => InputStream a -> IO (Maybe a)
+ System.IO.Streams.Combinators: maximum :: (Ord a) => InputStream a -> IO (Maybe a)
- System.IO.Streams.Combinators: minimum :: Ord a => InputStream a -> IO (Maybe a)
+ System.IO.Streams.Combinators: minimum :: (Ord a) => InputStream a -> IO (Maybe a)

Files

changelog.md view
@@ -1,3 +1,10 @@+# Version 1.3.3.0+  - Added a new convenience function, like `chunkList` but with a predicate for+    when to split, taking current element and current chunk length:+    ```haskell+chunkListWith :: (a -> Int -> Bool) -> InputStream a -> IO (InputStream [a])+    ```+ # Version 1.3.2.0   - Dependency bump for attoparsec 0.13 (another location)   - Dependency bump for vector 0.11
io-streams.cabal view
@@ -1,5 +1,5 @@ Name:                io-streams-Version:             1.3.2.0+Version:             1.3.3.0 License:             BSD3 License-file:        LICENSE Category:            Data, Network, IO-Streams
src/System/IO/Streams/List.hs view
@@ -11,6 +11,7 @@     -- * Utility  , chunkList+ , chunkListWith  , concatLists  , listOutputStream  ) where@@ -154,6 +155,38 @@         finish  = let l = dl []                   in if null l then return $! () else yield l         chunk x = go (k - 1) (dl . (x:))+++------------------------------------------------------------------------------+-- | Splits an input stream into chunks whenever @p elt count@ returns true.+--+-- Example:+--+-- @+-- ghci> 'fromList' [1..14::Int] >>= 'chunkListWith' (\x n -> n>=4) >>= 'toList'+-- [[1,2,3,4],[5,6,7,8],[9,10,11,12],[13,14]]+-- ghci> 'fromList' ['a'..'z'] >>= 'chunkListWith' (\x n -> n>=4 && x `elem` "aeiouy") >>= 'toList'+-- ["abcde","fghi","jklmno","pqrstu","vwxy","z"]+-- @+--+-- /Since: 1.3.3.0./+chunkListWith :: (a -> Int -> Bool)    -- ^ break predicate+              -> InputStream a         -- ^ stream to process+              -> IO (InputStream [a])+chunkListWith p input =+  fromGenerator $ go Nothing 0 id+  where+    go v !k dl+      | Just x <- v, p x k = yield (dl []) >> go Nothing 0 id+      | otherwise = do+          liftIO (read input) >>= maybe finish chunk+      where+        finish =+          let l = dl []+          in if null l+               then return $! ()+               else yield l+        chunk x = go (Just x) (k + 1) (dl . (x :))   ------------------------------------------------------------------------------
test/System/IO/Streams/Tests/List.hs view
@@ -14,9 +14,10 @@ import           System.IO.Streams.Tests.Common (expectExceptionH)  tests :: [Test]-tests = [ testChunkJoin ]+tests = [ testChunkJoin, testChunkWithJoin ]  + testChunkJoin :: Test testChunkJoin = testCase "list/chunkList and join" $ do     expectExceptionH (fromList [1..10::Int] >>= chunkList 0 >>= toList)@@ -32,3 +33,26 @@                             >>= concatLists                             >>= toList                             >>= assertEqual "concatlists" [1..12]++testChunkWithJoin :: Test+testChunkWithJoin = testCase "list/chunkListWith and join" $ do+    fromList [1..10 :: Int] >>= chunkListWith (\_ n -> n>=3)+                            >>= toList+                            >>= assertEqual "chunkListWith" [ [1,2,3]+                                                        , [4,5,6]+                                                        , [7,8,9]+                                                        , [10]+                                                        ]+    fromList [1..12 :: Int] >>= chunkListWith (\_ n -> n>=3)+                            >>= concatLists+                            >>= toList+                            >>= assertEqual "concatlists" [1..12]++    fromList ['a'..'z' :: Char] >>= chunkListWith (\x n -> n>=4 && x `elem` "aeiouy")+                            >>= toList+                            >>= assertEqual "chunkListWith" ["abcde"+                                                            ,"fghi"+                                                            ,"jklmno"+                                                            ,"pqrstu"+                                                            ,"vwxy"+                                                            ,"z"]