conduit-algorithms 0.0.3.0 → 0.0.4.0
raw patch · 6 files changed
+46/−4 lines, 6 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- ChangeLog +3/−0
- Data/Conduit/Algorithms.hs +4/−3
- Data/Conduit/Algorithms/Tests.hs +31/−0
- Data/Conduit/Algorithms/Utils.hs +2/−0
- README.md +5/−0
- conduit-algorithms.cabal +1/−1
ChangeLog view
@@ -1,3 +1,6 @@+Version 0.0.4.0 2017-09-12 by luispedro+ * Fix bug in merge* conduits+ Version 0.0.3.0 2017-08-30 by luispedro * Much improved mergeC2 function * Add removeRepeatsC conduit
Data/Conduit/Algorithms.hs view
@@ -94,8 +94,9 @@ go right@(CI.HaveOutput s1' f1 v1) left@(CI.HaveOutput s2' f2 v2) | compare v1 v2 /= GT = CI.HaveOutput (go s1' left) (f1 >> f2) v1 | otherwise = CI.HaveOutput (go right s2') (f1 >> f2) v2- go right CI.Done{} = right- go CI.Done{} left = left+ go right@CI.Done{} (CI.HaveOutput s f v) = CI.HaveOutput (go right s) f v+ go (CI.HaveOutput s f v) left@CI.Done{} = CI.HaveOutput (go s left) f v+ go CI.Done{} CI.Done{} = rest () go (CI.PipeM p) left = do next <- lift p go next left@@ -106,5 +107,5 @@ go right (CI.NeedInput _ next) = go right (next ()) go (CI.Leftover next ()) left = go next left go right (CI.Leftover next ()) = go right next- in go (s1 rest) (s2 rest)+ in go (s1 CI.Done) (s2 CI.Done)
Data/Conduit/Algorithms/Tests.hs view
@@ -9,8 +9,11 @@ import Test.Framework.Providers.HUnit import qualified Data.ByteString as B+import qualified Data.ByteString.Char8 as B8 import qualified Data.Conduit as C import qualified Data.Conduit.Combinators as CC+import qualified Data.Conduit.Binary as CB+import qualified Data.Conduit.List as CL import Data.Conduit ((.|)) import Data.List (sort) import System.Directory (removeFile)@@ -24,12 +27,17 @@ testingFileNameGZ :: FilePath testingFileNameGZ = "file_just_for_testing_delete_me_please.gz"+testingFileNameGZ2 :: FilePath+testingFileNameGZ2 = "file_just_for_testing_delete_me_please_2.gz" extract c = C.runConduitPure (c .| CC.sinkList) extractIO c = C.runConduitRes (c .| CC.sinkList) shouldProduce values cond = extract cond @?= values+shouldProduceIO values cond = do+ p <- extractIO cond+ p @?= values case_uniqueC = extract (CC.yieldMany [1,2,3,1,1,2,3] .| CAlg.uniqueC) @=? [1,2,3 :: Int] case_mergeC = shouldProduce expected $@@ -54,6 +62,13 @@ (CC.yieldMany [0, 1, 2]) (CC.yieldMany [0, 1, 2]) +case_mergeC2monad = shouldProduce [0, 1, 2, 2, 3, 4 :: Int] $ do+ CAlg.mergeC2+ (CC.yieldMany [0, 2])+ (CC.yieldMany [1, 2])+ CC.yieldMany [3]+ CC.yieldMany [4]+ case_groupC = shouldProduce [[0,1,2], [3,4,5], [6,7,8], [9, 10 :: Int]] $ CC.yieldMany [0..10] .| CAlg.groupC 3 @@ -72,3 +87,19 @@ r @?= "Hello World" removeFile testingFileNameGZ ++case_async_gzip_to_from = do+ let testdata = [0 :: Int .. 12]+ C.runConduitRes $+ CC.yieldMany testdata+ .| CL.map (B8.pack . (\n -> show n ++ "\n"))+ .| CAlg.asyncGzipToFile testingFileNameGZ+ C.runConduitRes $+ CAlg.asyncGzipFromFile testingFileNameGZ+ .| CAlg.asyncGzipToFile testingFileNameGZ2+ shouldProduceIO testdata $+ CAlg.asyncGzipFromFile testingFileNameGZ2+ .| CB.lines+ .| CL.map (read . B8.unpack)+ removeFile testingFileNameGZ+ removeFile testingFileNameGZ2
Data/Conduit/Algorithms/Utils.hs view
@@ -40,6 +40,8 @@ -- @ -- -- results in @[ [0,1,2], [3,4,5], [6,7,8], [9, 10] ]@+--+-- This function is deprecated; use 'Data.Conduit.List.chunksOf' groupC :: (Monad m) => Int -> C.Conduit a m [a] groupC n = loop n [] where
README.md view
@@ -1,5 +1,10 @@ # Conduit Algorithms +[](https://hackage.haskell.org/package/conduit-algorithms)+[](http://packdeps.haskellers.com/feed?needle=conduit-algorithms)+[](https://travis-ci.org/luispedro/conduit-algorithms)++ Some conduit-based algorithms. Much of this code was originally part of [NGLess](http://ngless.embl.de) and
conduit-algorithms.cabal view
@@ -1,5 +1,5 @@ name: conduit-algorithms-version: 0.0.3.0+version: 0.0.4.0 synopsis: Conduit-based algorithms description: Algorithms on Conduits, including higher level asynchronous processing and some other utilities.