aboutsummaryrefslogtreecommitdiffhomepage
path: root/Pipes
diff options
context:
space:
mode:
authorGabriel Gonzalez <Gabriel439@gmail.com>2014-02-07 22:08:47 +0700
committerGabriel Gonzalez <Gabriel439@gmail.com>2014-02-07 22:09:38 +0700
commit11645cdce20ff843caf8b53f82f2c32050fdd1fd (patch)
tree70ad8ff9afa81b17671bbe1ea4abce32aed06be4 /Pipes
parentca7b86be9116503f9ecc176b45bb3c695dc94b73 (diff)
downloadtext-pipes-11645cdce20ff843caf8b53f82f2c32050fdd1fd.tar.gz
text-pipes-11645cdce20ff843caf8b53f82f2c32050fdd1fd.tar.zst
text-pipes-11645cdce20ff843caf8b53f82f2c32050fdd1fd.zip
Fixed `scan`
The first `Char` of each output chunk is redundant (since it would have been emitted by the previous chunk). This removes the duplicate `Char`s. Note that this bug was present in `pipes-bytestring` as well, and I fixed it there, too.
Diffstat (limited to 'Pipes')
-rw-r--r--Pipes/Text.hs6
1 files changed, 4 insertions, 2 deletions
diff --git a/Pipes/Text.hs b/Pipes/Text.hs
index eb72be2..4b2d2b0 100644
--- a/Pipes/Text.hs
+++ b/Pipes/Text.hs
@@ -485,13 +485,15 @@ filter predicate = P.map (T.filter predicate)
485scan 485scan
486 :: (Monad m) 486 :: (Monad m)
487 => (Char -> Char -> Char) -> Char -> Pipe Text Text m r 487 => (Char -> Char -> Char) -> Char -> Pipe Text Text m r
488scan step begin = go begin 488scan step begin = do
489 yield (T.singleton begin)
490 go begin
489 where 491 where
490 go c = do 492 go c = do
491 txt <- await 493 txt <- await
492 let txt' = T.scanl step c txt 494 let txt' = T.scanl step c txt
493 c' = T.last txt' 495 c' = T.last txt'
494 yield txt' 496 yield (T.tail txt')
495 go c' 497 go c'
496{-# INLINABLE scan #-} 498{-# INLINABLE scan #-}
497 499