on master help sign in
Rename Fold.yield, yieldM to fromPure, fromEffect.
90be387Pranay Sashank
benchmark/Streamly/Benchmark/Data/Fold.hs+1−1
@@ -70,7 +70,7 @@ take value = IP.fold (FL.take value FL.drain)
70{-# INLINE sequence_ #-}
70{-# INLINE sequence_ #-}
71sequence_ :: Monad m => Int -> Fold m a ()
71sequence_ :: Monad m => Int -> Fold m a ()
72sequence_ value =
72sequence_ 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))
74
74
75 where
75 where
76
76
src/Streamly/Internal/Data/Array/Stream/Fold/Foreign.hs+9−9
@@ -39,8 +39,8 @@ module Streamly.Internal.Data.Array.Stream.Fold.Foreign
39 , rmapM
39 , rmapM
40
40
41 -- * Applicative
41 -- * Applicative
42− , yield
42+ , fromPure
43− , yieldM
43+ , fromEffect
44 , serialWith
44 , serialWith
45
45
46 -- * Monad
46 -- * Monad
@@ -204,18 +204,18 @@ rmapM f (Fold p) = Fold $ ParserD.rmapM f p
204--
204--
205-- /Pre-release/
205-- /Pre-release/
206--
206--
207−{-# INLINE yield #-}
207+{-# INLINE fromPure #-}
208−yield :: Monad m => b -> Fold m a b
208+fromPure :: Monad m => b -> Fold m a b
209−yield = Fold . ParserD.yield
209+fromPure = Fold . ParserD.yield
210
210
211-- | A fold that always yields the result of an effectful action without
211-- | A fold that always yields the result of an effectful action without
212-- consuming any input.
212-- consuming any input.
213--
213--
214-- /Pre-release/
214-- /Pre-release/
215--
215--
216−{-# INLINE yieldM #-}
216+{-# INLINE fromEffect #-}
217−yieldM :: Monad m => m b -> Fold m a b
217+fromEffect :: Monad m => m b -> Fold m a b
218−yieldM = Fold . ParserD.yieldM
218+fromEffect = Fold . ParserD.yieldM
219
219
220-- | Applies two folds sequentially on the input stream and combines their
220-- | Applies two folds sequentially on the input stream and combines their
221-- results using the supplied function.
221-- results using the supplied function.
@@ -239,7 +239,7 @@ serialWith f (Fold p1) (Fold p2) =
239-- > (<*>) = serialWith id
239-- > (<*>) = serialWith id
240instance MonadThrow m => Applicative (Fold m a) where
240instance MonadThrow m => Applicative (Fold m a) where
241 {-# INLINE pure #-}
241 {-# INLINE pure #-}
242− pure = yield
242+ pure = fromPure
243
243
244 {-# INLINE (<*>) #-}
244 {-# INLINE (<*>) #-}
245 (<*>) = serialWith id
245 (<*>) = serialWith id
src/Streamly/Internal/Data/Fold.hs+4−4
@@ -31,8 +31,8 @@ module Streamly.Internal.Data.Fold
31
31
32 -- * Folds
32 -- * Folds
33 -- ** Identity
33 -- ** Identity
34− , yield
34+ , fromPure
35− , yieldM
35+ , fromEffect
36
36
37 -- ** Accumulators
37 -- ** Accumulators
38 -- *** Semigroups and Monoids
38 -- *** Semigroups and Monoids
@@ -1092,7 +1092,7 @@ tee = teeWith (,)
1092-- >>> Stream.fold (Fold.distribute [Fold.sum, Fold.length]) (Stream.enumerateFromTo 1 5)
1092-- >>> Stream.fold (Fold.distribute [Fold.sum, Fold.length]) (Stream.enumerateFromTo 1 5)
1093-- [15,5]
1093-- [15,5]
1094--
1094--
1095−-- > distribute = Prelude.foldr (Fold.teeWith (:)) (Fold.yield [])
1095+-- > distribute = Prelude.foldr (Fold.teeWith (:)) (Fold.fromPure [])
1096--
1096--
1097-- This is the consumer side dual of the producer side 'sequence' operation.
1097-- This is the consumer side dual of the producer side 'sequence' operation.
1098--
1098--
@@ -1101,7 +1101,7 @@ tee = teeWith (,)
1101-- @since 0.7.0
1101-- @since 0.7.0
1102{-# INLINE distribute #-}
1102{-# INLINE distribute #-}
1103distribute :: Monad m => [Fold m a b] -> Fold m a [b]
1103distribute :: Monad m => [Fold m a b] -> Fold m a [b]
1104−distribute = Prelude.foldr (teeWith (:)) (yield [])
1104+distribute = Prelude.foldr (teeWith (:)) (fromPure [])
1105
1105
1106------------------------------------------------------------------------------
1106------------------------------------------------------------------------------
1107-- Partitioning
1107-- Partitioning
src/Streamly/Internal/Data/Fold/Tee.hs+1−1
@@ -37,7 +37,7 @@ newtype Tee m a b =
37instance Monad m => Applicative (Tee m a) where
37instance Monad m => Applicative (Tee m a) where
38
38
39 {-# INLINE pure #-}
39 {-# INLINE pure #-}
40− pure a = Tee (Fold.yield a)
40+ pure a = Tee (Fold.fromPure a)
41
41
42 {-# INLINE (<*>) #-}
42 {-# INLINE (<*>) #-}
43 (<*>) a b = Tee (Fold.teeWith ($) (toFold a) (toFold b))
43 (<*>) 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
207 , mkFoldM_
207 , mkFoldM_
208
208
209 -- * Folds
209 -- * Folds
210− , yield
210+ , fromPure
211− , yieldM
211+ , fromEffect
212 , drain
212 , drain
213 , toList
213 , toList
214
214
@@ -616,26 +616,26 @@ instance Functor m => Functor (Fold m a) where
616 step s b = fmap2 f (step1 s b)
616 step s b = fmap2 f (step1 s b)
617 fmap2 g = fmap (fmap g)
617 fmap2 g = fmap (fmap g)
618
618
619−-- This is the dual of stream "yield".
619+-- This is the dual of stream "fromPure".
620--
620--
621-- | A fold that always yields a pure value without consuming any input.
621-- | A fold that always yields a pure value without consuming any input.
622--
622--
623-- /Pre-release/
623-- /Pre-release/
624--
624--
625−{-# INLINE yield #-}
625+{-# INLINE fromPure #-}
626−yield :: Applicative m => b -> Fold m a b
626+fromPure :: Applicative m => b -> Fold m a b
627−yield b = Fold undefined (pure $ Done b) pure
627+fromPure b = Fold undefined (pure $ Done b) pure
628
628
629−-- This is the dual of stream "yieldM".
629+-- This is the dual of stream "fromEffect".
630--
630--
631-- | A fold that always yields the result of an effectful action without
631-- | A fold that always yields the result of an effectful action without
632-- consuming any input.
632-- consuming any input.
633--
633--
634-- /Pre-release/
634-- /Pre-release/
635--
635--
636−{-# INLINE yieldM #-}
636+{-# INLINE fromEffect #-}
637−yieldM :: Applicative m => m b -> Fold m a b
637+fromEffect :: Applicative m => m b -> Fold m a b
638−yieldM b = Fold undefined (Done <$> b) pure
638+fromEffect b = Fold undefined (Done <$> b) pure
639
639
640{-# ANN type Step Fuse #-}
640{-# ANN type Step Fuse #-}
641data SeqFoldState sl f sr = SeqFoldL !sl | SeqFoldR !f !sr
641data SeqFoldState sl f sr = SeqFoldL !sl | SeqFoldR !f !sr
@@ -1030,9 +1030,9 @@ duplicate (Fold step1 initial1 extract1) =
1030
1030
1031 where
1031 where
1032
1032
1033− initial = second yield <$> initial1
1033+ initial = second fromPure <$> initial1
1034
1034
1035− step s a = second yield <$> step1 s a
1035+ step s a = second fromPure <$> step1 s a
1036
1036
1037-- | Run the initialization effect of a fold. The returned fold would use the
1037-- | Run the initialization effect of a fold. The returned fold would use the
1038-- value returned by this effect as its initial value.
1038-- value returned by this effect as its initial value.