on master help sign in
Rename the resumable Unfold type to Producer
commit2a7e3ccdbc424aebb51eb3d1690aaee9c8513841 authorHarendra Kumar <harendra@composewell.com> dateWed 17 Feb 2021, 19:11 (6 years ago) parent7c95cca
9 files changed+119−116
benchmark/Streamly/Benchmark/Data/Parser.hs+6−6 benchmark/Streamly/Benchmark/Data/Parser/ParserD.hs+6−6 src/Streamly/Internal/Data/Array/Foreign.hs+6−6 src/Streamly/Internal/Data/Array/Foreign/Mut/Types.hs+8−8 src/Streamly/Internal/Data/Unfold/Resume.hs → src/Streamly/Internal/Data/Producer.hs+40−36 src/Streamly/Internal/Data/Unfold/Source.hs → src/Streamly/Internal/Data/Producer/Source.hs+11−8 src/Streamly/Internal/Data/Unfold/Resume/Type.hs → src/Streamly/Internal/Data/Producer/Type.hs+33−37 streamly.cabal+3−3 test/Streamly/Test/Data/Parser/ParserD.hs+6−6
benchmark/Streamly/Benchmark/Data/Parser.hs+6−6
@@ -39,8 +39,8 @@ import qualified Streamly.Internal.Data.Array.Foreign as Array
3939import qualified Streamly.Internal.Data.Fold as FL
4040import qualified Streamly.Internal.Data.Parser as PR
4141import qualified Streamly.Internal.Data.Stream.IsStream as IP
42−import qualified Streamly.Internal.Data.Unfold.Resume as UnfoldR
43−import qualified Streamly.Internal.Data.Unfold.Source as Source
42+import qualified Streamly.Internal.Data.Producer as Producer
43+import qualified Streamly.Internal.Data.Producer.Source as Source
4444
4545import Gauge hiding (env)
4646import Streamly.Prelude (SerialT)
@@ -245,13 +245,13 @@ parseManyChunksOfSum n inh =
245245{-# INLINE parseManyUnfoldArrays #-}
246246parseManyUnfoldArrays :: Int -> [Array.Array Int] -> IO ()
247247parseManyUnfoldArrays count arrays = do
248− let src = Source.source (Just (UnfoldR.OuterLoop arrays))
248+ let src = Source.source (Just (Producer.OuterLoop arrays))
249249 let parser = PR.fromFold (FL.takeLE count FL.drain)
250250 let readSrc =
251− Source.read
252− $ UnfoldR.concat UnfoldR.fromList Array.readResumable
251+ Source.producer
252+ $ Producer.concat Producer.fromList Array.producer
253253 let streamParser =
254− UnfoldR.simplify (UnfoldR.parseMany parser readSrc)
254+ Producer.simplify (Producer.parseMany parser readSrc)
255255 S.drain $ S.unfold streamParser src
256256
257257-------------------------------------------------------------------------------
benchmark/Streamly/Benchmark/Data/Parser/ParserD.hs+6−6
@@ -29,9 +29,9 @@ import qualified Streamly.Prelude as S
2929import qualified Streamly.Internal.Data.Array.Foreign as Array
3030import qualified Streamly.Internal.Data.Fold as FL
3131import qualified Streamly.Internal.Data.Parser.ParserD as PR
32+import qualified Streamly.Internal.Data.Producer as Producer
33+import qualified Streamly.Internal.Data.Producer.Source as Source
3234import qualified Streamly.Internal.Data.Stream.IsStream as IP
33−import qualified Streamly.Internal.Data.Unfold.Resume as UnfoldR
34−import qualified Streamly.Internal.Data.Unfold.Source as Source
3535
3636import Gauge
3737import Streamly.Prelude (SerialT, MonadAsync, IsStream)
@@ -219,13 +219,13 @@ parseManyGroupsRolling b =
219219{-# INLINE parseManyUnfoldArrays #-}
220220parseManyUnfoldArrays :: Int -> [Array.Array Int] -> IO ()
221221parseManyUnfoldArrays count arrays = do
222− let src = Source.source (Just (UnfoldR.OuterLoop arrays))
222+ let src = Source.source (Just (Producer.OuterLoop arrays))
223223 let parser = PR.fromFold (FL.takeLE count FL.drain)
224224 let readSrc =
225− Source.read
226− $ UnfoldR.concat UnfoldR.fromList Array.readResumable
225+ Source.producer
226+ $ Producer.concat Producer.fromList Array.producer
227227 let streamParser =
228− UnfoldR.simplify (UnfoldR.parseManyD parser readSrc)
228+ Producer.simplify (Producer.parseManyD parser readSrc)
229229 S.drain $ S.unfold streamParser src
230230
231231-------------------------------------------------------------------------------
src/Streamly/Internal/Data/Array/Foreign.hs+6−6
@@ -68,7 +68,7 @@ module Streamly.Internal.Data.Array.Foreign
6868 , A.toStream
6969 , A.toStreamRev
7070 , read
71− , readResumable
71+ , producer
7272 , unsafeRead
7373 , A.readRev
7474 -- , readChunksOf
@@ -160,6 +160,7 @@ import GHC.IO (IO(..))
160160
161161import Streamly.Internal.Data.Array.Foreign.Types (Array(..), length)
162162import Streamly.Internal.Data.Fold.Types (Fold(..))
163+import Streamly.Internal.Data.Producer.Type (Producer)
163164import Streamly.Internal.Data.Stream.Serial (SerialT)
164165import Streamly.Internal.Data.Tuple.Strict (Tuple3'(..))
165166import Streamly.Internal.Data.Unfold.Types (Unfold(..))
@@ -171,7 +172,7 @@ import qualified Streamly.Internal.Data.Stream.Prelude as P
171172import qualified Streamly.Internal.Data.Stream.Serial as Serial
172173import qualified Streamly.Internal.Data.Stream.StreamD as D
173174import qualified Streamly.Internal.Data.Unfold as Unfold
174−import qualified Streamly.Internal.Data.Unfold.Resume.Type as UnfoldR
175+import qualified Streamly.Internal.Data.Producer.Type as Producer
175176import qualified Streamly.Internal.Ring.Foreign as RB
176177
177178-------------------------------------------------------------------------------
@@ -214,10 +215,9 @@ fromStream = P.foldOnce A.write
214215read :: forall m a. (Monad m, Storable a) => Unfold m (Array a) a
215216read = Unfold.lmap A.unsafeThaw MA.read
216217
217−{-# INLINE_NORMAL readResumable #-}
218−readResumable :: forall m a. (Monad m, Storable a) =>
219− UnfoldR.Unfold m (Array a) a
220−readResumable = UnfoldR.lmap A.unsafeThaw A.unsafeFreeze MA.readResumable
218+{-# INLINE_NORMAL producer #-}
219+producer :: forall m a. (Monad m, Storable a) => Producer m (Array a) a
220+producer = Producer.translate A.unsafeThaw A.unsafeFreeze MA.producer
221221
222222-- | Unfold an array into a stream, does not check the end of the array, the
223223-- user is responsible for terminating the stream within the array bounds. For
src/Streamly/Internal/Data/Array/Foreign/Mut/Types.hs+8−8
@@ -78,7 +78,7 @@ module Streamly.Internal.Data.Array.Foreign.Mut.Types
7878 , ReadUState
7979 , read
8080 , readRev
81− , readResumable
81+ , producer
8282 , flattenArrays
8383 , flattenArraysRev
8484
@@ -136,8 +136,9 @@ import GHC.ForeignPtr (ForeignPtr(..))
136136import GHC.IO (IO(IO), unsafePerformIO)
137137import GHC.Ptr (Ptr(..))
138138import Streamly.Internal.Data.Fold.Types (Fold(..))
139−import Streamly.Internal.Data.Unfold.Types (Unfold(..))
139+import Streamly.Internal.Data.Producer.Type (Producer (..))
140140import Streamly.Internal.Data.SVar (adaptState)
141+import Streamly.Internal.Data.Unfold.Types (Unfold(..))
141142import Text.Read (readPrec, readListPrec, readListPrecDefault)
142143
143144#ifdef DEVBUILD
@@ -145,9 +146,9 @@ import qualified Data.Foldable as F
145146#endif
146147import qualified GHC.Exts as Exts
147148import qualified Streamly.Internal.Data.Fold.Types as FL
149+import qualified Streamly.Internal.Data.Producer as Producer
148150import qualified Streamly.Internal.Data.Stream.StreamD.Type as D
149151import qualified Streamly.Internal.Data.Stream.StreamK.Type as K
150−import qualified Streamly.Internal.Data.Unfold.Resume as UnfoldR
151152import qualified Streamly.Internal.Foreign.Malloc as Malloc
152153
153154import Prelude hiding (length, foldr, read, unlines, splitAt)
@@ -502,10 +503,9 @@ data ReadUState a = ReadUState
502503
503504-- | Resumable unfold of an array.
504505--
505−{-# INLINE_NORMAL readResumable #-}
506−readResumable :: forall m a. (Monad m, Storable a) =>
507− UnfoldR.Unfold m (Array a) a
508−readResumable = UnfoldR.Unfold step inject extract
506+{-# INLINE_NORMAL producer #-}
507+producer :: forall m a. (Monad m, Storable a) => Producer m (Array a) a
508+producer = Producer step inject extract
509509 where
510510
511511 inject (Array (ForeignPtr start contents) (Ptr end) _) =
@@ -534,7 +534,7 @@ readResumable = UnfoldR.Unfold step inject extract
534534-- @since 0.7.0
535535{-# INLINE_NORMAL read #-}
536536read :: forall m a. (Monad m, Storable a) => Unfold m (Array a) a
537−read = UnfoldR.simplify readResumable
537+read = Producer.simplify producer
538538
539539-- | Unfold an array into a stream in reverse order.
540540--
src/Streamly/Internal/Data/Unfold/Resume.hs → src/Streamly/Internal/Data/Producer.hsrenamed+40−36
@@ -1,31 +1,29 @@
11-- |
2−-- Module : Streamly.Internal.Data.Unfold.Resume
2+-- Module : Streamly.Internal.Data.Producer
33-- Copyright : (c) 2021 Composewell Technologies
44-- License : BSD-3-Clause
55-- Maintainer : streamly@composewell.com
66-- Stability : experimental
77-- Portability : GHC
88--
9−-- Unfolds in "Streamly.Internal.Data.Unfold" module run to completion, they
10−-- cannot be stopped and then resumed. In contrast, the unfolds in this module
11−-- allow extraction of the intermediate state which can be used to resume the
12−-- unfold later on.
9+-- A 'Producer' is an 'Unfold' with an 'extract' function added to to extract
10+-- the state. It is more powerful but less general than an Unfold.
1311--
14−-- For simple cases the seed itself can be used to represent the intermediate
15−-- state as well. For example, if we are iterating through a list or an array
16−-- we can return the remaining list or the remaining array slice as the
17−-- state and resume from it later.
12+-- A 'Producer' represents steps of a loop generating a sequence of elements.
13+-- While unfolds are closed representation of imperative loops with some opaque
14+-- internal state, producers are open loops with the state being accesible to
15+-- the user.
1816--
19−-- In general, the intermediate state could be different than the seed. Also,
20−-- when unfolds are nested, for example using 'concat', then each nesting layer
21−-- would have its own state.
22−--
23−-- In imperative terms, an unfold is like a for loop (or an iterator), the
24−-- state of the unfold is the state of the loop. The state of the 'concat' of
25−-- unfolds is like the state of each loop in the nesting of loops.
17+-- Unlike an unfold, which runs a loop till completion, a producer can be
18+-- stopped in the middle, its state can be extracted, examined, changed, and
19+-- then it can be resumed later from the stopped state.
2620--
21+-- A producer can be used in places where a CPS stream would otherwise be
22+-- needed, because the state of the loop can be passed around. However, it can
23+-- be much more efficient than CPS because it allows stream fusion and
24+-- unecessary function calls can be avoided.
2725
28−module Streamly.Internal.Data.Unfold.Resume
26+module Streamly.Internal.Data.Producer
2927 ( Unfold (..)
3028
3129 -- * Converting
@@ -54,43 +52,43 @@ import Control.Monad.Catch (MonadThrow, throwM)
5452import GHC.Exts (SpecConstrAnnotation(..))
5553import GHC.Types (SPEC(..))
5654import Streamly.Internal.Data.Parser.ParserD (ParseError(..), Step(..))
55+import Streamly.Internal.Data.Producer.Source (Source)
5756import Streamly.Internal.Data.Stream.StreamD.Step (Step(..))
5857import Streamly.Internal.Data.Stream.StreamD.Type (Stream(..))
5958import Streamly.Internal.Data.SVar (defState)
60−import Streamly.Internal.Data.Unfold.Source (Source)
59+import Streamly.Internal.Data.Unfold.Types (Unfold(..))
6160
6261import qualified Streamly.Internal.Data.Parser.ParserD as ParserD
6362import qualified Streamly.Internal.Data.Parser.ParserK.Types as ParserK
64−import qualified Streamly.Internal.Data.Unfold.Types as Unfold
65−import qualified Streamly.Internal.Data.Unfold.Source as Source
63+import qualified Streamly.Internal.Data.Producer.Source as Source
6664
67−import Streamly.Internal.Data.Unfold.Resume.Type
65+import Streamly.Internal.Data.Producer.Type
6866import Prelude hiding (concat)
6967
70−-- XXX We should write unfolds as resumable unfolds where possible and define
71−-- the regular unfolds using "simplify".
68+-- XXX We should write unfolds as producers where possible and define
69+-- unfolds using "simplify".
7270--
7371-------------------------------------------------------------------------------
74−-- Converting to regular unfolds
72+-- Converting to unfolds
7573-------------------------------------------------------------------------------
7674
77−-- | Simplify a resumable unfold to a regular unfold.
75+-- | Simplify a producer to an unfold.
7876--
7977-- /Internal/
8078{-# INLINE simplify #-}
81−simplify :: Unfold m a b -> Unfold.Unfold m a b
82−simplify (Unfold step inject _) = Unfold.Unfold step inject
79+simplify :: Producer m a b -> Unfold m a b
80+simplify (Producer step inject _) = Unfold step inject
8381
8482-------------------------------------------------------------------------------
8583-- Unfolds
8684-------------------------------------------------------------------------------
8785
88−-- | Convert a StreamD stream into an Unfold.
86+-- | Convert a StreamD stream into a producer.
8987--
9088-- /Internal/
9189{-# INLINE_NORMAL fromStreamD #-}
92−fromStreamD :: Monad m => Unfold m (Stream m a) a
93−fromStreamD = Unfold step return return
90+fromStreamD :: Monad m => Producer m (Stream m a) a
91+fromStreamD = Producer step return return
9492
9593 where
9694
@@ -106,6 +104,8 @@ fromStreamD = Unfold step return return
106104-- Parsing
107105-------------------------------------------------------------------------------
108106
107+-- XXX This should probably be moved to the Source module?
108+--
109109-- GHC parser does not accept {-# ANN type [] NoSpecConstr #-}, so we need
110110-- to make a newtype.
111111{-# ANN type List NoSpecConstr #-}
@@ -115,12 +115,12 @@ newtype List a = List {getList :: [a]}
115115parseD
116116 :: MonadThrow m
117117 => ParserD.Parser m a b
118− -> Unfold m (Source s a) a
118+ -> Producer m (Source s a) a
119119 -> Source s a
120120 -> m (b, Source s a)
121121parseD
122122 (ParserD.Parser pstep initial extract)
123− (Unfold ustep uinject uextract)
123+ (Producer ustep uinject uextract)
124124 seed = do
125125
126126 state <- uinject seed
@@ -197,7 +197,7 @@ parseD
197197parse
198198 :: MonadThrow m
199199 => ParserK.Parser m a b
200− -> Unfold m (Source s a) a
200+ -> Producer m (Source s a) a
201201 -> Source s a
202202 -> m (b, Source s a)
203203parse = parseD . ParserK.fromParserK
@@ -208,8 +208,10 @@ parse = parseD . ParserK.fromParserK
208208
209209{-# INLINE parseManyD #-}
210210parseManyD :: MonadThrow m =>
211− ParserD.Parser m a b -> Unfold m (Source x a) a -> Unfold m (Source x a) b
212−parseManyD parser reader = Unfold step return return
211+ ParserD.Parser m a b
212+ -> Producer m (Source x a) a
213+ -> Producer m (Source x a) b
214+parseManyD parser reader = Producer step return return
213215
214216 where
215217
@@ -227,5 +229,7 @@ parseManyD parser reader = Unfold step return return
227229-- /Internal/
228230{-# INLINE parseMany #-}
229231parseMany :: MonadThrow m =>
230− ParserK.Parser m a b -> Unfold m (Source x a) a -> Unfold m (Source x a) b
232+ ParserK.Parser m a b
233+ -> Producer m (Source x a) a
234+ -> Producer m (Source x a) b
231235parseMany parser = parseManyD (ParserK.fromParserK parser)
src/Streamly/Internal/Data/Unfold/Source.hs → src/Streamly/Internal/Data/Producer/Source.hsrenamed+11−8
@@ -1,5 +1,5 @@
11-- |
2−-- Module : Streamly.Internal.Data.Unfold.Source
2+-- Module : Streamly.Internal.Data.Producer.Source
33-- Copyright : (c) 2021 Composewell Technologies
44-- License : BSD-3-Clause
55-- Maintainer : streamly@composewell.com
@@ -11,7 +11,7 @@
1111-- useful in parsing applications with backtracking.
1212--
1313
14−module Streamly.Internal.Data.Unfold.Source
14+module Streamly.Internal.Data.Producer.Source
1515 ( Source
1616
1717 -- * Creation
@@ -22,16 +22,19 @@ module Streamly.Internal.Data.Unfold.Source
2222
2323 -- * Consumption
2424 , isEmpty
25− , read
25+ , producer
2626 )
2727where
2828
2929#include "inline.hs"
3030
3131import Streamly.Internal.Data.Stream.StreamD.Step (Step(..))
32−import Streamly.Internal.Data.Unfold.Resume.Type (Unfold(..))
32+import Streamly.Internal.Data.Producer.Type (Producer(..))
3333import Prelude hiding (read)
3434
35+-- XXX instead of a seed should we wrap a Producer in a source? Then we won't
36+-- have to supply a Producer for read.
37+--
3538-- | An unfold seed with some buffered data. It allows us to 'unread' or return
3639-- some data after reading it. Useful in backtracked parsing.
3740--
@@ -44,13 +47,13 @@ data Source a b = Source [b] (Maybe a)
4447source :: Maybe a -> Source a b
4548source = Source []
4649
47−
4850-- | Return some unused data back to the source. The data is prepended (or
4951-- consed) to the source.
5052--
5153-- /Internal/
5254unread :: [b] -> Source a b -> Source a b
5355unread xs (Source ys seed) = Source (xs ++ ys) seed
56+
5457isEmpty :: Source a b -> Bool
5558isEmpty (Source [] Nothing) = True
5659isEmpty _ = False
@@ -59,9 +62,9 @@ isEmpty _ = False
5962-- first and then the seed is unfolded using the supplied unfold.
6063--
6164-- /Internal/
62−{-# INLINE_NORMAL read #-}
63−read :: Monad m => Unfold m a b -> Unfold m (Source a b) b
64−read (Unfold step1 inject1 extract1) = Unfold step inject extract
65+{-# INLINE_NORMAL producer #-}
66+producer :: Monad m => Producer m a b -> Producer m (Source a b) b
67+producer (Producer step1 inject1 extract1) = Producer step inject extract
6568
6669 where
6770
src/Streamly/Internal/Data/Unfold/Resume/Type.hs → src/Streamly/Internal/Data/Producer/Type.hsrenamed+33−37
@@ -1,27 +1,27 @@
11-- |
2−-- Module : Streamly.Internal.Data.Unfold.Resume.Type
2+-- Module : Streamly.Internal.Data.Producer.Type
33-- Copyright : (c) 2021 Composewell Technologies
44-- License : BSD-3-Clause
55-- Maintainer : streamly@composewell.com
66-- Stability : experimental
77-- Portability : GHC
88--
9−-- Resumable unfolds. See "Streamly.Internal.Data.Unfold.Resume" for
10−-- introduction.
9+-- See "Streamly.Internal.Data.Producer" for introduction.
1110--
1211
13−module Streamly.Internal.Data.Unfold.Resume.Type
12+module Streamly.Internal.Data.Producer.Type
1413 (
1514 -- * Type
16− Unfold (..)
15+ Producer (..)
1716
18− -- * Unfolds
17+ -- * Producers
1918 , nil
2019 , nilM
2120 , unfoldrM
2221 , fromList
2322
2423 -- * Mapping
24+ , translate
2525 , lmap
2626
2727 -- * Nesting
@@ -40,33 +40,22 @@ import Prelude hiding (concat)
4040-- Type
4141------------------------------------------------------------------------------
4242
43−{-
44−-- Representing open loops.
45−-- Stepper/Iterator/Generator/Producer
46−-- | A function that can be called repeatedly to generate a sequence of values.
47−data Producer m a b = Producer (a -> m (Step a b))
48−
49−-- A similar concept for folds would be an accumulator/reducer/Consumer
50−-- | A function that can be called repeatedly to consume a sequence of values.
51−data Consumer m a b = Consumer (s -> a -> m (Step b))
52−-}
53−
54−-- | An @Unfold m a b@ is a generator of a stream of values of type @b@ from a
43+-- | A @Producer m a b@ is a generator of a stream of values of type @b@ from a
5544-- seed of type 'a' in 'Monad' @m@.
5645--
5746-- /Internal/
5847
59−data Unfold m a b =
60− -- | @Unfold step inject extract@
61− forall s. Unfold (s -> m (Step s b)) (a -> m s) (s -> m a)
48+data Producer m a b =
49+ -- | @Producer step inject extract@
50+ forall s. Producer (s -> m (Step s b)) (a -> m s) (s -> m a)
6251
6352------------------------------------------------------------------------------
64−-- Unfolds
53+-- Producers
6554------------------------------------------------------------------------------
6655
6756{-# INLINE nilM #-}
68−nilM :: Monad m => (a -> m c) -> Unfold m a b
69−nilM f = Unfold step return return
57+nilM :: Monad m => (a -> m c) -> Producer m a b
58+nilM f = Producer step return return
7059
7160 where
7261
@@ -74,12 +63,12 @@ nilM f = Unfold step return return
7463 step x = f x >> return Stop
7564
7665{-# INLINE nil #-}
77−nil :: Monad m => Unfold m a b
66+nil :: Monad m => Producer m a b
7867nil = nilM (\_ -> return ())
7968
8069{-# INLINE unfoldrM #-}
81−unfoldrM :: Monad m => (a -> m (Maybe (b, a))) -> Unfold m a b
82−unfoldrM next = Unfold step return return
70+unfoldrM :: Monad m => (a -> m (Maybe (b, a))) -> Producer m a b
71+unfoldrM next = Producer step return return
8372 where
8473 {-# INLINE_LATE step #-}
8574 step st = do
@@ -92,8 +81,8 @@ unfoldrM next = Unfold step return return
9281--
9382-- /Internal/
9483{-# INLINE_LATE fromList #-}
95−fromList :: Monad m => Unfold m [a] a
96−fromList = Unfold step return return
84+fromList :: Monad m => Producer m [a] a
85+fromList = Producer step return return
9786
9887 where
9988
@@ -105,14 +94,21 @@ fromList = Unfold step return return
10594-- Mapping
10695------------------------------------------------------------------------------
10796
108−-- | We can only lmap between two types that can be interconverted without
109−-- loss.
97+-- | Interconvert the producer between two interconvertible input types.
98+--
99+-- /Internal/
100+{-# INLINE_NORMAL translate #-}
101+translate :: Functor m =>
102+ (a -> c) -> (c -> a) -> Producer m c b -> Producer m a b
103+translate f g (Producer step inject extract) =
104+ Producer step (inject . f) (fmap g . extract)
105+
106+-- | Map the producer input to another value of the same type.
110107--
111108-- /Internal/
112109{-# INLINE_NORMAL lmap #-}
113−lmap :: Functor m => (a -> c) -> (c -> a) -> Unfold m c b -> Unfold m a b
114−lmap f g (Unfold ustep uinject uextract) =
115− Unfold ustep (uinject . f) (fmap g . uextract)
110+lmap :: (a -> a) -> Producer m a b -> Producer m a b
111+lmap f (Producer step inject extract) = Producer step (inject . f) extract
116112
117113------------------------------------------------------------------------------
118114-- Nesting
@@ -129,9 +125,9 @@ data NestedLoop s1 s2 = OuterLoop s1 | InnerLoop s1 s2
129125--
130126{-# INLINE_NORMAL concat #-}
131127concat :: Monad m =>
132− Unfold m a b -> Unfold m b c -> Unfold m (NestedLoop a b) c
133−concat (Unfold step1 inject1 extract1) (Unfold step2 inject2 extract2) =
134− Unfold step inject extract
128+ Producer m a b -> Producer m b c -> Producer m (NestedLoop a b) c
129+concat (Producer step1 inject1 extract1) (Producer step2 inject2 extract2) =
130+ Producer step inject extract
135131
136132 where
137133
streamly.cabal+3−3
@@ -433,9 +433,9 @@ library
433433 , Streamly.Internal.Data.Stream.StreamD.Type
434434 , Streamly.Internal.Data.Stream.StreamDK.Type
435435 , Streamly.Internal.Data.Unfold.Types
436− , Streamly.Internal.Data.Unfold.Resume.Type
437− , Streamly.Internal.Data.Unfold.Resume
438− , Streamly.Internal.Data.Unfold.Source
436+ , Streamly.Internal.Data.Producer.Type
437+ , Streamly.Internal.Data.Producer
438+ , Streamly.Internal.Data.Producer.Source
439439 , Streamly.Internal.Data.Sink.Types
440440 , Streamly.Internal.Data.Parser.ParserK.Types
441441 , Streamly.Internal.Data.Parser.ParserD.Types
test/Streamly/Test/Data/Parser/ParserD.hs+6−6
@@ -15,10 +15,10 @@ import qualified Prelude
1515import qualified Streamly.Internal.Data.Array.Foreign as A
1616import qualified Streamly.Internal.Data.Fold as FL
1717import qualified Streamly.Internal.Data.Parser.ParserD as P
18+import qualified Streamly.Internal.Data.Producer.Source as Source
19+import qualified Streamly.Internal.Data.Producer as Producer
1820import qualified Streamly.Internal.Data.Stream.IsStream as S
1921import qualified Streamly.Internal.Data.Unfold as Unfold
20−import qualified Streamly.Internal.Data.Unfold.Source as Source
21−import qualified Streamly.Internal.Data.Unfold.Resume as UnfoldR
2222import qualified Test.Hspec as H
2323
2424import Prelude hiding (sequence)
@@ -621,13 +621,13 @@ parseUnfold = do
621621 <*> chooseInt (1, len)) $ \(ls, clen, tlen) ->
622622 monadicIO $ do
623623 arrays <- S.toList $ S.arraysOf clen (S.fromList ls)
624− let src = Source.source (Just (UnfoldR.OuterLoop arrays))
624+ let src = Source.source (Just (Producer.OuterLoop arrays))
625625 let parser = P.fromFold (FL.takeLE tlen FL.toList)
626626 let readSrc =
627− Source.read
628− $ UnfoldR.concat UnfoldR.fromList A.readResumable
627+ Source.producer
628+ $ Producer.concat Producer.fromList A.producer
629629 let streamParser =
630− UnfoldR.simplify (UnfoldR.parseManyD parser readSrc)
630+ Producer.simplify (Producer.parseManyD parser readSrc)
631631 xs <- run
632632 $ S.toList
633633 $ S.concatUnfold Unfold.fromList