on master help sign in
Remove dependency of Array module on Data.Fold

Make it depend on low level Fold.Types instead.

commit6551e4969010aaa42744aeb82529797c1d6ca5b2 authorHarendra Kumar <harendra@composewell.com> dateThu 21 Jan 2021, 15:37 (6 years ago) parent162a14a
5 files changed+25−17
src/Streamly/Internal/Data/Array/Storable/Foreign/Mut/Types.hs+3−2 src/Streamly/Internal/Data/Array/Storable/Foreign/Types.hs+1−1 src/Streamly/Internal/Data/Fold.hs−13 src/Streamly/Internal/Data/Fold/Types.hs+20 streamly.cabal+1−1
src/Streamly/Internal/Data/Array/Storable/Foreign/Mut/Types.hs+3−2
@@ -121,9 +121,10 @@ import Text.Read (readPrec, readListPrec, readListPrecDefault)
121121import qualified Data.Foldable as F
122122#endif
123123import qualified GHC.Exts as Exts
124−import qualified Streamly.Internal.Data.Fold as FL
124+import qualified Streamly.Internal.Data.Fold.Types as FL
125125import qualified Streamly.Internal.Data.Stream.StreamD.Type as D
126−import qualified Streamly.Internal.Data.Stream.StreamK as K
126+import qualified Streamly.Internal.Data.Stream.StreamK as K (foldl')
127+import qualified Streamly.Internal.Data.Stream.StreamK.Type as K
127128import qualified Streamly.Internal.Foreign.Malloc as Malloc
128129
129130import Prelude hiding (length, foldr, read, unlines, splitAt)
src/Streamly/Internal/Data/Array/Storable/Foreign/Types.hs+1−1
@@ -105,7 +105,7 @@ import Text.Read (readPrec, readListPrec, readListPrecDefault)
105105import Prelude hiding (length, foldr, read, unlines, splitAt)
106106
107107import qualified Streamly.Internal.Data.Stream.StreamD.Type as D
108−import qualified Streamly.Internal.Data.Stream.StreamK as K
108+import qualified Streamly.Internal.Data.Stream.StreamK.Type as K
109109import qualified Streamly.Internal.Data.Array.Storable.Foreign.Mut.Types as MA
110110import qualified Streamly.Internal.Data.Fold.Types as Fold
111111import qualified GHC.Exts as Exts
src/Streamly/Internal/Data/Fold.hs−13
@@ -715,19 +715,6 @@ foldMapM act = mkAccumM_ step (pure mempty)
715715-- To Containers
716716------------------------------------------------------------------------------
717717
718−-- | Folds the input stream to a list.
719−--
720−-- /Warning!/ working on large lists accumulated as buffers in memory could be
721−-- very inefficient, consider using "Streamly.Data.Array.Storable.Foreign"
722−-- instead.
723−--
724−-- @since 0.7.0
725−
726−-- id . (x1 :) . (x2 :) . (x3 :) . ... . (xn :) $ []
727−{-# INLINABLE toList #-}
728−toList :: Monad m => Fold m a [a]
729−toList = mkAccum (\f x -> f . (x :)) id ($ [])
730−
731718-- $toListRevF
732719-- This is more efficient than 'Streamly.Internal.Data.Fold.toList'. toList is
733720-- exactly the same as reversing the list after 'toListRevF'.
src/Streamly/Internal/Data/Fold/Types.hs+20
@@ -185,6 +185,9 @@ module Streamly.Internal.Data.Fold.Types
185185 , Fold2 (..)
186186 , simplify
187187
188+ -- * Basic Folds
189+ , toList
190+
188191 -- * Generators
189192 , yield
190193 , yieldM
@@ -410,6 +413,23 @@ simplify :: Functor m => Fold2 m c a b -> c -> Fold m a b
410413simplify (Fold2 step inject extract) c =
411414 Fold (\x a -> Partial <$> step x a) (Partial <$> inject c) extract
412415
416+------------------------------------------------------------------------------
417+-- Basic Folds
418+------------------------------------------------------------------------------
419+
420+-- | Folds the input stream to a list.
421+--
422+-- /Warning!/ working on large lists accumulated as buffers in memory could be
423+-- very inefficient, consider using "Streamly.Data.Array.Storable.Foreign"
424+-- instead.
425+--
426+-- @since 0.7.0
427+
428+-- id . (x1 :) . (x2 :) . (x3 :) . ... . (xn :) $ []
429+{-# INLINABLE toList #-}
430+toList :: Monad m => Fold m a [a]
431+toList = mkAccum (\f x -> f . (x :)) id ($ [])
432+
413433------------------------------------------------------------------------------
414434-- Instances
415435------------------------------------------------------------------------------
streamly.cabal+1−1
@@ -452,8 +452,8 @@ library
452452 , Streamly.Internal.Data.SmallArray.Types
453453
454454 -- streamly-base-streams
455− -- May depend on streamly-core-array
456455 , Streamly.Internal.Data.Stream.StreamK
456+ -- StreamD depends on streamly-core-array
457457 , Streamly.Internal.Data.Stream.StreamD.Generate
458458 , Streamly.Internal.Data.Stream.StreamD.Eliminate
459459 , Streamly.Internal.Data.Stream.StreamD.Nesting