on master help sign in
Make misc formatting, stylistic, comment changes
7e98cfeHarendra Kumar
src/Streamly.hs+1−1
@@ -272,7 +272,7 @@ import qualified Streamly.Internal.Data.Stream.Async as Async
272-- reducers of streams. Reducers can be combined to consume a stream source in
272-- reducers of streams. Reducers can be combined to consume a stream source in
273-- many ways. The simplest is to reduce a stream source using a fold e.g.:
273-- many ways. The simplest is to reduce a stream source using a fold e.g.:
274--
274--
275−-- > S.foldOnce FL.length $ S.enumerateTo 100
275+-- > S.fold FL.length $ S.enumerateTo 100
276--
276--
277-- Folds are consumers of streams and can be used to split a stream into
277-- Folds are consumers of streams and can be used to split a stream into
278-- multiple independent flows. Grouping transforms a stream by applying a fold
278-- multiple independent flows. Grouping transforms a stream by applying a fold
src/Streamly/Internal/Data/Array.hs+5−5
@@ -49,20 +49,20 @@ import Control.DeepSeq (NFData(..))
49#endif
49#endif
50import Control.Monad (when)
50import Control.Monad (when)
51import Control.Monad.IO.Class (liftIO, MonadIO)
51import Control.Monad.IO.Class (liftIO, MonadIO)
52−import GHC.IO (unsafePerformIO)
53−import GHC.Base (Int(..))
54import Data.Functor.Identity (runIdentity)
52import Data.Functor.Identity (runIdentity)
55import Data.Primitive.Array hiding (fromList, fromListN)
53import Data.Primitive.Array hiding (fromList, fromListN)
54+import GHC.Base (Int(..))
55+import GHC.IO (unsafePerformIO)
56import qualified GHC.Exts as Exts
56import qualified GHC.Exts as Exts
57
57
58−import Streamly.Internal.Data.Tuple.Strict (Tuple'(..), Tuple3'(..))
59−import Streamly.Internal.Data.Unfold.Types (Unfold(..))
60import Streamly.Internal.Data.Fold.Types (Fold(..))
58import Streamly.Internal.Data.Fold.Types (Fold(..))
61import Streamly.Internal.Data.Stream.StreamK.Type (IsStream)
59import Streamly.Internal.Data.Stream.StreamK.Type (IsStream)
62import Streamly.Internal.Data.Stream.Serial (SerialT)
60import Streamly.Internal.Data.Stream.Serial (SerialT)
61+import Streamly.Internal.Data.Tuple.Strict (Tuple'(..), Tuple3'(..))
62+import Streamly.Internal.Data.Unfold.Types (Unfold(..))
63
63
64−import qualified Streamly.Internal.Data.Stream.StreamD as D
65import qualified Streamly.Internal.Data.Fold.Types as FL
64import qualified Streamly.Internal.Data.Fold.Types as FL
65+import qualified Streamly.Internal.Data.Stream.StreamD as D
66
66
67{-# NOINLINE bottomElement #-}
67{-# NOINLINE bottomElement #-}
68bottomElement :: a
68bottomElement :: a
src/Streamly/Internal/Data/Array/Prim/MutTypesInclude.hs+7−4
@@ -354,16 +354,19 @@ packArraysChunksOf n (D.Stream step state) =
354{-# INLINE_NORMAL lpackArraysChunksOf #-}
354{-# INLINE_NORMAL lpackArraysChunksOf #-}
355lpackArraysChunksOf ::
355lpackArraysChunksOf ::
356 (MonadIO m, Prim a) => Int -> Fold m (Array a) () -> Fold m (Array a) ()
356 (MonadIO m, Prim a) => Int -> Fold m (Array a) () -> Fold m (Array a) ()
357−lpackArraysChunksOf n (Fold step1 initial1 extract1) = Fold step initial extract
357+lpackArraysChunksOf n (Fold step1 initial1 extract1) =
358+ Fold step initial extract
358
359
359 where
360 where
360
361
361 initial = do
362 initial = do
362 when (n <= 0)
363 when (n <= 0)
363− $ error
364− $ "Streamly.Internal.Data.Array.Storable.Foreign.Mut.Types.packArraysChunksOf: the size of "
365− ++ "arrays [" ++ show n ++ "] must be a natural number"
366 -- XXX we can pass the module string from the higher level API
364 -- XXX we can pass the module string from the higher level API
365+ $ error
366+ $ "Streamly.Internal.Data.Array.Storable.Foreign.Mut.Types."
367+ ++ "packArraysChunksOf: the size of arrays ["
368+ ++ show n
369+ ++ "] must be a natural number"
367 r1 <- initial1
370 r1 <- initial1
368 return (Tuple' Nothing r1)
371 return (Tuple' Nothing r1)
369
372
src/Streamly/Internal/Data/Array/Storable/Foreign/Mut/Types.hs+4−3
@@ -119,11 +119,11 @@ import Text.Read (readPrec, readListPrec, readListPrecDefault)
119#ifdef DEVBUILD
119#ifdef DEVBUILD
120import qualified Data.Foldable as F
120import qualified Data.Foldable as F
121#endif
121#endif
122−import qualified Streamly.Internal.Foreign.Malloc as Malloc
122+import qualified GHC.Exts as Exts
123+import qualified Streamly.Internal.Data.Fold as FL
123import qualified Streamly.Internal.Data.Stream.StreamD.Type as D
124import qualified Streamly.Internal.Data.Stream.StreamD.Type as D
124import qualified Streamly.Internal.Data.Stream.StreamK as K
125import qualified Streamly.Internal.Data.Stream.StreamK as K
125−import qualified Streamly.Internal.Data.Fold as FL
126+import qualified Streamly.Internal.Foreign.Malloc as Malloc
126−import qualified GHC.Exts as Exts
127
127
128import Prelude hiding (length, foldr, read, unlines, splitAt)
128import Prelude hiding (length, foldr, read, unlines, splitAt)
129
129
@@ -704,6 +704,7 @@ lpackArraysChunksOf n (Fold step1 initial1 extract1) =
704 else return buf
704 else return buf
705 buf'' <- spliceWith buf' arr
705 buf'' <- spliceWith buf' arr
706
706
707+ -- XXX this is common in both the equations of step
707 if len >= n
708 if len >= n
708 then do
709 then do
709 r <- step1 r1 buf''
710 r <- step1 r1 buf''
src/Streamly/Internal/Data/Array/Storable/Foreign/Types.hs−1
@@ -344,7 +344,6 @@ fromStreamDN limit str = unsafeFreeze <$> MA.fromStreamDN limit str
344-- Streams of arrays
344-- Streams of arrays
345-------------------------------------------------------------------------------
345-------------------------------------------------------------------------------
346
346
347−-- XXX Investigare performance. fusion-plugin solves the issue though
348-- | @fromStreamArraysOf n stream@ groups the input stream into a stream of
347-- | @fromStreamArraysOf n stream@ groups the input stream into a stream of
349-- arrays of size n.
348-- arrays of size n.
350{-# INLINE_NORMAL fromStreamDArraysOf #-}
349{-# INLINE_NORMAL fromStreamDArraysOf #-}
src/Streamly/Internal/Data/Stream/StreamK.hs+7−7
@@ -436,20 +436,20 @@ foldlMx' step begin done m = go begin m
436
436
437{-# INLINABLE foldOnce #-}
437{-# INLINABLE foldOnce #-}
438foldOnce :: (IsStream t, Monad m) => FL.Fold m a b -> t m a -> m b
438foldOnce :: (IsStream t, Monad m) => FL.Fold m a b -> t m a -> m b
439−foldOnce (FL.Fold step begin done) m = go begin m
439+foldOnce (FL.Fold step begin done) = go begin
440 where
440 where
441 go !acc m1 =
441 go !acc m1 =
442 let stop = acc >>= done
442 let stop = acc >>= done
443 single a = acc
443 single a = acc
444 >>= \b -> step b a
444 >>= \b -> step b a
445− >>= \x -> case x of
445+ >>= \case
446− FL.Partial s -> done s
446+ FL.Partial s -> done s
447− FL.Done b1 -> return b1
447+ FL.Done b1 -> return b1
448 yieldk a r = acc
448 yieldk a r = acc
449 >>= \b -> step b a
449 >>= \b -> step b a
450− >>= \x -> case x of
450+ >>= \case
451− FL.Partial s -> go (return s) r
451+ FL.Partial s -> go (return s) r
452− FL.Done b1 -> return b1
452+ FL.Done b1 -> return b1
453 in foldStream defState yieldk single stop m1
453 in foldStream defState yieldk single stop m1
454
454
455-- | Like 'foldl'' but with a monadic step function.
455-- | Like 'foldl'' but with a monadic step function.
src/Streamly/Internal/Data/Unfold.hs+1−1
@@ -163,9 +163,9 @@ import System.Mem (performMajorGC)
163import qualified Prelude
163import qualified Prelude
164import qualified Control.Monad.Catch as MC
164import qualified Control.Monad.Catch as MC
165import qualified Data.Tuple as Tuple
165import qualified Data.Tuple as Tuple
166+import qualified Streamly.Internal.Data.Fold.Types as FL
166import qualified Streamly.Internal.Data.Stream.StreamK as K
167import qualified Streamly.Internal.Data.Stream.StreamK as K
167import qualified Streamly.Internal.Data.Stream.StreamD as D
168import qualified Streamly.Internal.Data.Stream.StreamD as D
168−import qualified Streamly.Internal.Data.Fold.Types as FL
169
169
170import Streamly.Internal.Data.SVar
170import Streamly.Internal.Data.SVar
171import Prelude
171import Prelude
src/Streamly/Internal/Network/Inet/TCP.hs+5−5
@@ -103,15 +103,15 @@ import Network.Socket
103 socket)
103 socket)
104import Prelude hiding (read)
104import Prelude hiding (read)
105
105
106−import Streamly.Prelude (MonadAsync)
106+import Streamly.Internal.Data.Array.Storable.Foreign.Types (Array(..), defaultChunkSize, writeNUnsafe)
107−import Streamly.Internal.Data.Tuple.Strict (Tuple'(..))
108import Streamly.Internal.Data.Fold.Types (Fold(..))
107import Streamly.Internal.Data.Fold.Types (Fold(..))
109import Streamly.Internal.Data.SVar (fork)
108import Streamly.Internal.Data.SVar (fork)
110−import Streamly.Internal.Data.Unfold.Types (Unfold(..))
111−import Streamly.Internal.Network.Socket (SockSpec(..), accept, connections)
112import Streamly.Internal.Data.Stream.Serial (SerialT)
109import Streamly.Internal.Data.Stream.Serial (SerialT)
113−import Streamly.Internal.Data.Array.Storable.Foreign.Types (Array(..), defaultChunkSize, writeNUnsafe)
114import Streamly.Internal.Data.Stream.StreamK.Type (IsStream)
110import Streamly.Internal.Data.Stream.StreamK.Type (IsStream)
111+import Streamly.Internal.Data.Tuple.Strict (Tuple'(..))
112+import Streamly.Internal.Data.Unfold.Types (Unfold(..))
113+import Streamly.Internal.Network.Socket (SockSpec(..), accept, connections)
114+import Streamly.Prelude (MonadAsync)
115
115
116import qualified Control.Monad.Catch as MC
116import qualified Control.Monad.Catch as MC
117import qualified Network.Socket as Net
117import qualified Network.Socket as Net