packages feed

conduit 1.2.8 → 1.2.9

raw patch · 5 files changed

+44/−6 lines, 5 filesdep +splitPVP ok

version bump matches the API change (PVP)

Dependencies added: split

API changes (from Hackage documentation)

+ Data.Conduit.List: chunksOf :: Monad m => Int -> Conduit a m [a]

Files

ChangeLog.md view
@@ -1,3 +1,7 @@+## 1.2.9++* `chunksOf` [#296](https://github.com/snoyberg/conduit/pull/296)+ ## 1.2.8  * Implement
Data/Conduit/Internal/Conduit.hs view
@@ -931,7 +931,7 @@ {-# INLINE yieldOr #-}  -- | Wait for input forever, calling the given inner component for each piece of--- new input. Returns the upstream result type.+-- new input. -- -- This function is provided as a convenience for the common pattern of -- @await@ing input, checking if it's @Just@ and then looping.
Data/Conduit/List.hs view
@@ -50,6 +50,7 @@     , scanl     , scan     , mapAccum+    , chunksOf     , groupBy     , groupOn1     , isolate@@ -80,6 +81,7 @@     , Enum, Eq     , maybe     , (<=)+    , (>)     ) import Data.Monoid (Monoid, mempty, mappend) import qualified Data.Foldable as F@@ -618,8 +620,7 @@ STREAMING(mapFoldableM, mapFoldableMC, mapFoldableMS, f)  -- | Consume all values from the stream and return as a list. Note that this--- will pull all values into memory. For a lazy variant, see--- "Data.Conduit.Lazy".+-- will pull all values into memory. -- -- Subject to fusion --@@ -631,6 +632,25 @@     loop front = await >>= maybe (return $ front []) (\x -> loop $ front . (x:)) {-# INLINE consumeC #-} STREAMING0(consume, consumeC, consumeS)++-- | Group a stream into chunks of a given size. The last chunk may contain+-- fewer than n elements.+--+-- Subject to fusion+--+-- Since 1.2.9+chunksOf :: Monad m => Int -> Conduit a m [a]+chunksOf n =+    start+  where+    start = await >>= maybe (return ()) (\x -> loop n (x:))++    loop !count rest =+        await >>= maybe (yield (rest [])) go+      where+        go y+            | count > 1 = loop (count - 1) (rest . (y:))+            | otherwise = yield (rest []) >> loop n (y:)  -- | Grouping input according to an equality function. --
conduit.cabal view
@@ -1,10 +1,16 @@ Name:                conduit-Version:             1.2.8+Version:             1.2.9 Synopsis:            Streaming data processing library. description:-    Hackage documentation generation is not reliable. For up to date documentation, please see: <http://www.stackage.org/package/conduit>.+    `conduit` is a solution to the streaming data problem, allowing for production,+    transformation, and consumption of streams of data in constant memory. It is an+    alternative to lazy I\/O which guarantees deterministic resource handling.     .-    @conduit@ is a solution to the streaming data problem, allowing for production, transformation, and consumption of streams of data in constant memory. It is an alternative to lazy I\/O which guarantees deterministic resource handling, and fits in the same general solution space as @enumerator@\/@iteratee@ and @pipes@. For a tutorial, please visit <https://www.fpcomplete.com/user/snoyberg/library-documentation/conduit-overview>.+    For more information about conduit in general, and how this package in+    particular fits into the ecosystem, see [the conduit+    homepage](https://github.com/snoyberg/conduit#readme).+    .+    Hackage documentation generation is not reliable. For up to date documentation, please see: <http://www.stackage.org/package/conduit>. License:             MIT License-file:        LICENSE Author:              Michael Snoyman@@ -58,6 +64,7 @@                    , containers                    , exceptions >= 0.6                    , safe+                   , split >= 0.2.0.0     if !impl(ghc>=7.9)         build-depends: void     ghc-options:     -Wall
test/main.hs view
@@ -16,6 +16,7 @@ import Control.Monad.Trans.Resource as C (runResourceT) import Data.Maybe   (fromMaybe,catMaybes,fromJust) import qualified Data.List as DL+import qualified Data.List.Split as DLS (chunksOf) import Control.Monad.ST (runST) import Data.Monoid import qualified Data.IORef as I@@ -234,6 +235,12 @@                     C.$$ CL.map (* 2)                     C.=$ CL.fold (+) 0             x `shouldBe` 2 * sum [1..10 :: Int]++        prop "chunksOf" $ equivToList+            (DLS.chunksOf 5 :: [Int]->[[Int]]) (CL.chunksOf 5)++        prop "chunksOf (negative)" $ equivToList+            (map (:[]) :: [Int]->[[Int]]) (CL.chunksOf (-5))          it "groupBy" $ do             let input = [1::Int, 1, 2, 3, 3, 3, 4, 5, 5]