on master help sign in
Fix documentation for rollingMap and rollingMap2
commit68e2a7901773350c2ebe885bcdd695d95878aa7c authorHarendra Kumar <harendra@composewell.com> dateFri 11 Mar 2022, 13:51 (5 years ago) parent4b49390
1 file changed+11−4
src/Streamly/Internal/Data/Stream/IsStream/Transform.hs+11−4
src/Streamly/Internal/Data/Stream/IsStream/Transform.hs+11−4
@@ -1518,10 +1518,10 @@ elemIndices a = findIndices (== a)
15181518-- XXX this is not a one-to-one map so calling it map may not be right.
15191519-- We can perhaps call it zipWithTail or rollWith.
15201520--
1521−-- | Apply a function on every two successive elements of a stream. If the
1522−-- stream consists of a single element the output is an empty stream.
1523−--
1524−-- This is the stream equivalent of the list idiom @zipWith f xs (tail xs)@.
1521+-- | Apply a function on every two successive elements of a stream. The first
1522+-- argument of the map function is the previous element and the second argument
1523+-- is the current element. When the current element is the first element, the
1524+-- previous element is 'Nothing'.
15251525--
15261526-- /Pre-release/
15271527--
@@ -1537,6 +1537,13 @@ rollingMap f m = fromStreamD $ D.rollingMap f $ toStreamD m
15371537rollingMapM :: (IsStream t, Monad m) => (Maybe a -> a -> m b) -> t m a -> t m b
15381538rollingMapM f m = fromStreamD $ D.rollingMapM f $ toStreamD m
15391539
1540+-- | Like 'rollingMap' but requires at least two elements in the stream,
1541+-- returns an empty stream otherwise.
1542+--
1543+-- This is the stream equivalent of the list idiom @zipWith f xs (tail xs)@.
1544+--
1545+-- /Pre-release/
1546+--
15401547{-# INLINE rollingMap2 #-}
15411548rollingMap2 :: (IsStream t, Monad m) => (a -> a -> b) -> t m a -> t m b
15421549rollingMap2 f m = fromStreamD $ D.rollingMap2 f $ toStreamD m