on master help sign in
Rename the Unfold apply functions
ccbf1e4Harendra Kumar
benchmark/Streamly/Benchmark/Data/Unfold.hs+1−1
@@ -427,7 +427,7 @@ toNullAp value start =
427 let end = start + nthRoot 2 value
427 let end = start + nthRoot 2 value
428 s = source end
428 s = source end
429 -- in UF.fold ((+) <$> s <*> s) FL.drain start
429 -- 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
431
431
432{-# INLINE _apDiscardFst #-}
432{-# INLINE _apDiscardFst #-}
433_apDiscardFst :: Int -> Int -> m ()
433_apDiscardFst :: Int -> Int -> m ()
core/src/Streamly/Internal/Data/Unfold.hs+1−1
@@ -237,7 +237,7 @@ module Streamly.Internal.Data.Unfold
237 , crossWithM
237 , crossWithM
238 , crossWith
238 , crossWith
239 , cross
239 , cross
240− , apply
240+ , crossApply
241
241
242 -- ** Nesting
242 -- ** Nesting
243 , ConcatState (..)
243 , ConcatState (..)
core/src/Streamly/Internal/Data/Unfold/Type.hs+11−11
@@ -55,12 +55,12 @@ module Streamly.Internal.Data.Unfold.Type
55 -- , manyInterleave2
55 -- , manyInterleave2
56
56
57 -- Applicative
57 -- Applicative
58− , apSequence
58+ , crossApplySnd
59− , apDiscardSnd
59+ , crossApplyFst
60 , crossWithM
60 , crossWithM
61 , crossWith
61 , crossWith
62 , cross
62 , cross
63− , apply
63+ , crossApply
64
64
65 -- Monad
65 -- Monad
66 , concatMapM
66 , concatMapM
@@ -407,19 +407,19 @@ fromList = Unfold step pure
407--
407--
408-- /Unimplemented/
408-- /Unimplemented/
409--
409--
410−{-# INLINE_NORMAL apSequence #-}
410+{-# INLINE_NORMAL crossApplySnd #-}
411−apSequence :: -- Monad m =>
411+crossApplySnd :: -- Monad m =>
412 Unfold m a b -> Unfold m a c -> Unfold m a c
412 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
414
414
415-- | Outer product discarding the second element.
415-- | Outer product discarding the second element.
416--
416--
417-- /Unimplemented/
417-- /Unimplemented/
418--
418--
419−{-# INLINE_NORMAL apDiscardSnd #-}
419+{-# INLINE_NORMAL crossApplyFst #-}
420−apDiscardSnd :: -- Monad m =>
420+crossApplyFst :: -- Monad m =>
421 Unfold m a b -> Unfold m a c -> Unfold m a b
421 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
423
423
424{-# ANN type Many2State Fuse #-}
424{-# ANN type Many2State Fuse #-}
425data Many2State x s1 s2 = Many2Outer x s1 | Many2Inner x s1 s2
425data Many2State x s1 s2 = Many2Outer x s1 | Many2Inner x s1 s2
@@ -520,8 +520,8 @@ crossWith f = crossWithM (\b c -> return $ f b c)
520cross :: Monad m => Unfold m a b -> Unfold m a c -> Unfold m a (b, c)
520cross :: Monad m => Unfold m a b -> Unfold m a c -> Unfold m a (b, c)
521cross = crossWith (,)
521cross = crossWith (,)
522
522
523−apply :: Monad m => Unfold m a (b -> c) -> Unfold m a b -> Unfold m a c
523+crossApply :: 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)
524+crossApply u1 u2 = fmap (\(a, b) -> a b) (cross u1 u2)
525
525
526-- XXX Applicative makes sense for unfolds, but monad does not. Use streams for
526-- XXX Applicative makes sense for unfolds, but monad does not. Use streams for
527-- monad.
527-- monad.