on master help sign in
Rename Fold.yield, yieldM to fromPure, fromEffect.
commit90be38762bc085c57ac2f3fdfb49286cfb1436a4 authorPranay Sashank <pranaysashank@composewell.com> dateSat 29 May 2021, 23:03 (5 years ago) parentf24ddc0
5 files changed+27−27
benchmark/Streamly/Benchmark/Data/Fold.hs+1−1 src/Streamly/Internal/Data/Array/Stream/Fold/Foreign.hs+9−9 src/Streamly/Internal/Data/Fold.hs+4−4 src/Streamly/Internal/Data/Fold/Tee.hs+1−1 src/Streamly/Internal/Data/Fold/Type.hs+12−12
benchmark/Streamly/Benchmark/Data/Fold.hs+1−1
@@ -70,7 +70,7 @@ take value = IP.fold (FL.take value FL.drain)
7070{-# INLINE sequence_ #-}
7171sequence_ :: Monad m => Int -> Fold m a ()
7272sequence_ value =
73− foldr f (FL.yield ()) (Prelude.replicate value (FL.take 1 FL.drain))
73+ foldr f (FL.fromPure ()) (Prelude.replicate value (FL.take 1 FL.drain))
7474
7575 where
7676
src/Streamly/Internal/Data/Array/Stream/Fold/Foreign.hs+9−9
@@ -39,8 +39,8 @@ module Streamly.Internal.Data.Array.Stream.Fold.Foreign
3939 , rmapM
4040
4141 -- * Applicative
42− , yield
43− , yieldM
42+ , fromPure
43+ , fromEffect
4444 , serialWith
4545
4646 -- * Monad
@@ -204,18 +204,18 @@ rmapM f (Fold p) = Fold $ ParserD.rmapM f p
204204--
205205-- /Pre-release/
206206--
207−{-# INLINE yield #-}
208−yield :: Monad m => b -> Fold m a b
209−yield = Fold . ParserD.yield
207+{-# INLINE fromPure #-}
208+fromPure :: Monad m => b -> Fold m a b
209+fromPure = Fold . ParserD.yield
210210
211211-- | A fold that always yields the result of an effectful action without
212212-- consuming any input.
213213--
214214-- /Pre-release/
215215--
216−{-# INLINE yieldM #-}
217−yieldM :: Monad m => m b -> Fold m a b
218−yieldM = Fold . ParserD.yieldM
216+{-# INLINE fromEffect #-}
217+fromEffect :: Monad m => m b -> Fold m a b
218+fromEffect = Fold . ParserD.yieldM
219219
220220-- | Applies two folds sequentially on the input stream and combines their
221221-- results using the supplied function.
@@ -239,7 +239,7 @@ serialWith f (Fold p1) (Fold p2) =
239239-- > (<*>) = serialWith id
240240instance MonadThrow m => Applicative (Fold m a) where
241241 {-# INLINE pure #-}
242− pure = yield
242+ pure = fromPure
243243
244244 {-# INLINE (<*>) #-}
245245 (<*>) = serialWith id
src/Streamly/Internal/Data/Fold.hs+4−4
@@ -31,8 +31,8 @@ module Streamly.Internal.Data.Fold
3131
3232 -- * Folds
3333 -- ** Identity
34− , yield
35− , yieldM
34+ , fromPure
35+ , fromEffect
3636
3737 -- ** Accumulators
3838 -- *** Semigroups and Monoids
@@ -1092,7 +1092,7 @@ tee = teeWith (,)
10921092-- >>> Stream.fold (Fold.distribute [Fold.sum, Fold.length]) (Stream.enumerateFromTo 1 5)
10931093-- [15,5]
10941094--
1095−-- > distribute = Prelude.foldr (Fold.teeWith (:)) (Fold.yield [])
1095+-- > distribute = Prelude.foldr (Fold.teeWith (:)) (Fold.fromPure [])
10961096--
10971097-- This is the consumer side dual of the producer side 'sequence' operation.
10981098--
@@ -1101,7 +1101,7 @@ tee = teeWith (,)
11011101-- @since 0.7.0
11021102{-# INLINE distribute #-}
11031103distribute :: Monad m => [Fold m a b] -> Fold m a [b]
1104−distribute = Prelude.foldr (teeWith (:)) (yield [])
1104+distribute = Prelude.foldr (teeWith (:)) (fromPure [])
11051105
11061106------------------------------------------------------------------------------
11071107-- Partitioning
src/Streamly/Internal/Data/Fold/Tee.hs+1−1
@@ -37,7 +37,7 @@ newtype Tee m a b =
3737instance Monad m => Applicative (Tee m a) where
3838
3939 {-# INLINE pure #-}
40− pure a = Tee (Fold.yield a)
40+ pure a = Tee (Fold.fromPure a)
4141
4242 {-# INLINE (<*>) #-}
4343 (<*>) a b = Tee (Fold.teeWith ($) (toFold a) (toFold b))
src/Streamly/Internal/Data/Fold/Type.hs+12−12
@@ -207,8 +207,8 @@ module Streamly.Internal.Data.Fold.Type
207207 , mkFoldM_
208208
209209 -- * Folds
210− , yield
211− , yieldM
210+ , fromPure
211+ , fromEffect
212212 , drain
213213 , toList
214214
@@ -616,26 +616,26 @@ instance Functor m => Functor (Fold m a) where
616616 step s b = fmap2 f (step1 s b)
617617 fmap2 g = fmap (fmap g)
618618
619−-- This is the dual of stream "yield".
619+-- This is the dual of stream "fromPure".
620620--
621621-- | A fold that always yields a pure value without consuming any input.
622622--
623623-- /Pre-release/
624624--
625−{-# INLINE yield #-}
626−yield :: Applicative m => b -> Fold m a b
627−yield b = Fold undefined (pure $ Done b) pure
625+{-# INLINE fromPure #-}
626+fromPure :: Applicative m => b -> Fold m a b
627+fromPure b = Fold undefined (pure $ Done b) pure
628628
629−-- This is the dual of stream "yieldM".
629+-- This is the dual of stream "fromEffect".
630630--
631631-- | A fold that always yields the result of an effectful action without
632632-- consuming any input.
633633--
634634-- /Pre-release/
635635--
636−{-# INLINE yieldM #-}
637−yieldM :: Applicative m => m b -> Fold m a b
638−yieldM b = Fold undefined (Done <$> b) pure
636+{-# INLINE fromEffect #-}
637+fromEffect :: Applicative m => m b -> Fold m a b
638+fromEffect b = Fold undefined (Done <$> b) pure
639639
640640{-# ANN type Step Fuse #-}
641641data SeqFoldState sl f sr = SeqFoldL !sl | SeqFoldR !f !sr
@@ -1030,9 +1030,9 @@ duplicate (Fold step1 initial1 extract1) =
10301030
10311031 where
10321032
1033− initial = second yield <$> initial1
1033+ initial = second fromPure <$> initial1
10341034
1035− step s a = second yield <$> step1 s a
1035+ step s a = second fromPure <$> step1 s a
10361036
10371037-- | Run the initialization effect of a fold. The returned fold would use the
10381038-- value returned by this effect as its initial value.