on master help sign in
Move Streamly.Data.Unfold module to streamly-core package (#1771)
7dde623Ranjeet Ranjan
src/Streamly/Data/Unfold.hs → core/src/Streamly/Data/Unfold.hsrenamed+2−20
@@ -160,7 +160,7 @@ module Streamly.Data.Unfold
160
160
161 -- * Unfolds
161 -- * Unfolds
162 -- One to one correspondence with
162 -- One to one correspondence with
163− -- "Streamly.Internal.Data.Stream.IsStream.Generate"
163+ -- "Streamly.Internal.Data.Stream.Generate"
164
164
165 -- ** Basic Constructors
165 -- ** Basic Constructors
166 , unfoldrM
166 , unfoldrM
@@ -212,22 +212,4 @@ import Prelude hiding
212 ( concat, map, mapM, takeWhile, take, filter, const, drop, dropWhile
212 ( concat, map, mapM, takeWhile, take, filter, const, drop, dropWhile
213 , zipWith
213 , zipWith
214 )
214 )
215−import Streamly.Internal.Data.Stream.IsStream.Type (IsStream)
215+import Streamly.Internal.Data.Unfold
216−import Streamly.Internal.Data.Unfold hiding (fromStream)
217−
218−import qualified Streamly.Internal.Data.Stream.IsStream.Type as IsStream
219−import qualified Streamly.Internal.Data.Unfold as Unfold
220−
221−-- XXX Using Unfold.fromStreamD seems to be faster (using cross product test
222−-- case) than using fromStream even if it is implemented using fromStreamD.
223−-- Check if StreamK to StreamD rewrite rules are working correctly when
224−-- implementing fromStream using fromStreamD.
225−
226−-- | Convert a stream into an 'Unfold'. Note that a stream converted to an
227−-- 'Unfold' may not be as efficient as an 'Unfold' in some situations.
228−--
229−-- /Since: 0.8.0/
230−--
231−{-# INLINE_NORMAL fromStream #-}
232−fromStream :: (IsStream t, Applicative m) => Unfold m (t m a) a
233−fromStream = lmap IsStream.toStream Unfold.fromStreamK
core/streamly-core.cabal+1
@@ -344,6 +344,7 @@ library
344 , Streamly.Data.Fold
344 , Streamly.Data.Fold
345 , Streamly.Data.Fold.Tee
345 , Streamly.Data.Fold.Tee
346 , Streamly.Data.Array.Unboxed
346 , Streamly.Data.Array.Unboxed
347+ , Streamly.Data.Unfold
347
348
348 build-depends:
349 build-depends:
349 -- Core libraries shipped with ghc, the min and max
350 -- Core libraries shipped with ghc, the min and max
docs/User/ProjectRelated/Changelog.md+2
@@ -14,6 +14,8 @@
14 writeWithBufferOf -> writeWith
14 writeWithBufferOf -> writeWith
15 writeChunksWithBufferOf -> writeChunksWith
15 writeChunksWithBufferOf -> writeChunksWith
16
16
17+* Signature changed: Streamly.Data.Unfold.fromStream
18+
17### Deprecations
19### Deprecations
18
20
19* In `Streamly.Data.Fold`:
21* In `Streamly.Data.Fold`:
src/Streamly/Internal/Data/Stream/IsStream/Common.hs−1
@@ -569,7 +569,6 @@ concatMapM f m = fromStreamD $ D.concatMapM (fmap toStreamD . f) (toStreamD m)
569-- >>> concatMap f = Stream.concatMapM (return . f)
569-- >>> concatMap f = Stream.concatMapM (return . f)
570-- >>> concatMap f = Stream.concatMapWith Stream.serial f
570-- >>> concatMap f = Stream.concatMapWith Stream.serial f
571-- >>> concatMap f = Stream.concat . Stream.map f
571-- >>> concatMap f = Stream.concat . Stream.map f
572−-- >>> concatMap f = Stream.unfoldMany (Unfold.lmap f Unfold.fromStream)
573--
572--
574-- @since 0.6.0
573-- @since 0.6.0
575{-# INLINE concatMap #-}
574{-# INLINE concatMap #-}
src/Streamly/Internal/Data/Stream/IsStream/Reduce.hs+1−5
@@ -1289,10 +1289,6 @@ ejectExpired reset ejectPred extract session@SessionState{..} curTime = do
1289 assert (IsMap.mapNull mp) (return ())
1289 assert (IsMap.mapNull mp) (return ())
1290 return (hp, mp, out, cnt)
1290 return (hp, mp, out, cnt)
1291
1291
1292−{-# INLINE readSerial #-}
1293−readSerial :: Applicative m => Unfold.Unfold m (IsStream.SerialT m a) a
1294−readSerial = Unfold.fromStream
1295−
1296-- XXX Use mutable IORef in accumulator
1292-- XXX Use mutable IORef in accumulator
1297{-# INLINE classifySessionsByGeneric #-}
1293{-# INLINE classifySessionsByGeneric #-}
1298classifySessionsByGeneric
1294classifySessionsByGeneric
@@ -1307,7 +1303,7 @@ classifySessionsByGeneric
1307 -> t m (Key f, b) -- ^ session key, fold result
1303 -> t m (Key f, b) -- ^ session key, fold result
1308classifySessionsByGeneric _ tick reset ejectPred tmout
1304classifySessionsByGeneric _ tick reset ejectPred tmout
1309 (Fold step initial extract) input =
1305 (Fold step initial extract) input =
1310− Expand.unfoldMany (Unfold.lmap sessionOutputStream readSerial)
1306+ Expand.unfoldMany (Unfold.lmap sessionOutputStream Unfold.fromStream)
1311 $ scanlMAfter' sstep (return szero) (flush extract)
1307 $ scanlMAfter' sstep (return szero) (flush extract)
1312 $ interjectSuffix tick (return Nothing)
1308 $ interjectSuffix tick (return Nothing)
1313 $ map Just input
1309 $ map Just input
streamly.cabal+3−4
@@ -215,6 +215,7 @@ extra-source-files:
215 core/src/Streamly/Data/Stream.hs
215 core/src/Streamly/Data/Stream.hs
216 core/src/Streamly/Data/Fold.hs
216 core/src/Streamly/Data/Fold.hs
217 core/src/Streamly/Data/Fold/Tee.hs
217 core/src/Streamly/Data/Fold/Tee.hs
218+ core/src/Streamly/Data/Unfold.hs
218 core/src/Streamly/Internal/Data/Fold/Window.hs
219 core/src/Streamly/Internal/Data/Fold/Window.hs
219 core/src/Streamly/Data/Array/Unboxed.hs
220 core/src/Streamly/Data/Array/Unboxed.hs
220 core/src/Streamly/Internal/Data/Time/Clock/Darwin.c
221 core/src/Streamly/Internal/Data/Time/Clock/Darwin.c
@@ -436,10 +437,7 @@ library
436 -- dependency order To view dependency graph:
437 -- dependency order To view dependency graph:
437 -- graphmod | dot -Tps > deps.ps
438 -- graphmod | dot -Tps > deps.ps
438
439
439− -- XXX To be moved to streamly-core
440− Streamly.Data.Unfold
441−
442− , Streamly.Internal.Data.IsMap.HashMap
440+ Streamly.Internal.Data.IsMap.HashMap
443
441
444 -- XXX To be removed or put under dev flag
442 -- XXX To be removed or put under dev flag
445 , Streamly.Internal.Data.SmallArray.Type
443 , Streamly.Internal.Data.SmallArray.Type
@@ -637,6 +635,7 @@ library
637 , Streamly.Internal.Data.Stream.StreamK
635 , Streamly.Internal.Data.Stream.StreamK
638
636
639 -- streamly-core exposed modules
637 -- streamly-core exposed modules
638+ , Streamly.Data.Unfold
640 , Streamly.Data.Stream
639 , Streamly.Data.Stream
641 , Streamly.Data.Fold
640 , Streamly.Data.Fold
642 , Streamly.Data.Fold.Tee
641 , Streamly.Data.Fold.Tee