diff --git a/core/src/Streamly/Internal/Data/Scanl/Window.hs b/core/src/Streamly/Internal/Data/Scanl/Window.hs index 9f4e014472..4a55e8fe25 100644 --- a/core/src/Streamly/Internal/Data/Scanl/Window.hs +++ b/core/src/Streamly/Internal/Data/Scanl/Window.hs @@ -110,12 +110,12 @@ import Prelude hiding (length, sum, minimum, maximum) data Incr a = Insert !a -- | Delete !a - | Replace !a !a -- ^ Replace new old + | Replace1 !a !a -- ^ Replace old new instance Functor Incr where fmap f (Insert x) = Insert (f x) -- fmap f (Delete x) = Delete (f x) - fmap f (Replace x y) = Replace (f x) (f y) + fmap f (Replace1 x y) = Replace1 (f x) (f y) ------------------------------------------------------------------------------- -- Utilities @@ -164,7 +164,7 @@ incrScanWith n (Scanl step1 initial1 extract1 final1) = step (SWRing rb st) a = do (rb1, old) <- RingArray.replace rb a - r <- step1 st (Replace a old, rb1) + r <- step1 st (Replace1 old a, rb1) return $ case r of Partial s -> Partial $ SWRing rb1 s @@ -205,7 +205,7 @@ incrScanWith n (Scanl step1 initial1 extract1 final1) = step (SWRing mba rh st) a = do (rb1@(RingArray _ _ rh1), old) <- RingArray.insert (RingArray mba (n * SIZE_OF(a)) rh) a - r <- step1 st (Replace a old, rb1) + r <- step1 st (Replace1 old a, rb1) return $ case r of Partial s -> Partial $ SWRing mba rh1 s @@ -252,7 +252,7 @@ incrRollingMapM f = Scanl.mkScanlM f1 initial f1 _ (Insert a) = f Nothing a -- f1 _ (Delete _) = return Nothing - f1 _ (Replace x y) = f (Just y) x + f1 _ (Replace1 old new) = f (Just old) new -- | Apply a pure function on the latest and the oldest element of the window. -- @@ -269,7 +269,7 @@ incrRollingMap f = Scanl.mkScanl f1 initial f1 _ (Insert a) = f Nothing a -- f1 _ (Delete _) = Nothing - f1 _ (Replace x y) = f (Just y) x + f1 _ (Replace1 old new) = f (Just old) new ------------------------------------------------------------------------------- -- Sum @@ -296,7 +296,7 @@ incrSumInt = Scanl step initial extract extract step s (Insert a) = return $ Partial (s + a) -- step s (Delete a) = return $ Partial (s - a) - step s (Replace new old) = return $ Partial (s + new - old) + step s (Replace1 old new) = return $ Partial (s + new - old) extract = return @@ -353,7 +353,7 @@ incrSum = Scanl step initial extract extract let incr = -new - err in add total incr -} - step (Tuple' total err) (Replace new old) = + step (Tuple' total err) (Replace1 old new) = -- XXX if (new - old) is large we may lose err let incr = (new - old) - err in add total incr @@ -374,7 +374,7 @@ incrCount = Scanl.mkScanl step 0 step w (Insert _) = w + 1 -- step w (Delete _) = w - 1 - step w (Replace _ _) = w + step w (Replace1 _ _) = w -- | Sum of the \(k\)th power of all the elements in a rolling window: --