on master help sign in
Refactor, reformat Stream module
1872958Harendra Kumar
core/src/Streamly/Internal/Data/Stream.hs+5−7
@@ -1,19 +1,17 @@
1-- |
1-- |
2-- Module : Streamly.Internal.Data.Stream
2-- Module : Streamly.Internal.Data.Stream
3-- Copyright : (c) 2017 Composewell Technologies
3-- Copyright : (c) 2017 Composewell Technologies
4−--
5-- License : BSD-3-Clause
4-- License : BSD-3-Clause
6-- Maintainer : streamly@composewell.com
5-- Maintainer : streamly@composewell.com
7-- Stability : experimental
6-- Stability : experimental
8-- Portability : GHC
7-- Portability : GHC
9--
8--
10module Streamly.Internal.Data.Stream
9module Streamly.Internal.Data.Stream
11−( module Streamly.Internal.Data.Stream.Type
10+ ( module Streamly.Internal.Data.Stream.Type
12−, module Streamly.Internal.Data.Stream.Eliminate
11+ , module Streamly.Internal.Data.Stream.Eliminate
13−, module Streamly.Internal.Data.Stream.Generate
12+ , module Streamly.Internal.Data.Stream.Generate
14−, module Streamly.Internal.Data.Stream.Transform
13+ , module Streamly.Internal.Data.Stream.Transform
15−)
14+ )
16−
17where
15where
18
16
19import Streamly.Internal.Data.Stream.Eliminate
17import Streamly.Internal.Data.Stream.Eliminate
core/src/Streamly/Internal/Data/Stream/Eliminate.hs+27−20
@@ -1,7 +1,6 @@
1-- |
1-- |
2-- Module : Streamly.Internal.Data.Stream.Eliminate
2-- Module : Streamly.Internal.Data.Stream.Eliminate
3-- Copyright : (c) 2017 Composewell Technologies
3-- Copyright : (c) 2017 Composewell Technologies
4−--
5-- License : BSD-3-Clause
4-- License : BSD-3-Clause
6-- Maintainer : streamly@composewell.com
5-- Maintainer : streamly@composewell.com
7-- Stability : experimental
6-- Stability : experimental
@@ -9,30 +8,38 @@
9--
8--
10module Streamly.Internal.Data.Stream.Eliminate
9module Streamly.Internal.Data.Stream.Eliminate
11 (
10 (
12− drain
11+ fold
13 )
12 )
14where
13where
15
14
16−#if __GLASGOW_HASKELL__ < 808
17−import Data.Semigroup (Semigroup(..))
18−#endif
19−
20−import qualified Streamly.Internal.Data.Stream.Common as P
15+import Streamly.Internal.Data.Fold.Type (Fold)
21−
22−import Streamly.Internal.Data.Stream.Type
16+import Streamly.Internal.Data.Stream.Type (Stream)
23
17
24−import Prelude hiding (map, mapM, repeat, filter)
18+import qualified Streamly.Internal.Data.Stream.Type as Stream
19+import qualified Streamly.Internal.Data.Stream.StreamD.Type as StreamD
25
20
26−#include "inline.hs"
21+-- | Fold a stream using the supplied left 'Fold' and reducing the resulting
27−
22+-- expression strictly at each step. The behavior is similar to 'foldl''. A
28−-- |
23+-- 'Fold' can terminate early without consuming the full stream. See the
29−-- > drain = mapM_ (\_ -> return ())
24+-- documentation of individual 'Fold's for termination behavior.
30−-- > drain = Stream.fold Fold.drain
31--
25--
32−-- Run a stream serially, discarding the results.
26+-- >>> Stream.foldWith Fold.sum (Stream.enumerateFromTo 1 100)
27+-- 5050
33--
28--
34−-- /Pre-release/
29+-- Folds never fail, therefore, they produce a default value even when no input
30+-- is provided. It means we can always fold an empty stream and get a valid
31+-- result. For example:
32+--
33+-- >>> Stream.fold Fold.sum Stream.nil
34+-- 0
35+--
36+-- However, 'foldMany' on an empty stream results in an empty stream.
37+-- Therefore, @Stream.foldWith f@ is not the same as @Stream.head . Stream.foldMany
38+-- f@.
35--
39--
40+-- @fold f = Stream.parse (Parser.fromFold f)@
41+--
42+-- /Pre-release/
36−{-# INLINE drain #-}
43+{-# INLINE fold #-}
37−drain :: Monad m => Stream m a -> m ()
44+fold :: Monad m => Fold m a b -> Stream m a -> m b
38−drain (Stream m) = P.drain m
45+fold fld = StreamD.fold fld . Stream.toStreamD
core/src/Streamly/Internal/Data/Stream/Generate.hs+13−54
@@ -1,7 +1,6 @@
1-- |
1-- |
2-- Module : Streamly.Internal.Data.Stream.Generate
2-- Module : Streamly.Internal.Data.Stream.Generate
3-- Copyright : (c) 2017 Composewell Technologies
3-- Copyright : (c) 2017 Composewell Technologies
4−--
5-- License : BSD-3-Clause
4-- License : BSD-3-Clause
6-- Maintainer : streamly@composewell.com
5-- Maintainer : streamly@composewell.com
7-- Stability : experimental
6-- Stability : experimental
@@ -11,9 +10,7 @@ module Streamly.Internal.Data.Stream.Generate
11 (
10 (
12 cons
11 cons
13 , consM
12 , consM
14− , repeat
13+ , append
15− , serial
16− , unfoldrM
17 )
14 )
18where
15where
19
16
@@ -23,16 +20,10 @@ import Data.Semigroup (Semigroup(..))
23#if __GLASGOW_HASKELL__ < 808
20#if __GLASGOW_HASKELL__ < 808
24import Data.Semigroup (Semigroup(..))
21import Data.Semigroup (Semigroup(..))
25#endif
22#endif
23+import Streamly.Internal.Data.Stream.Type (Stream)
26
24
27−import qualified Streamly.Internal.Data.Stream.StreamD.Type as D
25+import qualified Streamly.Internal.Data.Stream.Type as Stream
28−import qualified Streamly.Internal.Data.Stream.StreamD.Generate as D
29−import qualified Streamly.Internal.Data.Stream.StreamK.Type as K
26+import qualified Streamly.Internal.Data.Stream.StreamK.Type as StreamK
30−
31−import Prelude hiding (map, mapM, repeat, filter)
32−
33−import Streamly.Internal.Data.Stream.Type
34−
35−#include "inline.hs"
36
27
37-- $setup
28-- $setup
38-- >>> :m
29-- >>> :m
@@ -56,7 +47,7 @@ import Streamly.Internal.Data.Stream.Type
56--
47--
57{-# INLINE cons #-}
48{-# INLINE cons #-}
58cons :: a -> Stream m a -> Stream m a
49cons :: a -> Stream m a -> Stream m a
59−cons x (Stream ms) = Stream $ K.cons x ms
50+cons x = Stream.fromStreamK . StreamK.cons x . Stream.toStreamK
60
51
61-- | Constructs a stream by adding a monadic action at the head of an
52-- | Constructs a stream by adding a monadic action at the head of an
62-- existing stream. For example:
53-- existing stream. For example:
@@ -68,21 +59,14 @@ cons x (Stream ms) = Stream $ K.cons x ms
68-- ["hello","world"]
59-- ["hello","world"]
69-- @
60-- @
70--
61--
62+-- > consM x xs = fromEffect x `append` xs
63+--
71-- /Pre-release/
64-- /Pre-release/
72--
65--
73{-# INLINE consM #-}
66{-# INLINE consM #-}
74{-# SPECIALIZE consM :: IO a -> Stream IO a -> Stream IO a #-}
67{-# SPECIALIZE consM :: IO a -> Stream IO a -> Stream IO a #-}
75consM :: Monad m => m a -> Stream m a -> Stream m a
68consM :: Monad m => m a -> Stream m a -> Stream m a
76−consM m (Stream ms) = Stream $ K.consM m ms
69+consM m = Stream.fromStreamK . StreamK.consM m . Stream.toStreamK
77−
78−-- |
79−-- Generate an infinite stream by repeating a pure value.
80−--
81−-- /Pre-release/
82−--
83−{-# INLINE_NORMAL repeat #-}
84−repeat :: Monad m => a -> Stream m a
85−repeat = Stream . D.toStreamK . D.repeat
86
70
87------------------------------------------------------------------------------
71------------------------------------------------------------------------------
88-- Combining
72-- Combining
@@ -91,41 +75,16 @@ repeat = Stream . D.toStreamK . D.repeat
91-- | Appends two streams sequentially, yielding all elements from the first
75-- | Appends two streams sequentially, yielding all elements from the first
92-- stream, and then all elements from the second stream.
76-- stream, and then all elements from the second stream.
93--
77--
94−-- >>> import Streamly.Internal.Data.Stream (serial)
78+-- >>> import Streamly.Internal.Data.Stream (append)
95-- >>> stream1 = Stream.fromList [1,2]
79-- >>> stream1 = Stream.fromList [1,2]
96-- >>> stream2 = Stream.fromList [3,4]
80-- >>> stream2 = Stream.fromList [3,4]
97−-- >>> Stream.toList $ stream1 `serial` stream2
81+-- >>> Stream.toList $ stream1 `append` stream2
98-- [1,2,3,4]
82-- [1,2,3,4]
99--
83--
100-- This operation can be used to fold an infinite lazy container of streams.
84-- This operation can be used to fold an infinite lazy container of streams.
101--
85--
102-- /Pre-release/
86-- /Pre-release/
103--
87--
104−{-# INLINE serial #-}
88+{-# INLINE append #-}
105−serial :: Stream m a -> Stream m a -> Stream m a
89+append :: Stream m a -> Stream m a -> Stream m a
106−serial = (<>)
90+append = (<>)
107−
108−-- | Build a stream by unfolding a /monadic/ step function starting from a
109−-- seed. The step function returns the next element in the stream and the next
110−-- seed value. When it is done it returns 'Nothing' and the stream ends. For
111−-- example,
112−--
113−-- @
114−-- let f b =
115−-- if b > 3
116−-- then return Nothing
117−-- else print b >> return (Just (b, b + 1))
118−-- in drain $ unfoldrM f 0
119−-- @
120−-- @
121−-- 0
122−-- 1
123−-- 2
124−-- 3
125−-- @
126−--
127−-- /Pre-release/
128−--
129−{-# INLINE unfoldrM #-}
130−unfoldrM :: Monad m => (b -> m (Maybe (a, b))) -> b -> Stream m a
131−unfoldrM step seed = Stream $ D.toStreamK (D.unfoldrM step seed)
core/src/Streamly/Internal/Data/Stream/Instances.hs+2−2
@@ -139,7 +139,7 @@ instance (Foldable m, Monad m) => Foldable (STREAM m) where { \
139 \
139 \
140 {-# INLINE maximum #-}; \
140 {-# INLINE maximum #-}; \
141 maximum = \
141 maximum = \
142− fromMaybe (errorWithoutStackTrace $ "maximum: empty stream") \
142+ fromMaybe (errorWithoutStackTrace "maximum: empty stream") \
143 . toMaybe \
143 . toMaybe \
144 . foldl' getMax Nothing' where { \
144 . foldl' getMax Nothing' where { \
145 getMax Nothing' x = Just' x; \
145 getMax Nothing' x = Just' x; \
@@ -147,7 +147,7 @@ instance (Foldable m, Monad m) => Foldable (STREAM m) where { \
147 \
147 \
148 {-# INLINE minimum #-}; \
148 {-# INLINE minimum #-}; \
149 minimum = \
149 minimum = \
150− fromMaybe (errorWithoutStackTrace $ "minimum: empty stream") \
150+ fromMaybe (errorWithoutStackTrace "minimum: empty stream") \
151 . toMaybe \
151 . toMaybe \
152 . foldl' getMin Nothing' where { \
152 . foldl' getMin Nothing' where { \
153 getMin Nothing' x = Just' x; \
153 getMin Nothing' x = Just' x; \
core/src/Streamly/Internal/Data/Stream/Transform.hs+13−18
@@ -1,32 +1,27 @@
1-- |
1-- |
2-- Module : Streamly.Internal.Data.Stream.Transform
2-- Module : Streamly.Internal.Data.Stream.Transform
3-- Copyright : (c) 2017 Composewell Technologies
3-- Copyright : (c) 2017 Composewell Technologies
4−--
5-- License : BSD-3-Clause
4-- License : BSD-3-Clause
6-- Maintainer : streamly@composewell.com
5-- Maintainer : streamly@composewell.com
7-- Stability : experimental
6-- Stability : experimental
8-- Portability : GHC
7-- Portability : GHC
9--
8--
10module Streamly.Internal.Data.Stream.Transform
9module Streamly.Internal.Data.Stream.Transform
11−(
10+ (
12− filter
11+ filter
13−, foldFilter
12+ , foldFilter
14−, map
13+ , map
15−, mapM
14+ , mapM
16−)
15+ )
17where
16where
18
17
19import Streamly.Internal.Data.Fold.Type (Fold)
18import Streamly.Internal.Data.Fold.Type (Fold)
19+import Streamly.Internal.Data.Stream.Type (Stream)
20
20
21−import qualified Streamly.Internal.Data.Stream.StreamD.Transform as D
21+import qualified Streamly.Internal.Data.Stream.Type as Stream
22−import qualified Streamly.Internal.Data.Stream.StreamD.Type as D
22+import qualified Streamly.Internal.Data.Stream.StreamD.Transform as StreamD
23−
24−import Prelude hiding (map, mapM, repeat, filter)
25−
26−import Streamly.Internal.Data.Stream.Type
27
23
28−#include "Instances.hs"
24+import Prelude hiding (map, mapM, filter)
29−#include "inline.hs"
30
25
31--
26--
32-- $setup
27-- $setup
@@ -72,7 +67,7 @@ import Streamly.Internal.Data.Stream.Type
72--
67--
73{-# INLINE mapM #-}
68{-# INLINE mapM #-}
74mapM :: Monad m => (a -> m b) -> Stream m a -> Stream m b
69mapM :: Monad m => (a -> m b) -> Stream m a -> Stream m b
75−mapM f (Stream m) = Stream $ D.toStreamK $ D.mapM f $ D.fromStreamK m
70+mapM f = Stream.fromStreamD . StreamD.mapM f . Stream.toStreamD
76
71
77-- |
72-- |
78-- @
73-- @
@@ -96,7 +91,7 @@ map f = mapM (return . f)
96--
91--
97{-# INLINE filter #-}
92{-# INLINE filter #-}
98filter :: Monad m => (a -> Bool) -> Stream m a -> Stream m a
93filter :: Monad m => (a -> Bool) -> Stream m a -> Stream m a
99−filter p = fromStreamD . D.filter p . toStreamD
94+filter p = Stream.fromStreamD . StreamD.filter p . Stream.toStreamD
100
95
101-- | Use a filtering fold on a stream.
96-- | Use a filtering fold on a stream.
102--
97--
@@ -107,4 +102,4 @@ filter p = fromStreamD . D.filter p . toStreamD
107--
102--
108{-# INLINE foldFilter #-}
103{-# INLINE foldFilter #-}
109foldFilter :: Monad m => Fold m a (Maybe b) -> Stream m a -> Stream m b
104foldFilter :: Monad m => Fold m a (Maybe b) -> Stream m a -> Stream m b
110−foldFilter p = fromStreamD . D.foldFilter p . toStreamD
105+foldFilter p = Stream.fromStreamD . StreamD.foldFilter p . Stream.toStreamD
core/src/Streamly/Internal/Data/Stream/Type.hs+38−107
@@ -1,10 +1,8 @@
1{-# LANGUAGE UndecidableInstances #-}
1{-# LANGUAGE UndecidableInstances #-}
2−{-# OPTIONS_GHC -Wno-orphans #-}
3
2
4-- |
3-- |
5-- Module : Streamly.Internal.Data.Stream.Type
4-- Module : Streamly.Internal.Data.Stream.Type
6-- Copyright : (c) 2017 Composewell Technologies
5-- Copyright : (c) 2017 Composewell Technologies
7−--
8-- License : BSD-3-Clause
6-- License : BSD-3-Clause
9-- Maintainer : streamly@composewell.com
7-- Maintainer : streamly@composewell.com
10-- Stability : experimental
8-- Stability : experimental
@@ -12,42 +10,40 @@
12--
10--
13module Streamly.Internal.Data.Stream.Type
11module Streamly.Internal.Data.Stream.Type
14 (
12 (
15− Stream(..)
13+ Stream
14+ , fromStreamK
15+ , toStreamK
16 , fromStreamD
16 , fromStreamD
17 , toStreamD
17 , toStreamD
18− , foldWith
19−
20− -- * Conversion operations
21− , fromList
22− , toList
23−
24− -- * Transformation
25− , list
26 )
18 )
27where
19where
28
20
29import Control.Applicative (liftA2)
21import Control.Applicative (liftA2)
30−import Control.DeepSeq (NFData1(..))
22+import Control.DeepSeq (NFData(..), NFData1(..))
31import Control.Monad.Base (MonadBase(..), liftBaseDefault)
23import Control.Monad.Base (MonadBase(..), liftBaseDefault)
32import Control.Monad.Catch (MonadThrow, throwM)
24import Control.Monad.Catch (MonadThrow, throwM)
33import Control.Monad.IO.Class (MonadIO(..))
25import Control.Monad.IO.Class (MonadIO(..))
34import Control.Monad.Reader.Class (MonadReader(..))
26import Control.Monad.Reader.Class (MonadReader(..))
35import Control.Monad.State.Class (MonadState(..))
27import Control.Monad.State.Class (MonadState(..))
36import Control.Monad.Trans.Class (MonadTrans(lift))
28import Control.Monad.Trans.Class (MonadTrans(lift))
29+import Data.Foldable (Foldable(foldl'), fold)
37import Data.Functor.Identity (Identity(..), runIdentity)
30import Data.Functor.Identity (Identity(..), runIdentity)
31+import Data.Maybe (fromMaybe)
32+import Data.Semigroup (Endo(..))
38#if __GLASGOW_HASKELL__ < 808
33#if __GLASGOW_HASKELL__ < 808
39import Data.Semigroup (Semigroup(..))
34import Data.Semigroup (Semigroup(..))
40#endif
35#endif
36+import GHC.Exts (IsList(..), IsString(..), oneShot)
37+import Streamly.Internal.BaseCompat ((#.))
41−import Streamly.Internal.Data.Fold.Type (Fold)
38+import Streamly.Internal.Data.Maybe.Strict (Maybe'(..), toMaybe)
39+import Text.Read
40+ ( Lexeme(Ident), lexP, parens, prec, readPrec, readListPrec
41+ , readListPrecDefault)
42
42
43import qualified Streamly.Internal.Data.Stream.Common as P
43import qualified Streamly.Internal.Data.Stream.Common as P
44−import qualified Streamly.Internal.Data.Stream.StreamD.Generate as D
45−import qualified Streamly.Internal.Data.Stream.StreamD.Transform as D
46import qualified Streamly.Internal.Data.Stream.StreamD.Type as D
44import qualified Streamly.Internal.Data.Stream.StreamD.Type as D
47import qualified Streamly.Internal.Data.Stream.StreamK.Type as K
45import qualified Streamly.Internal.Data.Stream.StreamK.Type as K
48
46
49−import Prelude hiding (map, mapM, repeat, filter)
50−
51#include "Instances.hs"
47#include "Instances.hs"
52#include "inline.hs"
48#include "inline.hs"
53
49
@@ -87,10 +83,30 @@ import Prelude hiding (map, mapM, repeat, filter)
87-- /Since: 0.2.0 ("Streamly")/
83-- /Since: 0.2.0 ("Streamly")/
88--
84--
89-- @since 0.8.0
85-- @since 0.8.0
90−newtype Stream m a = Stream {getStream :: K.Stream m a}
86+newtype Stream m a = Stream (K.Stream m a)
91 -- XXX when deriving do we inherit an INLINE?
87 -- XXX when deriving do we inherit an INLINE?
92 deriving (Semigroup, Monoid, MonadTrans)
88 deriving (Semigroup, Monoid, MonadTrans)
93
89
90+------------------------------------------------------------------------------
91+-- Conversions
92+------------------------------------------------------------------------------
93+
94+{-# INLINE fromStreamK #-}
95+fromStreamK :: K.Stream m a -> Stream m a
96+fromStreamK = Stream
97+
98+{-# INLINE toStreamK #-}
99+toStreamK :: Stream m a -> K.Stream m a
100+toStreamK (Stream k) = k
101+
102+{-# INLINE toStreamD #-}
103+toStreamD :: Applicative m => Stream m a -> D.Stream m a
104+toStreamD = D.fromStreamK . toStreamK
105+
106+{-# INLINE fromStreamD #-}
107+fromStreamD :: Monad m => D.Stream m a -> Stream m a
108+fromStreamD = fromStreamK . D.toStreamK
109+
94------------------------------------------------------------------------------
110------------------------------------------------------------------------------
95-- Monad
111-- Monad
96------------------------------------------------------------------------------
112------------------------------------------------------------------------------
@@ -109,7 +125,7 @@ instance Monad m => Monad (Stream m) where
109 -- n binds, breakAfterSome, filterAllIn, state transformer (~2x)
125 -- n binds, breakAfterSome, filterAllIn, state transformer (~2x)
110 --
126 --
111 {-# INLINE (>>=) #-}
127 {-# INLINE (>>=) #-}
112− (>>=) (Stream m) f = Stream $ K.bindWith K.serial m (getStream . f)
128+ (>>=) (Stream m) f = Stream $ K.bindWith K.serial m (toStreamK . f)
113
129
114 {-# INLINE (>>) #-}
130 {-# INLINE (>>) #-}
115 (>>) = (*>)
131 (>>) = (*>)
@@ -155,92 +171,7 @@ instance Monad m => Applicative (Stream m) where
155 -- (<*) = K.apSerialDiscardSnd
171 -- (<*) = K.apSerialDiscardSnd
156
172
157MONAD_COMMON_INSTANCES(Stream,)
173MONAD_COMMON_INSTANCES(Stream,)
174+LIST_INSTANCES(Stream)
158NFDATA1_INSTANCE(Stream)
175NFDATA1_INSTANCE(Stream)
159−
176+FOLDABLE_INSTANCE(Stream)
160−-- XXX Renamed to foldWith because Stream has a Foldable instance having
177+TRAVERSABLE_INSTANCE(Stream)
161−-- method fold.
162−--
163−-- | Fold a stream using the supplied left 'Fold' and reducing the resulting
164−-- expression strictly at each step. The behavior is similar to 'foldl''. A
165−-- 'Fold' can terminate early without consuming the full stream. See the
166−-- documentation of individual 'Fold's for termination behavior.
167−--
168−-- >>> Stream.foldWith Fold.sum (Stream.enumerateFromTo 1 100)
169−-- 5050
170−--
171−-- Folds never fail, therefore, they produce a default value even when no input
172−-- is provided. It means we can always fold an empty stream and get a valid
173−-- result. For example:
174−--
175−-- >>> Stream.foldWith Fold.sum Stream.nil
176−-- 0
177−--
178−-- However, 'foldMany' on an empty stream results in an empty stream.
179−-- Therefore, @Stream.foldWith f@ is not the same as @Stream.head . Stream.foldMany
180−-- f@.
181−--
182−-- @foldWith f = Stream.parse (Parser.fromFold f)@
183−--
184−-- /Pre-release/
185−{-# INLINE foldWith #-}
186−foldWith :: Monad m => Fold m a b -> Stream m a -> m b
187−foldWith fld m = D.fold fld $ toStreamD m
188−
189−-- XXX Renamed to "list" because fromList is present in IsList instance.
190−--
191−-- |
192−-- @
193−-- fromList = 'Prelude.foldr' 'K.cons' 'K.nil'
194−-- @
195−--
196−-- Construct a stream from a list of pure values. This is more efficient than
197−-- 'K.fromFoldable' for serial streams.
198−--
199−-- @since 0.4.0
200−{-# INLINE_EARLY list #-}
201−list :: Monad m => [a] -> Stream m a
202−list = fromStreamD . D.fromList
203−
204−------------------------------------------------------------------------------
205−-- Construction
206−------------------------------------------------------------------------------
207−
208−-- | Build a stream by unfolding a /monadic/ step function starting from a
209−-- seed. The step function returns the next element in the stream and the next
210−-- seed value. When it is done it returns 'Nothing' and the stream ends. For
211−-- example,
212−--
213−-- @
214−-- let f b =
215−-- if b > 3
216−-- then return Nothing
217−-- else print b >> return (Just (b, b + 1))
218−-- in drain $ unfoldrM f 0
219−-- @
220−-- @
221−-- 0
222−-- 1
223−-- 2
224−-- 3
225−-- @
226−--
227−-- /Pre-release/
228−--
229−{-# INLINE toStreamD #-}
230−toStreamD :: Applicative m => Stream m a -> D.Stream m a
231−toStreamD (Stream m) = D.fromStreamK m
232−
233−{-# INLINE fromStreamD #-}
234−fromStreamD :: Monad m => D.Stream m a -> Stream m a
235−fromStreamD m = Stream $ D.toStreamK m
236−
237−{-# INLINE_EARLY fromList #-}
238−fromList :: Monad m => [a] -> Stream m a
239−fromList = fromStreamD . D.fromList
240−
241−-- | Convert a stream into a list in the underlying monad.
242−--
243−-- @since 0.1.0
244−{-# INLINE toList #-}
245−toList :: Monad m => Stream m a -> m [a]
246−toList m = D.toList $ toStreamD m
core/streamly-core.cabal+5−5
@@ -290,15 +290,15 @@ library
290 , Streamly.Internal.Data.Fold.Window
290 , Streamly.Internal.Data.Fold.Window
291 , Streamly.Internal.Data.Parser
291 , Streamly.Internal.Data.Parser
292 , Streamly.Internal.Data.Pipe
292 , Streamly.Internal.Data.Pipe
293+ , Streamly.Internal.Data.Stream.Type
294+ , Streamly.Internal.Data.Stream.Eliminate
295+ , Streamly.Internal.Data.Stream.Generate
296+ , Streamly.Internal.Data.Stream.Transform
297+ , Streamly.Internal.Data.Stream
293 , Streamly.Internal.Data.Stream.Serial
298 , Streamly.Internal.Data.Stream.Serial
294 , Streamly.Internal.Data.Stream.WSerial
299 , Streamly.Internal.Data.Stream.WSerial
295 , Streamly.Internal.Data.Stream.Zip
300 , Streamly.Internal.Data.Stream.Zip
296 , Streamly.Internal.Data.List
301 , Streamly.Internal.Data.List
297− , Streamly.Internal.Data.Stream
298− , Streamly.Internal.Data.Stream.Eliminate
299− , Streamly.Internal.Data.Stream.Generate
300− , Streamly.Internal.Data.Stream.Transform
301− , Streamly.Internal.Data.Stream.Type
302
302
303 -- streamly-core-data-arrays
303 -- streamly-core-data-arrays
304 -- XXX Depends on primitive
304 -- XXX Depends on primitive
streamly.cabal+5−5
@@ -602,14 +602,14 @@ library
602 , Streamly.Internal.Data.Fold.Window
602 , Streamly.Internal.Data.Fold.Window
603 , Streamly.Internal.Data.Parser
603 , Streamly.Internal.Data.Parser
604 , Streamly.Internal.Data.Pipe
604 , Streamly.Internal.Data.Pipe
605− , Streamly.Internal.Data.Stream.Serial
605+ , Streamly.Internal.Data.Stream.Type
606− , Streamly.Internal.Data.Stream.Zip
607− , Streamly.Internal.Data.List
608− , Streamly.Internal.Data.Stream
609 , Streamly.Internal.Data.Stream.Eliminate
606 , Streamly.Internal.Data.Stream.Eliminate
610 , Streamly.Internal.Data.Stream.Generate
607 , Streamly.Internal.Data.Stream.Generate
611 , Streamly.Internal.Data.Stream.Transform
608 , Streamly.Internal.Data.Stream.Transform
612− , Streamly.Internal.Data.Stream.Type
609+ , Streamly.Internal.Data.Stream
610+ , Streamly.Internal.Data.Stream.Serial
611+ , Streamly.Internal.Data.Stream.Zip
612+ , Streamly.Internal.Data.List
613
613
614 -- streamly-core-data-arrays
614 -- streamly-core-data-arrays
615 -- XXX Depends on primitive
615 -- XXX Depends on primitive