on master help sign in
Rename Unfold.yield, yieldM to fromPure, fromEffect.
commitf24ddc0bdf6602ebf1cb14be5f169f23e003b928 authorPranay Sashank <pranaysashank@composewell.com> dateSat 29 May 2021, 20:09 (5 years ago) parent47d0e89
5 files changed+23−23
benchmark/Streamly/Benchmark/Data/Unfold.hs+9−9 src/Streamly/Internal/Data/Pipe.hs+1−1 src/Streamly/Internal/Data/Unfold.hs+2−2 src/Streamly/Internal/Data/Unfold/Type.hs+10−10 test/Streamly/Test/Data/Unfold.hs+1−1
benchmark/Streamly/Benchmark/Data/Unfold.hs+9−9
@@ -196,7 +196,7 @@ _identity _ start = drainGeneration UF.identity start
196196{-# INLINE _const #-}
197197_const :: Monad m => Int -> Int -> m ()
198198_const size start =
199− drainGeneration (UF.take size (UF.yieldM (return start))) undefined
199+ drainGeneration (UF.take size (UF.fromEffect (return start))) undefined
200200
201201{-# INLINE unfoldrM #-}
202202unfoldrM :: Monad m => Int -> Int -> m ()
@@ -450,7 +450,7 @@ toNull value start =
450450 -}
451451 u = src `UF.bind` \x ->
452452 src `UF.bind` \y ->
453− UF.yield (x + y)
453+ UF.fromPure (x + y)
454454 in UF.fold FL.drain u start
455455
456456
@@ -468,7 +468,7 @@ toNull3 value start =
468468 -}
469469 u = src `UF.bind` \x ->
470470 src `UF.bind` \y ->
471− UF.yield (x + y)
471+ UF.fromPure (x + y)
472472 in UF.fold FL.drain u start
473473
474474{-# INLINE toList #-}
@@ -484,7 +484,7 @@ toList value start = do
484484 -}
485485 u = src `UF.bind` \x ->
486486 src `UF.bind` \y ->
487− UF.yield (x + y)
487+ UF.fromPure (x + y)
488488 in UF.fold FL.toList u start
489489
490490{-# INLINE toListSome #-}
@@ -500,7 +500,7 @@ toListSome value start = do
500500 -}
501501 u = src `UF.bind` \x ->
502502 src `UF.bind` \y ->
503− UF.yield (x + y)
503+ UF.fromPure (x + y)
504504 in UF.fold FL.toList (UF.take 1000 u) start
505505
506506{-# INLINE filterAllOut #-}
@@ -517,7 +517,7 @@ filterAllOut value start = do
517517 src `UF.bind` \y ->
518518 let s = x + y
519519 in if s < 0
520− then UF.yield s
520+ then UF.fromPure s
521521 else UF.nilM (return . const ())
522522 in UF.fold FL.drain u start
523523
@@ -535,7 +535,7 @@ filterAllIn value start = do
535535 src `UF.bind` \y ->
536536 let s = x + y
537537 in if s > 0
538− then UF.yield s
538+ then UF.fromPure s
539539 else UF.nilM (return . const ())
540540 in UF.fold FL.drain u start
541541
@@ -553,7 +553,7 @@ filterSome value start = do
553553 src `UF.bind` \y ->
554554 let s = x + y
555555 in if s > 1100000
556− then UF.yield s
556+ then UF.fromPure s
557557 else UF.nilM (return . const ())
558558 in UF.fold FL.drain u start
559559
@@ -572,7 +572,7 @@ breakAfterSome value start =
572572 let s = x + y
573573 in if s > 1100000
574574 then error "break"
575− else UF.yield s
575+ else UF.fromPure s
576576 in do
577577 (_ :: Either ErrorCall ()) <- try $ UF.fold FL.drain u start
578578 return ()
src/Streamly/Internal/Data/Pipe.hs+1−1
@@ -1845,7 +1845,7 @@ classifySessionsBy tick timeout reset (Fold step initial extract) str =
18451845 let (r, mp') = Map.updateLookupWithKey (\_ _ -> Nothing) key mp
18461846 Tuple' _ acc <- accumulate r
18471847 res <- extract acc
1848− return $ Tuple4' evTime hp mp' (S.yield (key, res))
1848+ return $ Tuple4' evTime hp mp' (S.fromPure (key, res))
18491849 else do
18501850 let r = Map.lookup key mp
18511851 acc <- accumulate r
src/Streamly/Internal/Data/Unfold.hs+2−2
@@ -129,8 +129,8 @@ module Streamly.Internal.Data.Unfold
129129 , consM
130130
131131 -- ** From Values
132− , yieldM
133− , yield
132+ , fromEffect
133+ , fromPure
134134
135135 -- ** Generators
136136 -- | Generate a monadic stream from a seed.
src/Streamly/Internal/Data/Unfold/Type.hs+10−10
@@ -25,8 +25,8 @@ module Streamly.Internal.Data.Unfold.Type
2525 , identity
2626
2727 -- * From Values
28− , yieldM
29− , yield
28+ , fromEffect
29+ , fromPure
3030
3131 -- * Transformations
3232 , lmap
@@ -183,9 +183,9 @@ instance Functor m => Functor (Unfold m a) where
183183-- supplied monadic action.
184184--
185185-- /Pre-release/
186−{-# INLINE yieldM #-}
187−yieldM :: Applicative m => m b -> Unfold m a b
188−yieldM m = Unfold step inject
186+{-# INLINE fromEffect #-}
187+fromEffect :: Applicative m => m b -> Unfold m a b
188+fromEffect m = Unfold step inject
189189
190190 where
191191
@@ -194,13 +194,13 @@ yieldM m = Unfold step inject
194194 step False = (`Yield` True) <$> m
195195 step True = pure Stop
196196
197−-- | Discards the unfold input and always returns the argument of 'yield'.
197+-- | Discards the unfold input and always returns the argument of 'fromPure'.
198198--
199−-- > yield = yieldM . pure
199+-- > fromPure = fromEffect . pure
200200--
201201-- /Pre-release/
202−yield :: Applicative m => b -> Unfold m a b
203−yield = yieldM Prelude.. pure
202+fromPure :: Applicative m => b -> Unfold m a b
203+fromPure = fromEffect Prelude.. pure
204204
205205-- | Outer product discarding the first element.
206206--
@@ -300,7 +300,7 @@ apply u1 u2 = fmap (\(a, b) -> a b) (cross u1 u2)
300300--
301301instance Monad m => Applicative (Unfold m a) where
302302 {-# INLINE pure #-}
303− pure = yield
303+ pure = fromPure
304304
305305 {-# INLINE (<*>) #-}
306306 (<*>) = apply
test/Streamly/Test/Data/Unfold.hs+1−1
@@ -141,7 +141,7 @@ functionM =
141141
142142const :: Bool
143143const =
144− let unf = UF.yieldM (modify (+ 1) >> get)
144+ let unf = UF.fromEffect (modify (+ 1) >> get)
145145 in testUnfoldMD unf (0 :: Int) 0 1 [1]
146146
147147unfoldrM :: Property