diff options
author | Michael Thompson <what_is_it_to_do_anything@yahoo.com> | 2014-02-07 10:36:32 -0500 |
---|---|---|
committer | Michael Thompson <what_is_it_to_do_anything@yahoo.com> | 2014-02-07 10:36:32 -0500 |
commit | 662175887cdb8724ff8a0acbd2e50f4aee853adc (patch) | |
tree | 70ad8ff9afa81b17671bbe1ea4abce32aed06be4 | |
parent | ca7b86be9116503f9ecc176b45bb3c695dc94b73 (diff) | |
parent | 11645cdce20ff843caf8b53f82f2c32050fdd1fd (diff) | |
download | text-pipes-662175887cdb8724ff8a0acbd2e50f4aee853adc.tar.gz text-pipes-662175887cdb8724ff8a0acbd2e50f4aee853adc.tar.zst text-pipes-662175887cdb8724ff8a0acbd2e50f4aee853adc.zip |
Merge pull request #5 from Gabriel439/fix-scan
Fixed `scan`
-rw-r--r-- | Pipes/Text.hs | 6 |
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) | |||
485 | scan | 485 | scan |
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 |
488 | scan step begin = go begin | 488 | scan 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 | ||