packages feed

io-streams 1.0.0.1 → 1.0.1.0

raw patch · 3 files changed

+55/−13 lines, 3 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ System.IO.Streams.Combinators: ignoreEof :: OutputStream a -> IO (OutputStream a)

Files

io-streams.cabal view
@@ -1,5 +1,5 @@ Name:                io-streams-Version:             1.0.0.1+Version:             1.0.1.0 License:             BSD3 License-file:        LICENSE Category:            Data, Network, IO-Streams@@ -75,6 +75,12 @@       bytestring builders, folds, maps, filters, zips, etc.   .     * support for parsing from streams using @attoparsec@.+  .+  /ChangeLog/+  .+    [@1.0.1.0@] Added 'System.IO.Streams.Combinators.ignoreEof'.+  .+    [@1.0.0.1@] Fixed some haddock markup.  Extra-Source-Files:  CONTRIBUTORS README.md 
src/System/IO/Streams/Combinators.hs view
@@ -46,6 +46,7 @@    -- * Utility  , intersperse  , skipToEof+ , ignoreEof  ) where  ------------------------------------------------------------------------------@@ -55,15 +56,17 @@ import           Data.Int                   (Int64) import           Data.IORef                 (atomicModifyIORef, modifyIORef,                                              newIORef, readIORef, writeIORef)-import           Prelude                    hiding (all, any, drop, filter, map,-                                             mapM, mapM_, maximum, minimum,-                                             read, take, unzip, zip, zipWith)+import           Prelude                    hiding (all, any, drop, filter,+                                             map, mapM, mapM_, maximum,+                                             minimum, read, take, unzip, zip,+                                             zipWith) -------------------------------------------------------------------------------import           System.IO.Streams.Internal (InputStream, OutputStream, SP (..),-                                             Source (..), fromGenerator,-                                             makeInputStream, makeOutputStream,-                                             read, sourceToStream, unRead,-                                             write, yield)+import           System.IO.Streams.Internal (InputStream, OutputStream,+                                             SP (..), Source (..),+                                             fromGenerator, makeInputStream,+                                             makeOutputStream, read,+                                             sourceToStream, unRead, write,+                                             yield)  ------------------------------------------------------------------------------ -- | A side-effecting fold over an 'OutputStream', as a stream transformer.@@ -761,3 +764,16 @@                     if n > 0                       then writeIORef ref $! n - 1                       else write (Just x) output+++------------------------------------------------------------------------------+-- | Wraps an 'OutputStream', ignoring any end-of-stream 'Nothing' values+-- written to the returned stream.+--+-- Since: 1.0.1.0+--+ignoreEof :: OutputStream a -> IO (OutputStream a)+ignoreEof s = makeOutputStream f+  where+    f Nothing  = return $! ()+    f x        = write x s
test/System/IO/Streams/Tests/Combinators.hs view
@@ -15,11 +15,12 @@                                                        take, unzip, zip,                                                        zipWith) import           Prelude                              hiding (drop, filter,-                                                       mapM, mapM_, read, take,-                                                       unzip, zip, zipWith)+                                                       mapM, mapM_, read,+                                                       take, unzip, zip,+                                                       zipWith) import qualified Prelude-import           System.IO.Streams                    hiding (all, any, maximum,-                                                       minimum)+import           System.IO.Streams                    hiding (all, any,+                                                       maximum, minimum) import qualified System.IO.Streams                    as S import           Test.Framework import           Test.Framework.Providers.HUnit@@ -55,6 +56,7 @@         , testDrop         , testGive         , testIgnore+        , testIgnoreEof         ]  @@ -395,3 +397,21 @@              outputToList (\os -> ignore n os >>= connect is) >>=              assertEqual ("ignore" ++ show n)                          (Prelude.drop (fromEnum n) [1..10])+++------------------------------------------------------------------------------+testIgnoreEof :: Test+testIgnoreEof = testCase "combinators/ignoreEof" $ do+    eofRef   <- newIORef 0+    chunkRef <- newIORef []+    str0 <- S.makeOutputStream $ f eofRef chunkRef+    str  <- S.ignoreEof str0+    S.write (Just 0) str+    S.write Nothing str++    readIORef eofRef >>= assertEqual "eof ignored" (0::Int)+    readIORef chunkRef >>= assertEqual "input propagated" [0::Int]++  where+    f ref _ Nothing    = modifyIORef ref (+1)+    f _ chunk (Just x) = modifyIORef chunk (++ [x])