packages feed

conduit 1.1.6 → 1.1.7

raw patch · 3 files changed

+46/−1 lines, 3 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Data.Conduit.List: groupOn1 :: (Monad m, Eq b) => (a -> b) -> Conduit a m (a, [a])

Files

Data/Conduit/List.hs view
@@ -43,6 +43,7 @@     , scan     , mapAccum     , groupBy+    , groupOn1     , isolate     , filter       -- ** Monadic@@ -467,6 +468,35 @@         go y             | f x y     = loop (rest . (y:)) x             | otherwise = yield (x : rest []) >> loop id y+++-- | 'groupOn1' is similar to @groupBy id@+--+-- returns a pair, indicating there are always 1 or more items in the grouping.+-- This is designed to be converted into a NonEmpty structure+-- but it avoids a dependency on another package+--+-- > import Data.List.NonEmpty+-- >+-- > groupOn1 :: (Monad m, Eq b) => (a -> b) -> Conduit a m (NonEmpty a)+-- > groupOn1 f = CL.groupOn1 f =$= CL.map (uncurry (:|))+--+-- Since 1.1.7+groupOn1 :: (Monad m, Eq b)+         => (a -> b)+         -> Conduit a m (a, [a])+groupOn1 f =+    start+  where+    start = await >>= maybe (return ()) (loop id)++    loop rest x =+        await >>= maybe (yield (x, rest [])) go+      where+        go y+            | f x == f y = loop (rest . (y:)) x+            | otherwise  = yield (x, rest []) >> loop id y+  -- | Ensure that the inner sink consumes no more than the given number of -- values. Note this this does /not/ ensure that the sink consumes all of those
conduit.cabal view
@@ -1,5 +1,5 @@ Name:                conduit-Version:             1.1.6+Version:             1.1.7 Synopsis:            Streaming data processing library. Description:     @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://haskell.fpcomplete.com/user/snoyberg/library-documentation/conduit-overview>.
test/main.hs view
@@ -245,6 +245,21 @@                     C.=$ CL.consume             x `shouldBe` DL.groupBy (==) input +        it "groupOn1" $ do+            let input = [1::Int, 1, 2, 3, 3, 3, 4, 5, 5]+            x <- runResourceT $ CL.sourceList input+                    C.$$ CL.groupOn1 id+                    C.=$ CL.consume+            x `shouldBe` [(1,[1]), (2, []), (3,[3,3]), (4,[]), (5, [5])]++        it "groupOn1 (nondup begin/end)" $ do+            let input = [1::Int, 2, 3, 3, 3, 4, 5]+            x <- runResourceT $ CL.sourceList input+                    C.$$ CL.groupOn1 id+                    C.=$ CL.consume+            x `shouldBe` [(1,[]), (2, []), (3,[3,3]), (4,[]), (5, [])]++         it "mapMaybe" $ do             let input = [Just (1::Int), Nothing, Just 2, Nothing, Just 3]             x <- runResourceT $ CL.sourceList input