on master help sign in
Rename Fold.ltake to Fold.takeLE
084cdeaAdithya Kumar
benchmark/Streamly/Benchmark/Data/Fold.hs+6−6
@@ -64,9 +64,9 @@ any value = IP.fold (FL.any (> value))
64all :: (Monad m, Ord a) => a -> SerialT m a -> m Bool
64all :: (Monad m, Ord a) => a -> SerialT m a -> m Bool
65all value = IP.fold (FL.all (<= value))
65all value = IP.fold (FL.all (<= value))
66
66
67−{-# INLINE take #-}
67+{-# INLINE takeLE #-}
68−take :: Monad m => Int -> SerialT m a -> m ()
68+takeLE :: Monad m => Int -> SerialT m a -> m ()
69−take value = IP.fold (FL.ltake value FL.drain)
69+takeLE value = IP.fold (FL.takeLE value FL.drain)
70
70
71-------------------------------------------------------------------------------
71-------------------------------------------------------------------------------
72-- Splitting by serial application
72-- Splitting by serial application
@@ -78,7 +78,7 @@ sliceSepBy value = IP.fold (FL.sliceSepBy (>= value) FL.drain)
78
78
79{-# INLINE many #-}
79{-# INLINE many #-}
80many :: Monad m => SerialT m Int -> m ()
80many :: Monad m => SerialT m Int -> m ()
81−many = IP.fold (FL.many FL.drain (FL.ltake 1 FL.drain))
81+many = IP.fold (FL.many FL.drain (FL.takeLE 1 FL.drain))
82
82
83{-# INLINE splitAllAny #-}
83{-# INLINE splitAllAny #-}
84splitAllAny :: Monad m => Int -> SerialT m Int -> m (Bool, Bool)
84splitAllAny :: Monad m => Int -> SerialT m Int -> m (Bool, Bool)
@@ -229,7 +229,7 @@ o_1_space_serial_elimination value =
229 , benchIOSink value "notElem" (S.fold (FL.notElem (value + 1)))
229 , benchIOSink value "notElem" (S.fold (FL.notElem (value + 1)))
230 , benchIOSink value "all" $ all value
230 , benchIOSink value "all" $ all value
231 , benchIOSink value "any" $ any value
231 , benchIOSink value "any" $ any value
232− , benchIOSink value "take" $ take value
232+ , benchIOSink value "takeLE" $ takeLE value
233 , benchIOSink value "sliceSepBy" $ sliceSepBy value
233 , benchIOSink value "sliceSepBy" $ sliceSepBy value
234 , benchIOSink value "and" (S.fold FL.and . S.map (<= (value + 1)))
234 , benchIOSink value "and" (S.fold FL.and . S.map (<= (value + 1)))
235 , benchIOSink value "or" (S.fold FL.or . S.map (> (value + 1)))
235 , benchIOSink value "or" (S.fold FL.or . S.map (> (value + 1)))
@@ -265,7 +265,7 @@ o_1_space_serial_composition value =
265 [ benchIOSink value "splitWith (all, any)" $ splitAllAny value
265 [ benchIOSink value "splitWith (all, any)" $ splitAllAny value
266 , benchIOSink value "teeApplicative (all, any)"
266 , benchIOSink value "teeApplicative (all, any)"
267 $ teeApplicative value
267 $ teeApplicative value
268− , benchIOSink value "many drain (take 1)" many
268+ , benchIOSink value "many drain (takeLE 1)" many
269 , benchIOSink value "tee (sum, length)" teeSumLength
269 , benchIOSink value "tee (sum, length)" teeSumLength
270 , benchIOSink value "distribute [sum, length]" distribute
270 , benchIOSink value "distribute [sum, length]" distribute
271 , benchIOSink value "partition (sum, length)" partition
271 , benchIOSink value "partition (sum, length)" partition
benchmark/Streamly/Benchmark/Data/Parser.hs+2−2
@@ -256,7 +256,7 @@ parseMany :: MonadCatch m => SerialT m Int -> m ()
256parseMany =
256parseMany =
257 S.drain
257 S.drain
258 . S.map getSum
258 . S.map getSum
259− . IP.parseMany (PR.fromFold $ FL.ltake 2 FL.mconcat)
259+ . IP.parseMany (PR.fromFold $ FL.takeLE 2 FL.mconcat)
260 . S.map Sum
260 . S.map Sum
261
261
262{-# INLINE parseIterate #-}
262{-# INLINE parseIterate #-}
@@ -264,7 +264,7 @@ parseIterate :: MonadCatch m => SerialT m Int -> m ()
264parseIterate =
264parseIterate =
265 S.drain
265 S.drain
266 . S.map getSum
266 . S.map getSum
267− . IP.parseIterate (PR.fromFold . FL.ltake 2 . FL.sconcat) (Sum 0)
267+ . IP.parseIterate (PR.fromFold . FL.takeLE 2 . FL.sconcat) (Sum 0)
268 . S.map Sum
268 . S.map Sum
269
269
270-------------------------------------------------------------------------------
270-------------------------------------------------------------------------------
benchmark/Streamly/Benchmark/FileSystem/Handle/Read.hs+2−2
@@ -311,12 +311,12 @@ chunksOfSum n inh = S.length $ S.chunksOf n FL.sum (S.unfold FH.read inh)
311
311
312foldManyChunksOfSum :: Int -> Handle -> IO Int
312foldManyChunksOfSum :: Int -> Handle -> IO Int
313foldManyChunksOfSum n inh =
313foldManyChunksOfSum n inh =
314− S.length $ IP.foldMany (FL.ltake n FL.sum) (S.unfold FH.read inh)
314+ S.length $ IP.foldMany (FL.takeLE n FL.sum) (S.unfold FH.read inh)
315
315
316parseManyChunksOfSum :: Int -> Handle -> IO Int
316parseManyChunksOfSum :: Int -> Handle -> IO Int
317parseManyChunksOfSum n inh =
317parseManyChunksOfSum n inh =
318 S.length
318 S.length
319− $ IP.parseMany (PR.fromFold $ FL.ltake n FL.sum) (S.unfold FH.read inh)
319+ $ IP.parseMany (PR.fromFold $ FL.takeLE n FL.sum) (S.unfold FH.read inh)
320
320
321-- XXX investigate why we need an INLINE in this case (GHC)
321-- XXX investigate why we need an INLINE in this case (GHC)
322-- Even though allocations remain the same in both cases inlining improves time
322-- Even though allocations remain the same in both cases inlining improves time
benchmark/Streamly/Benchmark/Prelude/Serial/Transformation2.hs+2−2
@@ -137,7 +137,7 @@ foldMany :: Monad m => SerialT m Int -> m ()
137foldMany =
137foldMany =
138 S.drain
138 S.drain
139 . S.map getSum
139 . S.map getSum
140− . Internal.foldMany (FL.ltake 2 FL.mconcat)
140+ . Internal.foldMany (FL.takeLE 2 FL.mconcat)
141 . S.map Sum
141 . S.map Sum
142
142
143{-# INLINE _foldIterate #-}
143{-# INLINE _foldIterate #-}
@@ -145,7 +145,7 @@ _foldIterate :: Monad m => SerialT m Int -> m ()
145_foldIterate =
145_foldIterate =
146 S.drain
146 S.drain
147 . S.map getSum
147 . S.map getSum
148− . Internal.foldIterate (FL.ltake 2 . FL.sconcat) (Sum 0)
148+ . Internal.foldIterate (FL.takeLE 2 . FL.sconcat) (Sum 0)
149 . S.map Sum
149 . S.map Sum
150
150
151o_1_space_grouping :: Int -> [Benchmark]
151o_1_space_grouping :: Int -> [Benchmark]
src/Streamly/Data/Fold.hs+1−1
@@ -173,7 +173,7 @@ module Streamly.Data.Fold
173
173
174 {-
174 {-
175 -- ** Trimming
175 -- ** Trimming
176− , ltake
176+ , takeLE
177 -- takeByTime
177 -- takeByTime
178 , ldrop
178 , ldrop
179 , ldropWhile
179 , ldropWhile
src/Streamly/Internal/Data/Fold.hs+7−7
@@ -137,7 +137,7 @@ module Streamly.Internal.Data.Fold
137 -}
137 -}
138
138
139 -- ** Trimming
139 -- ** Trimming
140− , ltake
140+ , takeLE
141 , takeByTime
141 , takeByTime
142 -- By elements
142 -- By elements
143 , sliceSepBy
143 , sliceSepBy
@@ -715,10 +715,10 @@ rollingHash = rollingHashWithSalt defaultSalt
715-- | Compute an 'Int' sized polynomial rolling hash of the first n elements of
715-- | Compute an 'Int' sized polynomial rolling hash of the first n elements of
716-- a stream.
716-- a stream.
717--
717--
718−-- > rollingHashFirstN = ltake n rollingHash
718+-- > rollingHashFirstN = takeLE n rollingHash
719{-# INLINABLE rollingHashFirstN #-}
719{-# INLINABLE rollingHashFirstN #-}
720rollingHashFirstN :: (Monad m, Enum a) => Int -> Fold m a Int64
720rollingHashFirstN :: (Monad m, Enum a) => Int -> Fold m a Int64
721−rollingHashFirstN n = ltake n rollingHash
721+rollingHashFirstN n = takeLE n rollingHash
722
722
723------------------------------------------------------------------------------
723------------------------------------------------------------------------------
724-- Monoidal left folds
724-- Monoidal left folds
@@ -826,7 +826,7 @@ toListRevF = mkAccum_ (flip (:)) []
826-- and discarding the results.
826-- and discarding the results.
827{-# INLINABLE drainN #-}
827{-# INLINABLE drainN #-}
828drainN :: Monad m => Int -> Fold m a ()
828drainN :: Monad m => Int -> Fold m a ()
829−drainN n = ltake n drain
829+drainN n = takeLE n drain
830
830
831------------------------------------------------------------------------------
831------------------------------------------------------------------------------
832-- To Elements
832-- To Elements
@@ -1056,7 +1056,7 @@ or = any (== True)
1056-- >>> splitAt_ 4 [1,2,3]
1056-- >>> splitAt_ 4 [1,2,3]
1057-- > ([1,2,3],[])
1057-- > ([1,2,3],[])
1058--
1058--
1059−-- > splitAt n f1 f2 = splitWith (,) (ltake n f1) f2
1059+-- > splitAt n f1 f2 = splitWith (,) (takeLE n f1) f2
1060--
1060--
1061-- /Internal/
1061-- /Internal/
1062
1062
@@ -1067,7 +1067,7 @@ splitAt
1067 -> Fold m a b
1067 -> Fold m a b
1068 -> Fold m a c
1068 -> Fold m a c
1069 -> Fold m a (b, c)
1069 -> Fold m a (b, c)
1070−splitAt n fld = splitWith (,) (ltake n fld)
1070+splitAt n fld = splitWith (,) (takeLE n fld)
1071
1071
1072------------------------------------------------------------------------------
1072------------------------------------------------------------------------------
1073-- Element Aware APIs
1073-- Element Aware APIs
@@ -1176,7 +1176,7 @@ sliceSepBy predicate (Fold fstep finitial fextract) =
1176{-# INLINABLE sliceSepByMax #-}
1176{-# INLINABLE sliceSepByMax #-}
1177sliceSepByMax :: Monad m
1177sliceSepByMax :: Monad m
1178 => (a -> Bool) -> Int -> Fold m a b -> Fold m a b
1178 => (a -> Bool) -> Int -> Fold m a b -> Fold m a b
1179−sliceSepByMax p n = sliceSepBy p . ltake n
1179+sliceSepByMax p n = sliceSepBy p . takeLE n
1180
1180
1181-- | Collect stream elements until an element succeeds the predicate. Also take
1181-- | Collect stream elements until an element succeeds the predicate. Also take
1182-- the element on which the predicate succeeded. The succeeding element is
1182-- the element on which the predicate succeeded. The succeeding element is
src/Streamly/Internal/Data/Fold/Types.hs+8−8
@@ -184,7 +184,7 @@ module Streamly.Internal.Data.Fold.Types
184 , lfilter
184 , lfilter
185 , lfilterM
185 , lfilterM
186 , lcatMaybes
186 , lcatMaybes
187− , ltake
187+ , takeLE
188 , takeByTime
188 , takeByTime
189
189
190 -- * Distributing
190 -- * Distributing
@@ -704,18 +704,18 @@ lcatMaybes = lfilter isJust . lmap fromJust
704
704
705-- | Take at most @n@ input elements and fold them using the supplied fold.
705-- | Take at most @n@ input elements and fold them using the supplied fold.
706--
706--
707−-- >>> Stream.fold (Fold.ltake 1 Fold.toList) $ Stream.fromList [1]
707+-- >>> Stream.fold (Fold.takeLE 1 Fold.toList) $ Stream.fromList [1]
708-- [1]
708-- [1]
709--
709--
710−-- >>> Stream.fold (Fold.ltake (-1) Fold.toList) $ Stream.fromList [1]
710+-- >>> Stream.fold (Fold.takeLE (-1) Fold.toList) $ Stream.fromList [1]
711-- []
711-- []
712--
712--
713-- /Internal/
713-- /Internal/
714--
714--
715-- @since 0.7.0
715-- @since 0.7.0
716−{-# INLINE ltake #-}
716+{-# INLINE takeLE #-}
717−ltake :: Monad m => Int -> Fold m a b -> Fold m a b
717+takeLE :: Monad m => Int -> Fold m a b -> Fold m a b
718−ltake n (Fold fstep finitial fextract) = Fold step initial extract
718+takeLE n (Fold fstep finitial fextract) = Fold step initial extract
719
719
720 where
720 where
721
721
@@ -862,7 +862,7 @@ many (Fold cstep cinitial cextract) (Fold sstep sinitial sextract) =
862-- of @n@ items in the input stream and supplies the result to the @collect@
862-- of @n@ items in the input stream and supplies the result to the @collect@
863-- fold.
863-- fold.
864--
864--
865−-- > lchunksOf n split collect = many collect (ltake n split)
865+-- > lchunksOf n split collect = many collect (takeLE n split)
866--
866--
867-- Stops when @collect@ stops.
867-- Stops when @collect@ stops.
868--
868--
@@ -870,7 +870,7 @@ many (Fold cstep cinitial cextract) (Fold sstep sinitial sextract) =
870--
870--
871{-# INLINE lchunksOf #-}
871{-# INLINE lchunksOf #-}
872lchunksOf :: Monad m => Int -> Fold m a b -> Fold m b c -> Fold m a c
872lchunksOf :: Monad m => Int -> Fold m a b -> Fold m b c -> Fold m a c
873−lchunksOf n split collect = many collect (ltake n split)
873+lchunksOf n split collect = many collect (takeLE n split)
874
874
875{-# INLINE lchunksOf2 #-}
875{-# INLINE lchunksOf2 #-}
876lchunksOf2 :: Monad m => Int -> Fold m a b -> Fold2 m x b c -> Fold2 m x a c
876lchunksOf2 :: Monad m => Int -> Fold m a b -> Fold2 m x b c -> Fold2 m x a c
src/Streamly/Internal/Data/Stream/IsStream/Eliminate.hs+1−1
@@ -382,7 +382,7 @@ drain = P.drain
382
382
383-- |
383-- |
384-- > drainN n = drain . take n
384-- > drainN n = drain . take n
385−-- > drainN n = fold (Fold.ltake n Fold.drain)
385+-- > drainN n = fold (Fold.takeLE n Fold.drain)
386--
386--
387-- Run maximum up to @n@ iterations of a stream.
387-- Run maximum up to @n@ iterations of a stream.
388--
388--
src/Streamly/Internal/Data/Stream/IsStream/Nesting.hs+5−5
@@ -877,7 +877,7 @@ iterateMapLeftsWith combine f = iterateMapWith combine (either f (const K.nil))
877-- This is the streaming dual of the 'Streamly.Internal.Data.Fold.many'
877-- This is the streaming dual of the 'Streamly.Internal.Data.Fold.many'
878-- parse combinator.
878-- parse combinator.
879--
879--
880−-- >>> f = Fold.ltake 2 Fold.sum
880+-- >>> f = Fold.takeLE 2 Fold.sum
881-- >>> Stream.toList $ Stream.foldMany f $ Stream.fromList [1..10]
881-- >>> Stream.toList $ Stream.foldMany f $ Stream.fromList [1..10]
882-- > [3,7,11,15,19]
882-- > [3,7,11,15,19]
883--
883--
@@ -912,7 +912,7 @@ foldSequence _f _m = undefined
912-- generate the first fold, the fold is applied on the stream and the result of
912-- generate the first fold, the fold is applied on the stream and the result of
913-- the fold is used to generate the next fold and so on.
913-- the fold is used to generate the next fold and so on.
914--
914--
915−-- >>> f x = Fold.ltake 2 (Fold.mconcatTo x)
915+-- >>> f x = Fold.takeLE 2 (Fold.mconcatTo x)
916-- >>> s = Stream.map Sum $ Stream.fromList [1..10]
916-- >>> s = Stream.map Sum $ Stream.fromList [1..10]
917-- >>> Stream.toList $ Stream.map getSum $ Stream.foldIterate f 0 s
917-- >>> Stream.toList $ Stream.map getSum $ Stream.foldIterate f 0 s
918-- > [3,10,21,36,55,55]
918-- > [3,10,21,36,55,55]
@@ -1535,15 +1535,15 @@ splitOnSuffixSeqAny subseq f m = undefined
1535-- >> S.toList $ S.chunksOf 2 FL.sum (S.enumerateFromTo 1 10)
1535-- >> S.toList $ S.chunksOf 2 FL.sum (S.enumerateFromTo 1 10)
1536-- > [3,7,11,15,19]
1536-- > [3,7,11,15,19]
1537--
1537--
1538−-- This can be considered as an n-fold version of 'ltake' where we apply
1538+-- This can be considered as an n-fold version of 'takeLE' where we apply
1539−-- 'ltake' repeatedly on the leftover stream until the stream exhausts.
1539+-- 'takeLE' repeatedly on the leftover stream until the stream exhausts.
1540--
1540--
1541-- @since 0.7.0
1541-- @since 0.7.0
1542{-# INLINE chunksOf #-}
1542{-# INLINE chunksOf #-}
1543chunksOf
1543chunksOf
1544 :: (IsStream t, Monad m)
1544 :: (IsStream t, Monad m)
1545 => Int -> Fold m a b -> t m a -> t m b
1545 => Int -> Fold m a b -> t m a -> t m b
1546−chunksOf n f = foldMany (FL.ltake n f)
1546+chunksOf n f = foldMany (FL.takeLE n f)
1547
1547
1548-- |
1548-- |
1549--
1549--
test/Streamly/Test/Data/Fold.hs+4−4
@@ -215,10 +215,10 @@ and ls = S.fold FL.and (S.fromList ls) `shouldReturn` Prelude.and ls
215or :: [Bool] -> Expectation
215or :: [Bool] -> Expectation
216or ls = S.fold FL.or (S.fromList ls) `shouldReturn` Prelude.or ls
216or ls = S.fold FL.or (S.fromList ls) `shouldReturn` Prelude.or ls
217
217
218−ltake :: [Int] -> Property
218+takeLE :: [Int] -> Property
219−ltake ls =
219+takeLE ls =
220 forAll (chooseInt (-1, Prelude.length ls + 2)) $ \n ->
220 forAll (chooseInt (-1, Prelude.length ls + 2)) $ \n ->
221− S.fold (F.ltake n FL.toList) (S.fromList ls)
221+ S.fold (F.takeLE n FL.toList) (S.fromList ls)
222 `shouldReturn` Prelude.take n ls
222 `shouldReturn` Prelude.take n ls
223
223
224sliceSepBy :: Property
224sliceSepBy :: Property
@@ -443,7 +443,7 @@ main = hspec $
443 prop "And" Main.and
443 prop "And" Main.and
444 prop "Or" Main.or
444 prop "Or" Main.or
445 prop "mapMaybe" mapMaybe
445 prop "mapMaybe" mapMaybe
446− prop "ltake" ltake
446+ prop "takeLE" takeLE
447 prop "sliceSepBy" sliceSepBy
447 prop "sliceSepBy" sliceSepBy
448 prop "sliceSepByMax" sliceSepByMax
448 prop "sliceSepByMax" sliceSepByMax
449 prop "drain" Main.drain
449 prop "drain" Main.drain
test/Streamly/Test/Data/Parser.hs+6−6
@@ -535,8 +535,8 @@ applicative =
535 forAll (listOf (chooseAny :: Gen Int)) $ \ list2 ->
535 forAll (listOf (chooseAny :: Gen Int)) $ \ list2 ->
536 let parser =
536 let parser =
537 (,)
537 (,)
538− <$> P.fromFold (FL.ltake (length list1) FL.toList)
538+ <$> P.fromFold (FL.takeLE (length list1) FL.toList)
539− <*> P.fromFold (FL.ltake (length list2) FL.toList)
539+ <*> P.fromFold (FL.takeLE (length list2) FL.toList)
540 in monadicIO $ do
540 in monadicIO $ do
541 (olist1, olist2) <-
541 (olist1, olist2) <-
542 run $ S.parse parser (S.fromList $ list1 ++ list2)
542 run $ S.parse parser (S.fromList $ list1 ++ list2)
@@ -546,7 +546,7 @@ applicative =
546sequence :: Property
546sequence :: Property
547sequence =
547sequence =
548 forAll (vectorOf 11 (listOf (chooseAny :: Gen Int))) $ \ ins ->
548 forAll (vectorOf 11 (listOf (chooseAny :: Gen Int))) $ \ ins ->
549− let p xs = P.fromFold (FL.ltake (length xs) FL.toList)
549+ let p xs = P.fromFold (FL.takeLE (length xs) FL.toList)
550 in monadicIO $ do
550 in monadicIO $ do
551 outs <- run $
551 outs <- run $
552 S.parse
552 S.parse
@@ -559,8 +559,8 @@ monad =
559 forAll (listOf (chooseAny :: Gen Int)) $ \ list1 ->
559 forAll (listOf (chooseAny :: Gen Int)) $ \ list1 ->
560 forAll (listOf (chooseAny :: Gen Int)) $ \ list2 ->
560 forAll (listOf (chooseAny :: Gen Int)) $ \ list2 ->
561 let parser = do
561 let parser = do
562− olist1 <- P.fromFold (FL.ltake (length list1) FL.toList)
562+ olist1 <- P.fromFold (FL.takeLE (length list1) FL.toList)
563− olist2 <- P.fromFold (FL.ltake (length list2) FL.toList)
563+ olist2 <- P.fromFold (FL.takeLE (length list2) FL.toList)
564 return (olist1, olist2)
564 return (olist1, olist2)
565 in monadicIO $ do
565 in monadicIO $ do
566 (olist1, olist2) <-
566 (olist1, olist2) <-
@@ -578,7 +578,7 @@ parseMany =
578 forAll (listOf (vectorOf len (chooseAny :: Gen Int))) $ \ ins ->
578 forAll (listOf (vectorOf len (chooseAny :: Gen Int))) $ \ ins ->
579 monadicIO $ do
579 monadicIO $ do
580 outs <- do
580 outs <- do
581− let p = P.fromFold $ FL.ltake len FL.toList
581+ let p = P.fromFold $ FL.takeLE len FL.toList
582 run
582 run
583 $ S.toList
583 $ S.toList
584 $ S.parseMany p (S.fromList $ concat ins)
584 $ S.parseMany p (S.fromList $ concat ins)
test/Streamly/Test/Data/Parser/ParserD.hs+10−10
@@ -182,7 +182,7 @@ take :: Property
182take =
182take =
183 forAll (chooseInt (min_value, max_value)) $ \n ->
183 forAll (chooseInt (min_value, max_value)) $ \n ->
184 forAll (listOf (chooseInt (min_value, max_value))) $ \ls ->
184 forAll (listOf (chooseInt (min_value, max_value))) $ \ls ->
185− case S.parseD (P.fromFold $ FL.ltake n FL.toList) (S.fromList ls) of
185+ case S.parseD (P.fromFold $ FL.takeLE n FL.toList) (S.fromList ls) of
186 Right parsed_list -> checkListEqual parsed_list (Prelude.take n ls)
186 Right parsed_list -> checkListEqual parsed_list (Prelude.take n ls)
187 Left _ -> property False
187 Left _ -> property False
188
188
@@ -263,7 +263,7 @@ lookAheadPass :: Property
263lookAheadPass =
263lookAheadPass =
264 forAll (chooseInt (min_value, max_value)) $ \n ->
264 forAll (chooseInt (min_value, max_value)) $ \n ->
265 let
265 let
266− takeWithoutConsume = P.lookAhead $ P.fromFold $ FL.ltake n FL.toList
266+ takeWithoutConsume = P.lookAhead $ P.fromFold $ FL.takeLE n FL.toList
267 parseTwice = do
267 parseTwice = do
268 parsed_list_1 <- takeWithoutConsume
268 parsed_list_1 <- takeWithoutConsume
269 parsed_list_2 <- takeWithoutConsume
269 parsed_list_2 <- takeWithoutConsume
@@ -279,7 +279,7 @@ lookAhead :: Property
279lookAhead =
279lookAhead =
280 forAll (chooseInt (min_value, max_value)) $ \n ->
280 forAll (chooseInt (min_value, max_value)) $ \n ->
281 let
281 let
282− takeWithoutConsume = P.lookAhead $ P.fromFold $ FL.ltake n FL.toList
282+ takeWithoutConsume = P.lookAhead $ P.fromFold $ FL.takeLE n FL.toList
283 parseTwice = do
283 parseTwice = do
284 parsed_list_1 <- takeWithoutConsume
284 parsed_list_1 <- takeWithoutConsume
285 parsed_list_2 <- takeWithoutConsume
285 parsed_list_2 <- takeWithoutConsume
@@ -396,7 +396,7 @@ teeWithPass =
396 forAll (chooseInt (min_value, max_value)) $ \n ->
396 forAll (chooseInt (min_value, max_value)) $ \n ->
397 forAll (listOf (chooseInt (0, 1))) $ \ls ->
397 forAll (listOf (chooseInt (0, 1))) $ \ls ->
398 let
398 let
399− prsr = P.fromFold $ FL.ltake n FL.toList
399+ prsr = P.fromFold $ FL.takeLE n FL.toList
400 in
400 in
401 case S.parseD (P.teeWith (,) prsr prsr) (S.fromList ls) of
401 case S.parseD (P.teeWith (,) prsr prsr) (S.fromList ls) of
402 Right (ls_1, ls_2) -> checkListEqual (Prelude.take n ls) ls_1 .&&. checkListEqual ls_1 ls_2
402 Right (ls_1, ls_2) -> checkListEqual (Prelude.take n ls) ls_1 .&&. checkListEqual ls_1 ls_2
@@ -536,8 +536,8 @@ applicative =
536 forAll (listOf (chooseAny :: Gen Int)) $ \ list2 ->
536 forAll (listOf (chooseAny :: Gen Int)) $ \ list2 ->
537 let parser =
537 let parser =
538 (,)
538 (,)
539− <$> P.fromFold (FL.ltake (length list1) FL.toList)
539+ <$> P.fromFold (FL.takeLE (length list1) FL.toList)
540− <*> P.fromFold (FL.ltake (length list2) FL.toList)
540+ <*> P.fromFold (FL.takeLE (length list2) FL.toList)
541 in monadicIO $ do
541 in monadicIO $ do
542 (olist1, olist2) <-
542 (olist1, olist2) <-
543 run $ S.parseD parser (S.fromList $ list1 ++ list2)
543 run $ S.parseD parser (S.fromList $ list1 ++ list2)
@@ -547,7 +547,7 @@ applicative =
547sequence :: Property
547sequence :: Property
548sequence =
548sequence =
549 forAll (vectorOf 11 (listOf (chooseAny :: Gen Int))) $ \ ins ->
549 forAll (vectorOf 11 (listOf (chooseAny :: Gen Int))) $ \ ins ->
550− let parsers = fmap (\xs -> P.fromFold $ FL.ltake (length xs) FL.toList) ins
550+ let parsers = fmap (\xs -> P.fromFold $ FL.takeLE (length xs) FL.toList) ins
551 in monadicIO $ do
551 in monadicIO $ do
552 outs <- run $
552 outs <- run $
553 S.parseD
553 S.parseD
@@ -560,8 +560,8 @@ monad =
560 forAll (listOf (chooseAny :: Gen Int)) $ \ list1 ->
560 forAll (listOf (chooseAny :: Gen Int)) $ \ list1 ->
561 forAll (listOf (chooseAny :: Gen Int)) $ \ list2 ->
561 forAll (listOf (chooseAny :: Gen Int)) $ \ list2 ->
562 let parser = do
562 let parser = do
563− olist1 <- P.fromFold (FL.ltake (length list1) FL.toList)
563+ olist1 <- P.fromFold (FL.takeLE (length list1) FL.toList)
564− olist2 <- P.fromFold (FL.ltake (length list2) FL.toList)
564+ olist2 <- P.fromFold (FL.takeLE (length list2) FL.toList)
565 return (olist1, olist2)
565 return (olist1, olist2)
566 in monadicIO $ do
566 in monadicIO $ do
567 (olist1, olist2) <-
567 (olist1, olist2) <-
@@ -582,7 +582,7 @@ parseMany =
582 ( run
582 ( run
583 $ S.toList
583 $ S.toList
584 $ S.parseManyD
584 $ S.parseManyD
585− (P.fromFold $ FL.ltake len FL.toList) (S.fromList $ concat ins)
585+ (P.fromFold $ FL.takeLE len FL.toList) (S.fromList $ concat ins)
586 )
586 )
587 listEquals (==) outs ins
587 listEquals (==) outs ins
588
588