io-streams 1.5.1.0 → 1.5.2.0
raw patch · 7 files changed
+104/−19 lines, 7 filesdep ~bytestringPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: bytestring
API changes (from Hackage documentation)
+ System.IO.Streams.Combinators: contraunzip :: OutputStream a -> OutputStream b -> IO (OutputStream (a, b))
Files
- CONTRIBUTORS +1/−0
- changelog.md +6/−0
- io-streams.cabal +42/−19
- src/System/IO/Streams.hs +9/−0
- src/System/IO/Streams/Combinators.hs +15/−0
- test/System/IO/Streams/Tests/Combinators.hs +21/−0
- test/TestSuite.hs +10/−0
CONTRIBUTORS view
@@ -3,6 +3,7 @@ - Gregory Collins <greg@gregorycollins.net> - Gabriel Gonzalez <gabriel439@gmail.com>+ - Ignat Insarov <kindaro@gmail.com> ------------------------------------------------------------------------------ Contains some code ported from the "blaze-builder-enumerator" package by Simon
changelog.md view
@@ -1,3 +1,9 @@+# Version 1.5.2.0+- Add `contraunzip`.++- Guard support for `network` and `zlib` by cabal flags, to support platforms+ like GHCJS where they are not available.+ # Version 1.5.1.0 Fix [stackage#4312](https://github.com/commercialhaskell/stackage/issues/4312): Relax `network` upper bound
io-streams.cabal view
@@ -1,5 +1,5 @@ Name: io-streams-Version: 1.5.1.0+Version: 1.5.2.0 License: BSD3 License-file: LICENSE Category: Data, Network, IO-Streams@@ -8,7 +8,9 @@ Cabal-version: >= 1.10 Synopsis: Simple, composable, and easy-to-use stream I/O Tested-With: GHC==7.4.2, GHC==7.6.3, GHC==7.8.4, GHC==7.10.3,- GHC==8.0.2, GHC==8.2.2, GHC==8.4.3, GHC==8.6.3+ GHC==8.0.2, GHC==8.2.2, GHC==8.4.3, GHC==8.6.3,+ GHC==8.8.3, GHC==8.10.1+ Bug-Reports: https://github.com/snapframework/io-streams/issues Description: /Overview/@@ -85,6 +87,16 @@ Description: Do not run interactive tests Default: False +Flag Zlib+ Description: Include zlib support+ Default: True+ Manual: True++Flag Network+ Description: Include network support+ Default: True+ Manual: True+ ------------------------------------------------------------------------------ Library hs-source-dirs: src@@ -106,34 +118,40 @@ System.IO.Streams.Handle, System.IO.Streams.File, System.IO.Streams.List,- System.IO.Streams.Network, System.IO.Streams.Process, System.IO.Streams.Text, System.IO.Streams.Vector,- System.IO.Streams.Zlib, System.IO.Streams.Internal, System.IO.Streams.Tutorial Other-modules: System.IO.Streams.Internal.Attoparsec,- System.IO.Streams.Internal.Network, System.IO.Streams.Internal.Search Build-depends: base >= 4 && <5, attoparsec >= 0.10 && <0.14, bytestring >= 0.9 && <0.11, bytestring-builder >= 0.10 && <0.11,- network >= 2.3 && <3.1,- primitive >= 0.2 && <0.7,+ primitive >= 0.2 && <0.8, process >= 1.1 && <1.7, text >= 0.10 && <1.3, time >= 1.2 && <1.10, transformers >= 0.2 && <0.6,- vector >= 0.7 && <0.13,- zlib-bindings >= 0.1 && <0.2+ vector >= 0.7 && <0.13 if impl(ghc >= 7.2) other-extensions: Trustworthy + if flag(Zlib)+ Exposed-modules: System.IO.Streams.Zlib+ Build-depends: zlib-bindings >= 0.1 && <0.2+ cpp-options: -DENABLE_ZLIB++ if flag(Network)+ Exposed-modules: System.IO.Streams.Network+ Other-modules: System.IO.Streams.Internal.Network+ Build-depends: network >= 2.3 && <3.2+ cpp-options: -DENABLE_NETWORK+ other-extensions: BangPatterns, CPP,@@ -166,11 +184,9 @@ System.IO.Streams.Tests.Handle, System.IO.Streams.Tests.Internal, System.IO.Streams.Tests.List,- System.IO.Streams.Tests.Network, System.IO.Streams.Tests.Process, System.IO.Streams.Tests.Text, System.IO.Streams.Tests.Vector,- System.IO.Streams.Tests.Zlib, System.IO.Streams, System.IO.Streams.Attoparsec.ByteString, System.IO.Streams.Attoparsec.Text,@@ -183,24 +199,34 @@ System.IO.Streams.Handle, System.IO.Streams.File, System.IO.Streams.List,- System.IO.Streams.Network, System.IO.Streams.Process, System.IO.Streams.Text, System.IO.Streams.Vector,- System.IO.Streams.Zlib, System.IO.Streams.Internal, System.IO.Streams.Internal.Attoparsec,- System.IO.Streams.Internal.Network, System.IO.Streams.Internal.Search ghc-options: -Wall -fwarn-tabs -funbox-strict-fields -threaded -fno-warn-unused-do-bind- ghc-prof-options: -auto-all if !os(windows) && !flag(NoInteractiveTests) cpp-options: -DENABLE_PROCESS_TESTS + if flag(Zlib)+ Other-modules: System.IO.Streams.Tests.Zlib,+ System.IO.Streams.Zlib+ Build-depends: zlib-bindings,+ zlib >= 0.5 && <0.7+ cpp-options: -DENABLE_ZLIB++ if flag(Network)+ Other-modules: System.IO.Streams.Internal.Network,+ System.IO.Streams.Network,+ System.IO.Streams.Tests.Network+ Build-depends: network+ cpp-options: -DENABLE_NETWORK+ Build-depends: base, attoparsec, bytestring,@@ -209,21 +235,18 @@ directory >= 1.1 && <2, filepath >= 1.2 && <2, mtl >= 2 && <3,- network, primitive, process, text, time, transformers, vector,- zlib-bindings, HUnit >= 1.2 && <2, QuickCheck >= 2.3.0.2 && <3, test-framework >= 0.6 && <0.9, test-framework-hunit >= 0.2.7 && <0.4,- test-framework-quickcheck2 >= 0.2.12.1 && <0.4,- zlib >= 0.5 && <0.7+ test-framework-quickcheck2 >= 0.2.12.1 && <0.4 if impl(ghc >= 7.2) other-extensions: Trustworthy
src/System/IO/Streams.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE CPP #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE OverloadedStrings #-} @@ -66,11 +67,15 @@ , module System.IO.Streams.Handle , module System.IO.Streams.File , module System.IO.Streams.List+#ifdef ENABLE_NETWORK , module System.IO.Streams.Network+#endif , module System.IO.Streams.Process , module System.IO.Streams.Text , module System.IO.Streams.Vector+#ifdef ENABLE_ZLIB , module System.IO.Streams.Zlib+#endif ) where ------------------------------------------------------------------------------@@ -85,11 +90,15 @@ import System.IO.Streams.File import System.IO.Streams.Handle import System.IO.Streams.List+#ifdef ENABLE_NETWORK import System.IO.Streams.Network+#endif import System.IO.Streams.Process import System.IO.Streams.Text import System.IO.Streams.Vector+#ifdef ENABLE_ZLIB import System.IO.Streams.Zlib+#endif ------------------------------------------------------------------------------ -- $generator
src/System/IO/Streams/Combinators.hs view
@@ -47,6 +47,7 @@ , zipWith , zipWithM , unzip+ , contraunzip -- * Utility , intersperse@@ -748,6 +749,20 @@ let (a, b) = proj x modifyIORef buf (. (b:)) return $! Just a)+++------------------------------------------------------------------------------+-- | Given two 'OutputStream's, returns a new stream that "unzips" the tuples+-- being written, writing the two elements to the corresponding given streams.+--+-- You can use this together with @'contramap' (\\ x -> (x, x))@ to "fork" a+-- stream into two.+--+-- /Since: 1.5.2.0/+contraunzip :: OutputStream a -> OutputStream b -> IO (OutputStream (a, b))+contraunzip sink1 sink2 = makeOutputStream $ \ tuple -> do+ write (fmap fst tuple) sink1+ write (fmap snd tuple) sink2 ------------------------------------------------------------------------------
test/System/IO/Streams/Tests/Combinators.hs view
@@ -56,6 +56,7 @@ , testZipWith , testZipWithM , testUnzip+ , testContraunzip , testTake , testDrop , testGive@@ -358,6 +359,26 @@ toList is3 >>= assertEqual "unzip2-a" (fst $ Prelude.unzip l) read is4 >>= assertEqual "unzip2-read-b" Nothing read is3 >>= assertEqual "unzip2-read" Nothing+++------------------------------------------------------------------------------+testContraunzip :: Test+testContraunzip = testProperty "combinators/contrazip" $ monadicIO $ forAllM arbitrary prop+ where+ prop :: [Int] -> PropertyM IO ( )+ prop xs = liftQ $ do+ let ys = fmap show xs+ xsStream <- fromList xs+ ysStream <- fromList ys+ (xsSink, getXs') <- listOutputStream+ (ysSink, getYs') <- listOutputStream+ xysStream <- zip xsStream ysStream+ xysSink <- contraunzip xsSink ysSink+ connect xysStream xysSink+ xs' <- getXs'+ ys' <- getYs'+ assertEqual "numbers" xs xs'+ assertEqual "strings" ys ys' ------------------------------------------------------------------------------
test/TestSuite.hs view
@@ -1,3 +1,5 @@+{-# LANGUAGE CPP #-}+ module Main where import qualified System.IO.Streams.Tests.Attoparsec.ByteString as AttoparsecByteString@@ -11,11 +13,15 @@ import qualified System.IO.Streams.Tests.Handle as Handle import qualified System.IO.Streams.Tests.Internal as Internal import qualified System.IO.Streams.Tests.List as List+#ifdef ENABLE_NETWORK import qualified System.IO.Streams.Tests.Network as Network+#endif import qualified System.IO.Streams.Tests.Process as Process import qualified System.IO.Streams.Tests.Text as Text import qualified System.IO.Streams.Tests.Vector as Vector+#ifdef ENABLE_ZLIB import qualified System.IO.Streams.Tests.Zlib as Zlib+#endif import Test.Framework (defaultMain, testGroup) @@ -34,9 +40,13 @@ , testGroup "Tests.Handle" Handle.tests , testGroup "Tests.Internal" Internal.tests , testGroup "Tests.List" List.tests+#ifdef ENABLE_NETWORK , testGroup "Tests.Network" Network.tests+#endif , testGroup "Tests.Process" Process.tests , testGroup "Tests.Text" Text.tests , testGroup "Tests.Vector" Vector.tests+#ifdef ENABLE_ZLIB , testGroup "Tests.Zlib" Zlib.tests+#endif ]