Skip to content

Commit 3fc8544

Browse files
Make minor doc updates in the Scanl module
1 parent 0920ed3 commit 3fc8544

File tree

1 file changed

+21
-16
lines changed
  • core/src/Streamly/Internal/Data/Scanl

1 file changed

+21
-16
lines changed

core/src/Streamly/Internal/Data/Scanl/Window.hs

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,20 +28,20 @@ module Streamly.Internal.Data.Scanl.Window
2828
Incr (..)
2929

3030
-- * Running Incremental Scans
31-
-- | Scans of type @Scanl m (Incr a) b@ are incremental sliding window
32-
-- scans and are prefixed with @incr@. An input of type @(Insert a)@
33-
-- indicates that the input element @a@ is being inserted in the window
34-
-- without ejecting an old value increasing the window size by 1. An input
35-
-- of type @(Replace a a)@ indicates that the first element is being inserted
36-
-- in the window and the second element is being removed from the window,
37-
-- the window size remains the same. The window size can only increase and
38-
-- never decrease.
31+
-- | Scans of type @Scanl m (Incr a) b@ are incremental sliding-window
32+
-- scans. Names of such scans are prefixed with @incr@. An input of type
33+
-- @(Insert a)@ indicates that the input element @a@ is being inserted in
34+
-- the window without ejecting an old value, increasing the window size by
35+
-- 1. An input of type @(Replace a a)@ indicates that the first argument of
36+
-- Replace is being inserted in the window and the second argument is being
37+
-- removed from the window, the window size remains the same. The window
38+
-- size can only increase and never decrease.
3939
--
4040
-- You can compute the statistics over the entire stream using window folds
4141
-- by always supplying input of type @Insert a@.
4242
--
4343
-- The incremental scans are converted into scans over a window using the
44-
-- 'windowScan' operation which maintains a sliding window and supplies the
44+
-- 'incrScan' operation which maintains a sliding window and supplies the
4545
-- new and/or exiting element of the window to the window scan in the form
4646
-- of an incremental operation. The names of window scans are prefixed with
4747
-- @window@.
@@ -101,11 +101,16 @@ import Prelude hiding (length, sum, minimum, maximum)
101101
-- for time based windows.
102102
--
103103
-- Replace can be implemented using Insert and Delete.
104+
--
105+
-- XXX Use "Replace old new" instead.
104106

107+
-- | Represents incremental input for a scan. 'Insert' means a new element is
108+
-- being added to the collection, 'Replace' means an old value in the
109+
-- collection is being replaced with a new value.
105110
data Incr a =
106111
Insert !a
107-
-- | Delete !a
108-
| Replace !a !a
112+
-- | Delete !a
113+
| Replace !a !a -- ^ Replace new old
109114

110115
instance Functor Incr where
111116
fmap f (Insert x) = Insert (f x)
@@ -120,7 +125,7 @@ instance Functor Incr where
120125
data SlidingWindow a r s = SWArray !a !Int !s | SWRing !r !s
121126
-- data SlidingWindow a s = SWArray !a !Int !s !Int | SWRing !a !Int !s
122127

123-
-- | Like 'windowScan' but also provides the ring array to the scan. The ring
128+
-- | Like 'incrScan' but also provides the ring array to the scan. The ring
124129
-- array reflects the state of the ring after inserting the incoming element.
125130
--
126131
-- IMPORTANT NOTE: The ring is mutable, therefore, references to it should not
@@ -213,10 +218,10 @@ incrScanWith n (Scanl step1 initial1 extract1 final1) =
213218
-}
214219

215220
-- | @incrScan collector@ is an incremental sliding window scan that does not
216-
-- require all the intermediate elements in a computation. This maintains @n@
217-
-- elements in the window, when a new element comes it slides out the oldest
218-
-- element and the new element along with the old element are supplied to the
219-
-- collector fold.
221+
-- require all the intermediate elements in each step of the scan computation.
222+
-- This maintains @n@ elements in the window, when a new element comes it
223+
-- slides out the oldest element. The new element along with the old element
224+
-- are supplied to the collector fold.
220225
--
221226
{-# INLINE incrScan #-}
222227
incrScan :: forall m a b. (MonadIO m, Unbox a)

0 commit comments

Comments
 (0)