on master help sign in
Make minor refactoring changes for fromPure/fromEffect
79defebHarendra Kumar
src/Streamly/Internal/Data/Stream/Ahead.hs+1−1
@@ -136,7 +136,7 @@ import Prelude hiding (map)
136-- XXX It may be a good idea to increment sequence numbers for each yield,
136-- XXX It may be a good idea to increment sequence numbers for each yield,
137-- currently a stream on the left side of the expression may yield many
137-- currently a stream on the left side of the expression may yield many
138-- elements with the same sequene number. We can then use the seq number to
138-- elements with the same sequene number. We can then use the seq number to
139−-- enforce fromEffectax and yieldLImit as well.
139+-- enforce yieldMax and yieldLImit as well.
140
140
141-- Invariants:
141-- Invariants:
142--
142--
src/Streamly/Internal/Data/Stream/IsStream/Common.hs+15−16
@@ -119,6 +119,14 @@ import Prelude hiding (take, takeWhile, drop, reverse, concatMap)
119fromPure :: IsStream t => a -> t m a
119fromPure :: IsStream t => a -> t m a
120fromPure = K.fromPure
120fromPure = K.fromPure
121
121
122+-- | Same as 'fromPure'
123+--
124+-- @since 0.4.0
125+{-# DEPRECATED yield "Please use fromPure instead." #-}
126+{-# INLINE yield #-}
127+yield :: IsStream t => a -> t m a
128+yield = fromPure
129+
122-- |
130-- |
123-- @
131-- @
124-- fromEffect m = m \`consM` nil
132-- fromEffect m = m \`consM` nil
@@ -138,6 +146,13 @@ fromPure = K.fromPure
138fromEffect :: (Monad m, IsStream t) => m a -> t m a
146fromEffect :: (Monad m, IsStream t) => m a -> t m a
139fromEffect = K.fromEffect
147fromEffect = K.fromEffect
140
148
149+-- | Same as 'fromEffect'
150+--
151+-- @since 0.4.0
152+{-# DEPRECATED yieldM "Please use fromEffect instead." #-}
153+{-# INLINE yieldM #-}
154+yieldM :: (Monad m, IsStream t) => m a -> t m a
155+yieldM = fromEffect
141-- |
156-- |
142-- @
157-- @
143-- repeatM = fix . consM
158-- repeatM = fix . consM
@@ -551,19 +566,3 @@ splitOnSeq
551 :: (IsStream t, MonadIO m, Storable a, Enum a, Eq a)
566 :: (IsStream t, MonadIO m, Storable a, Enum a, Eq a)
552 => Array a -> Fold m a b -> t m a -> t m b
567 => Array a -> Fold m a b -> t m a -> t m b
553splitOnSeq patt f m = D.fromStreamD $ D.splitOnSeq patt f (D.toStreamD m)
568splitOnSeq patt f m = D.fromStreamD $ D.splitOnSeq patt f (D.toStreamD m)
554−
555−-- | Same as 'fromPure'
556−--
557−-- @since 0.4.0
558−{-# DEPRECATED yield "Please use fromPure instead." #-}
559−{-# INLINE yield #-}
560−yield :: IsStream t => a -> t m a
561−yield = fromPure
562−
563−-- | Same as 'fromEffect'
564−--
565−-- @since 0.4.0
566−{-# DEPRECATED yieldM "Please use fromEffect instead." #-}
567−{-# INLINE yieldM #-}
568−yieldM :: (Monad m, IsStream t) => m a -> t m a
569−yieldM = fromEffect
test/Streamly/Test/Prelude/Serial.hs+1−1
@@ -558,7 +558,7 @@ main = hspec
558 serialOps $ prop "serially fromList" . constructWithFromList id
558 serialOps $ prop "serially fromList" . constructWithFromList id
559 serialOps $ prop "serially fromListM" . constructWithFromListM id
559 serialOps $ prop "serially fromListM" . constructWithFromListM id
560 serialOps $ prop "serially unfoldr" . constructWithUnfoldr id
560 serialOps $ prop "serially unfoldr" . constructWithUnfoldr id
561− serialOps $ prop "serially fromPure" . constructWithYield id
561+ serialOps $ prop "serially fromPure" . constructWithFromPure id
562 serialOps $ prop "serially fromEffect" . constructWithFromEffect id
562 serialOps $ prop "serially fromEffect" . constructWithFromEffect id
563 serialOps $ prop "serially cons" . constructWithCons S.cons
563 serialOps $ prop "serially cons" . constructWithCons S.cons
564 serialOps $ prop "serially consM" . constructWithConsM S.consM id
564 serialOps $ prop "serially consM" . constructWithConsM S.consM id
test/lib/Streamly/Test/Prelude/Common.hs+3−3
@@ -29,7 +29,7 @@ module Streamly.Test.Prelude.Common
29 , constructWithUnfoldr
29 , constructWithUnfoldr
30 , constructWithCons
30 , constructWithCons
31 , constructWithConsM
31 , constructWithConsM
32− , constructWithYield
32+ , constructWithFromPure
33 , constructWithFromEffect
33 , constructWithFromEffect
34 , simpleOps
34 , simpleOps
35 -- * Applicative operations
35 -- * Applicative operations
@@ -395,7 +395,7 @@ constructWithUnfoldr listT op len =
395 then Nothing
395 then Nothing
396 else Just (seed, seed + 1)
396 else Just (seed, seed + 1)
397
397
398−constructWithYield ::
398+constructWithFromPure ::
399 (IsStream t
399 (IsStream t
400#if __GLASGOW_HASKELL__ < 806
400#if __GLASGOW_HASKELL__ < 806
401 , Monoid (t IO Int)
401 , Monoid (t IO Int)
@@ -405,7 +405,7 @@ constructWithYield ::
405 -> (t IO Int -> SerialT IO Int)
405 -> (t IO Int -> SerialT IO Int)
406 -> Word8
406 -> Word8
407 -> Property
407 -> Property
408−constructWithYield listT op len =
408+constructWithFromPure listT op len =
409 withMaxSuccess maxTestCount $
409 withMaxSuccess maxTestCount $
410 monadicIO $ do
410 monadicIO $ do
411 strm <-
411 strm <-