on master help sign in
Fix takeBetween to not hold unnecessary input
commit1bc2f87cd946fc48fc9fe7e2690b5267d721da19 authorHarendra Kumar <harendra@composewell.com> dateTue 31 Oct 2023, 19:21 (3 years ago) parent4b18ceb
1 file changed+5−3
core/src/Streamly/Internal/Data/Parser.hs+5−3
core/src/Streamly/Internal/Data/Parser.hs+5−3
@@ -13,7 +13,7 @@ module Streamly.Internal.Data.Parser
1313 -- $setup
1414
1515 module Streamly.Internal.Data.Parser.Type
16− --, module Streamly.Internal.Data.Parser.Tee
16+ --, module Streamly.Internal.Data.Parser.Tee
1717
1818 -- * Types
1919 , Parser (..)
@@ -681,9 +681,11 @@ takeBetween low high (Fold fstep finitial fextract) =
681681 in case res of
682682 FL.Partial s -> do
683683 let s1 = Tuple'Fused i1 s
684− if i1 < high
684+ if i1 < low
685685 then return $ Continue 0 s1
686− else extract foldErr s1
686+ else if i1 < high
687+ then return $ Partial 0 s1
688+ else fmap (Done 0) (fextract s)
687689 FL.Done b ->
688690 return
689691 $ if i1 >= low