on master help sign in
Make minor refactoring changes for fromPure/fromEffect

* Move deprecated functions next to original ones, keep them in the generate section itself. * Rename constructWithYield to constructWithFromPure * Fix typo

commit79defeb5ec021e741264f1869911877a909c0851 authorHarendra Kumar <harendra@composewell.com> dateSat 29 May 2021, 11:36 (5 years ago) parent70faf01
4 files changed+20−21
src/Streamly/Internal/Data/Stream/Ahead.hs+1−1 src/Streamly/Internal/Data/Stream/IsStream/Common.hs+15−16 test/Streamly/Test/Prelude/Serial.hs+1−1 test/lib/Streamly/Test/Prelude/Common.hs+3−3
src/Streamly/Internal/Data/Stream/Ahead.hs+1−1
@@ -136,7 +136,7 @@ import Prelude hiding (map)
136136-- XXX It may be a good idea to increment sequence numbers for each yield,
137137-- currently a stream on the left side of the expression may yield many
138138-- 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.
140140
141141-- Invariants:
142142--
src/Streamly/Internal/Data/Stream/IsStream/Common.hs+15−16
@@ -119,6 +119,14 @@ import Prelude hiding (take, takeWhile, drop, reverse, concatMap)
119119fromPure :: IsStream t => a -> t m a
120120fromPure = K.fromPure
121121
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+
122130-- |
123131-- @
124132-- fromEffect m = m \`consM` nil
@@ -138,6 +146,13 @@ fromPure = K.fromPure
138146fromEffect :: (Monad m, IsStream t) => m a -> t m a
139147fromEffect = K.fromEffect
140148
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
141156-- |
142157-- @
143158-- repeatM = fix . consM
@@ -551,19 +566,3 @@ splitOnSeq
551566 :: (IsStream t, MonadIO m, Storable a, Enum a, Eq a)
552567 => Array a -> Fold m a b -> t m a -> t m b
553568splitOnSeq 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
558558 serialOps $ prop "serially fromList" . constructWithFromList id
559559 serialOps $ prop "serially fromListM" . constructWithFromListM id
560560 serialOps $ prop "serially unfoldr" . constructWithUnfoldr id
561− serialOps $ prop "serially fromPure" . constructWithYield id
561+ serialOps $ prop "serially fromPure" . constructWithFromPure id
562562 serialOps $ prop "serially fromEffect" . constructWithFromEffect id
563563 serialOps $ prop "serially cons" . constructWithCons S.cons
564564 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
2929 , constructWithUnfoldr
3030 , constructWithCons
3131 , constructWithConsM
32− , constructWithYield
32+ , constructWithFromPure
3333 , constructWithFromEffect
3434 , simpleOps
3535 -- * Applicative operations
@@ -395,7 +395,7 @@ constructWithUnfoldr listT op len =
395395 then Nothing
396396 else Just (seed, seed + 1)
397397
398−constructWithYield ::
398+constructWithFromPure ::
399399 (IsStream t
400400#if __GLASGOW_HASKELL__ < 806
401401 , Monoid (t IO Int)
@@ -405,7 +405,7 @@ constructWithYield ::
405405 -> (t IO Int -> SerialT IO Int)
406406 -> Word8
407407 -> Property
408−constructWithYield listT op len =
408+constructWithFromPure listT op len =
409409 withMaxSuccess maxTestCount $
410410 monadicIO $ do
411411 strm <-