on master help sign in
Rename the Unfold apply functions

To make them consistent with corresponding stream functions.

commitccbf1e40590253158dde8749f227c10d3f8c3bd5 authorHarendra Kumar <harendra@composewell.com> dateThu 8 Dec 2022, 06:19 (4 years ago) parent6bffc84
3 files changed+13−13
benchmark/Streamly/Benchmark/Data/Unfold.hs+1−1 core/src/Streamly/Internal/Data/Unfold.hs+1−1 core/src/Streamly/Internal/Data/Unfold/Type.hs+11−11
benchmark/Streamly/Benchmark/Data/Unfold.hs+1−1
@@ -427,7 +427,7 @@ toNullAp value start =
427427 let end = start + nthRoot 2 value
428428 s = source end
429429 -- in UF.fold ((+) <$> s <*> s) FL.drain start
430− in UF.fold FL.drain ((+) `fmap` s `UF.apply` s) start
430+ in UF.fold FL.drain ((+) `fmap` s `UF.crossApply` s) start
431431
432432{-# INLINE _apDiscardFst #-}
433433_apDiscardFst :: Int -> Int -> m ()
core/src/Streamly/Internal/Data/Unfold.hs+1−1
@@ -237,7 +237,7 @@ module Streamly.Internal.Data.Unfold
237237 , crossWithM
238238 , crossWith
239239 , cross
240− , apply
240+ , crossApply
241241
242242 -- ** Nesting
243243 , ConcatState (..)
core/src/Streamly/Internal/Data/Unfold/Type.hs+11−11
@@ -55,12 +55,12 @@ module Streamly.Internal.Data.Unfold.Type
5555 -- , manyInterleave2
5656
5757 -- Applicative
58− , apSequence
59− , apDiscardSnd
58+ , crossApplySnd
59+ , crossApplyFst
6060 , crossWithM
6161 , crossWith
6262 , cross
63− , apply
63+ , crossApply
6464
6565 -- Monad
6666 , concatMapM
@@ -407,19 +407,19 @@ fromList = Unfold step pure
407407--
408408-- /Unimplemented/
409409--
410−{-# INLINE_NORMAL apSequence #-}
411−apSequence :: -- Monad m =>
410+{-# INLINE_NORMAL crossApplySnd #-}
411+crossApplySnd :: -- Monad m =>
412412 Unfold m a b -> Unfold m a c -> Unfold m a c
413−apSequence (Unfold _step1 _inject1) (Unfold _step2 _inject2) = undefined
413+crossApplySnd (Unfold _step1 _inject1) (Unfold _step2 _inject2) = undefined
414414
415415-- | Outer product discarding the second element.
416416--
417417-- /Unimplemented/
418418--
419−{-# INLINE_NORMAL apDiscardSnd #-}
420−apDiscardSnd :: -- Monad m =>
419+{-# INLINE_NORMAL crossApplyFst #-}
420+crossApplyFst :: -- Monad m =>
421421 Unfold m a b -> Unfold m a c -> Unfold m a b
422−apDiscardSnd (Unfold _step1 _inject1) (Unfold _step2 _inject2) = undefined
422+crossApplyFst (Unfold _step1 _inject1) (Unfold _step2 _inject2) = undefined
423423
424424{-# ANN type Many2State Fuse #-}
425425data Many2State x s1 s2 = Many2Outer x s1 | Many2Inner x s1 s2
@@ -520,8 +520,8 @@ crossWith f = crossWithM (\b c -> return $ f b c)
520520cross :: Monad m => Unfold m a b -> Unfold m a c -> Unfold m a (b, c)
521521cross = crossWith (,)
522522
523−apply :: Monad m => Unfold m a (b -> c) -> Unfold m a b -> Unfold m a c
524−apply u1 u2 = fmap (\(a, b) -> a b) (cross u1 u2)
523+crossApply :: Monad m => Unfold m a (b -> c) -> Unfold m a b -> Unfold m a c
524+crossApply u1 u2 = fmap (\(a, b) -> a b) (cross u1 u2)
525525
526526-- XXX Applicative makes sense for unfolds, but monad does not. Use streams for
527527-- monad.