on master help sign in
Rename takeLE to take
commit0414fe8ec68cc7d85e14dbd1fc838302de2897f4 authorRanjeet Kumar Ranjan <ranjeetr@composewell.com> dateThu 4 Mar 2021, 14:46 (6 years ago) parent305f89b
18 files changed+74−73
benchmark/Streamly/Benchmark/Data/Fold.hs+8−7 benchmark/Streamly/Benchmark/Data/Parser.hs+4−4 benchmark/Streamly/Benchmark/Data/Parser/ParserD.hs+1−1 benchmark/Streamly/Benchmark/FileSystem/Handle/Read.hs+2−2 benchmark/Streamly/Benchmark/Prelude/Serial/Transformation2.hs+2−2 src/Streamly/Data/Fold.hs+1−1 src/Streamly/Internal/Data/Array/Foreign/Mut/Types.hs+1−1 src/Streamly/Internal/Data/Fold.hs+6−6 src/Streamly/Internal/Data/Fold/Types.hs+10−10 src/Streamly/Internal/Data/Parser.hs+1−1 src/Streamly/Internal/Data/Parser/ParserD.hs+1−1 src/Streamly/Internal/Data/Stream/IsStream/Eliminate.hs+1−1 src/Streamly/Internal/Data/Stream/IsStream/Nesting.hs+7−7 src/Streamly/Internal/Data/Stream/StreamD/Type.hs+1−1 src/Streamly/Internal/FileSystem/Event/Linux.hs+1−1 test/Streamly/Test/Data/Fold.hs+9−9 test/Streamly/Test/Data/Parser.hs+6−6 test/Streamly/Test/Data/Parser/ParserD.hs+12−12
benchmark/Streamly/Benchmark/Data/Fold.hs+8−7
@@ -64,13 +64,14 @@ any value = IP.fold (FL.any (> value))
6464all :: (Monad m, Ord a) => a -> SerialT m a -> m Bool
6565all value = IP.fold (FL.all (<= value))
6666
67−{-# INLINE takeLE #-}
68−takeLE :: Monad m => Int -> SerialT m a -> m ()
69−takeLE value = IP.fold (FL.takeLE value FL.drain)
67+{-# INLINE take #-}
68+take :: Monad m => Int -> SerialT m a -> m ()
69+take value = IP.fold (FL.take value FL.drain)
7070
7171{-# INLINE sequence_ #-}
7272sequence_ :: Monad m => Int -> Fold m a ()
73−sequence_ value = foldr f (FL.yield ()) (Prelude.replicate value (FL.takeLE 1 FL.drain))
73+sequence_ value =
74+ foldr f (FL.yield ()) (Prelude.replicate value (FL.take 1 FL.drain))
7475
7576 where
7677
@@ -87,7 +88,7 @@ sliceSepBy value = IP.fold (FL.sliceSepBy (>= value) FL.drain)
8788
8889{-# INLINE many #-}
8990many :: Monad m => SerialT m Int -> m ()
90−many = IP.fold (FL.many FL.drain (FL.takeLE 1 FL.drain))
91+many = IP.fold (FL.many FL.drain (FL.take 1 FL.drain))
9192
9293{-# INLINE splitAllAny #-}
9394splitAllAny :: Monad m => Int -> SerialT m Int -> m (Bool, Bool)
@@ -242,7 +243,7 @@ o_1_space_serial_elimination value =
242243 , benchIOSink value "notElem" (S.fold (FL.notElem (value + 1)))
243244 , benchIOSink value "all" $ all value
244245 , benchIOSink value "any" $ any value
245− , benchIOSink value "takeLE" $ takeLE value
246+ , benchIOSink value "take" $ take value
246247 , benchIOSink value "sliceSepBy" $ sliceSepBy value
247248 , benchIOSink value "and" (S.fold FL.and . S.map (<= (value + 1)))
248249 , benchIOSink value "or" (S.fold FL.or . S.map (> (value + 1)))
@@ -277,7 +278,7 @@ o_1_space_serial_composition value =
277278 "composition"
278279 [ benchIOSink value "splitWith (all, any)" $ splitAllAny value
279280 , benchIOSink value "tee (all, any)" $ teeAllAny value
280− , benchIOSink value "many drain (takeLE 1)" many
281+ , benchIOSink value "many drain (take 1)" many
281282 , benchIOSink value "tee (sum, length)" teeSumLength
282283 , benchIOSink value "distribute [sum, length]" distribute
283284 , benchIOSink value "partition (sum, length)" partition
benchmark/Streamly/Benchmark/Data/Parser.hs+4−4
@@ -235,7 +235,7 @@ parseManyChunksOfSum :: Int -> Handle -> IO Int
235235parseManyChunksOfSum n inh =
236236 S.length
237237 $ IP.parseMany
238− (PR.fromFold $ FL.takeLE n FL.sum)
238+ (PR.fromFold $ FL.take n FL.sum)
239239 (S.unfold Handle.read inh)
240240
241241-------------------------------------------------------------------------------
@@ -246,7 +246,7 @@ parseManyChunksOfSum n inh =
246246parseManyUnfoldArrays :: Int -> [Array.Array Int] -> IO ()
247247parseManyUnfoldArrays count arrays = do
248248 let src = Source.source (Just (Producer.OuterLoop arrays))
249− let parser = PR.fromFold (FL.takeLE count FL.drain)
249+ let parser = PR.fromFold (FL.take count FL.drain)
250250 let readSrc =
251251 Source.producer
252252 $ Producer.concat Producer.fromList Array.producer
@@ -304,7 +304,7 @@ parseMany :: MonadCatch m => Int -> SerialT m Int -> m ()
304304parseMany n =
305305 S.drain
306306 . S.map getSum
307− . IP.parseMany (PR.fromFold $ FL.takeLE n FL.mconcat)
307+ . IP.parseMany (PR.fromFold $ FL.take n FL.mconcat)
308308 . S.map Sum
309309
310310{-# INLINE parseIterate #-}
@@ -312,7 +312,7 @@ parseIterate :: MonadCatch m => Int -> SerialT m Int -> m ()
312312parseIterate n =
313313 S.drain
314314 . S.map getSum
315− . IP.parseIterate (PR.fromFold . FL.takeLE n . FL.sconcat) (Sum 0)
315+ . IP.parseIterate (PR.fromFold . FL.take n . FL.sconcat) (Sum 0)
316316 . S.map Sum
317317
318318-------------------------------------------------------------------------------
benchmark/Streamly/Benchmark/Data/Parser/ParserD.hs+1−1
@@ -220,7 +220,7 @@ parseManyGroupsRolling b =
220220parseManyUnfoldArrays :: Int -> [Array.Array Int] -> IO ()
221221parseManyUnfoldArrays count arrays = do
222222 let src = Source.source (Just (Producer.OuterLoop arrays))
223− let parser = PR.fromFold (FL.takeLE count FL.drain)
223+ let parser = PR.fromFold (FL.take count FL.drain)
224224 let readSrc =
225225 Source.producer
226226 $ Producer.concat Producer.fromList Array.producer
benchmark/Streamly/Benchmark/FileSystem/Handle/Read.hs+2−2
@@ -311,11 +311,11 @@ chunksOfSum n inh = S.length $ S.chunksOf n FL.sum (S.unfold FH.read inh)
311311
312312foldManyPostChunksOfSum :: Int -> Handle -> IO Int
313313foldManyPostChunksOfSum n inh =
314− S.length $ IP.foldManyPost (FL.takeLE n FL.sum) (S.unfold FH.read inh)
314+ S.length $ IP.foldManyPost (FL.take n FL.sum) (S.unfold FH.read inh)
315315
316316foldManyChunksOfSum :: Int -> Handle -> IO Int
317317foldManyChunksOfSum n inh =
318− S.length $ IP.foldMany (FL.takeLE n FL.sum) (S.unfold FH.read inh)
318+ S.length $ IP.foldMany (FL.take n FL.sum) (S.unfold FH.read inh)
319319
320320-- XXX investigate why we need an INLINE in this case (GHC)
321321-- Even though allocations remain the same in both cases inlining improves time
benchmark/Streamly/Benchmark/Prelude/Serial/Transformation2.hs+2−2
@@ -138,7 +138,7 @@ foldMany :: Monad m => SerialT m Int -> m ()
138138foldMany =
139139 S.drain
140140 . S.map getSum
141− . Internal.foldMany (FL.takeLE 2 FL.mconcat)
141+ . Internal.foldMany (FL.take 2 FL.mconcat)
142142 . S.map Sum
143143
144144{-# INLINE _foldIterate #-}
@@ -146,7 +146,7 @@ _foldIterate :: Monad m => SerialT m Int -> m ()
146146_foldIterate =
147147 S.drain
148148 . S.map getSum
149− . Internal.foldIterate (FL.takeLE 2 . FL.sconcat) (Sum 0)
149+ . Internal.foldIterate (FL.take 2 . FL.sconcat) (Sum 0)
150150 . S.map Sum
151151
152152o_1_space_grouping :: Int -> [Benchmark]
src/Streamly/Data/Fold.hs+1−1
@@ -175,7 +175,7 @@ module Streamly.Data.Fold
175175
176176 {-
177177 -- ** Trimming
178− , takeLE
178+ , take
179179 -- takeByTime
180180 , ldrop
181181 , ldropWhile
src/Streamly/Internal/Data/Array/Foreign/Mut/Types.hs+1−1
@@ -789,7 +789,7 @@ writeNAllocWith alloc n = Fold step initial extract
789789-- | @writeN n@ folds a maximum of @n@ elements from the input stream to an
790790-- 'Array'.
791791--
792−-- @writeN n = Fold.takeLE n writeNUnsafe@
792+-- @writeN n = Fold.take n writeNUnsafe@
793793--
794794-- @since 0.7.0
795795{-# INLINE_NORMAL writeN #-}
src/Streamly/Internal/Data/Fold.hs+6−6
@@ -143,7 +143,7 @@ module Streamly.Internal.Data.Fold
143143 -}
144144
145145 -- ** Trimming
146− , takeLE
146+ , take
147147 , takeByTime
148148 -- By elements
149149 , sliceSepBy
@@ -643,10 +643,10 @@ rollingHash = rollingHashWithSalt defaultSalt
643643-- | Compute an 'Int' sized polynomial rolling hash of the first n elements of
644644-- a stream.
645645--
646−-- > rollingHashFirstN = takeLE n rollingHash
646+-- > rollingHashFirstN = take n rollingHash
647647{-# INLINABLE rollingHashFirstN #-}
648648rollingHashFirstN :: (Monad m, Enum a) => Int -> Fold m a Int64
649−rollingHashFirstN n = takeLE n rollingHash
649+rollingHashFirstN n = take n rollingHash
650650
651651------------------------------------------------------------------------------
652652-- Monoidal left folds
@@ -741,7 +741,7 @@ toListRev = mkAccum_ (flip (:)) []
741741-- and discarding the results.
742742{-# INLINABLE drainN #-}
743743drainN :: Monad m => Int -> Fold m a ()
744−drainN n = takeLE n drain
744+drainN n = take n drain
745745
746746------------------------------------------------------------------------------
747747-- To Elements
@@ -971,7 +971,7 @@ or = any (== True)
971971-- >>> splitAt_ 4 [1,2,3]
972972-- ([1,2,3],[])
973973--
974−-- > splitAt n f1 f2 = splitWith (,) (takeLE n f1) f2
974+-- > splitAt n f1 f2 = splitWith (,) (take n f1) f2
975975--
976976-- /Pre-release/
977977
@@ -982,7 +982,7 @@ splitAt
982982 -> Fold m a b
983983 -> Fold m a c
984984 -> Fold m a (b, c)
985−splitAt n fld = splitWith (,) (takeLE n fld)
985+splitAt n fld = splitWith (,) (take n fld)
986986
987987------------------------------------------------------------------------------
988988-- Element Aware APIs
src/Streamly/Internal/Data/Fold/Types.hs+10−10
@@ -199,7 +199,7 @@ module Streamly.Internal.Data.Fold.Types
199199 , filter
200200 , filterM
201201 , lcatMaybes
202− , takeLE
202+ , take
203203 , takeByTime
204204
205205 -- * Distributing
@@ -241,7 +241,7 @@ import Fusion.Plugin.Types (Fuse(..))
241241import Streamly.Internal.Data.Tuple.Strict (Tuple'(..), Tuple3'(..))
242242import Streamly.Internal.Data.SVar (MonadAsync)
243243
244−import Prelude hiding (concatMap, filter, map)
244+import Prelude hiding (concatMap, filter, map, take)
245245
246246-- $setup
247247-- >>> :m
@@ -682,7 +682,7 @@ data ConcatMapState m sa a c
682682-- Compare with 'Monad' instance method '>>='.
683683--
684684-- >>> import Data.Maybe (fromJust)
685−-- >>> Stream.fold (Fold.concatMap (flip Fold.takeLE Fold.sum) (Fold.rmapM (return . fromJust) Fold.head)) $ Stream.fromList [10,9..1]
685+-- >>> Stream.fold (Fold.concatMap (flip Fold.take Fold.sum) (Fold.rmapM (return . fromJust) Fold.head)) $ Stream.fromList [10,9..1]
686686-- 45
687687--
688688-- /Pre-release/
@@ -796,18 +796,18 @@ lcatMaybes = filter isJust . map fromJust
796796
797797-- | Take at most @n@ input elements and fold them using the supplied fold.
798798--
799−-- >>> Stream.fold (Fold.takeLE 1 Fold.toList) $ Stream.fromList [1]
799+-- >>> Stream.fold (Fold.take 1 Fold.toList) $ Stream.fromList [1]
800800-- [1]
801801--
802−-- >>> Stream.fold (Fold.takeLE (-1) Fold.toList) $ Stream.fromList [1]
802+-- >>> Stream.fold (Fold.take (-1) Fold.toList) $ Stream.fromList [1]
803803-- []
804804--
805805-- /Pre-release/
806806--
807807-- @since 0.7.0
808−{-# INLINE takeLE #-}
809−takeLE :: Monad m => Int -> Fold m a b -> Fold m a b
810−takeLE n (Fold fstep finitial fextract) = Fold step initial extract
808+{-# INLINE take #-}
809+take :: Monad m => Int -> Fold m a b -> Fold m a b
810+take n (Fold fstep finitial fextract) = Fold step initial extract
811811
812812 where
813813
@@ -954,7 +954,7 @@ many (Fold cstep cinitial cextract) (Fold sstep sinitial sextract) =
954954-- of @n@ items in the input stream and supplies the result to the @collect@
955955-- fold.
956956--
957−-- > chunksOf n split collect = many collect (takeLE n split)
957+-- > chunksOf n split collect = many collect (take n split)
958958--
959959-- Stops when @collect@ stops.
960960--
@@ -962,7 +962,7 @@ many (Fold cstep cinitial cextract) (Fold sstep sinitial sextract) =
962962--
963963{-# INLINE chunksOf #-}
964964chunksOf :: Monad m => Int -> Fold m a b -> Fold m b c -> Fold m a c
965−chunksOf n split collect = many collect (takeLE n split)
965+chunksOf n split collect = many collect (take n split)
966966
967967{-# INLINE chunksOf2 #-}
968968chunksOf2 :: Monad m => Int -> Fold m a b -> Fold2 m x b c -> Fold2 m x a c
src/Streamly/Internal/Data/Parser.hs+1−1
@@ -379,7 +379,7 @@ either = K.toParserK . D.either
379379-- be defined in terms of takeBetween. For example:
380380--
381381-- @
382−-- take = takeBetween 0 n -- equivalent of takeLE
382+-- take = takeBetween 0 n -- equivalent of take
383383-- take1 = takeBetween 1 n -- equivalent of takeLE1
384384-- takeEQ = takeBetween n n
385385-- takeGE = takeBetween n maxBound
src/Streamly/Internal/Data/Parser/ParserD.hs+1−1
@@ -45,7 +45,7 @@ module Streamly.Internal.Data.Parser.ParserD
4545 --
4646 -- Grab a sequence of input elements without inspecting them
4747 , takeBetween
48− -- , takeLE -- take -- takeBetween 0 n
48+ -- , take -- take -- takeBetween 0 n
4949 -- , takeLE1 -- take1 -- takeBetween 1 n
5050 , takeEQ -- takeBetween n n
5151 , takeGE -- takeBetween n maxBound
src/Streamly/Internal/Data/Stream/IsStream/Eliminate.hs+1−1
@@ -398,7 +398,7 @@ drain = P.drain
398398
399399-- |
400400-- > drainN n = drain . take n
401−-- > drainN n = fold (Fold.takeLE n Fold.drain)
401+-- > drainN n = fold (Fold.take n Fold.drain)
402402--
403403-- Run maximum up to @n@ iterations of a stream.
404404--
src/Streamly/Internal/Data/Stream/IsStream/Nesting.hs+7−7
@@ -946,7 +946,7 @@ iterateMapLeftsWith combine f = iterateMapWith combine (either f (const K.nil))
946946-- | Like 'foldMany' but appends empty fold output if the fold and stream
947947-- termination aligns:
948948--
949−-- >>> f = Fold.takeLE 2 Fold.sum
949+-- >>> f = Fold.take 2 Fold.sum
950950-- >>> Stream.toList $ Stream.foldManyPost f $ Stream.fromList []
951951-- [0]
952952-- >>> Stream.toList $ Stream.foldManyPost f $ Stream.fromList [1..9]
@@ -969,7 +969,7 @@ foldManyPost f m = D.fromStreamD $ D.foldManyPost f (D.toStreamD m)
969969--
970970-- To sum every two contiguous elements in a stream:
971971--
972−-- >>> f = Fold.takeLE 2 Fold.sum
972+-- >>> f = Fold.take 2 Fold.sum
973973-- >>> Stream.toList $ Stream.foldMany f $ Stream.fromList [1..10]
974974-- [3,7,11,15,19]
975975--
@@ -978,7 +978,7 @@ foldManyPost f m = D.fromStreamD $ D.foldManyPost f (D.toStreamD m)
978978-- >>> Stream.toList $ Stream.foldMany f $ Stream.fromList []
979979-- []
980980--
981−-- Note @foldMany (takeLE 0)@ would result in an infinite loop in a non-empty
981+-- Note @foldMany (take 0)@ would result in an infinite loop in a non-empty
982982-- stream.
983983--
984984-- /Pre-release/
@@ -1010,7 +1010,7 @@ foldSequence _f _m = undefined
10101010--
10111011-- @
10121012-- > import Data.Monoid (Sum(..))
1013−-- > f x = Fold.takeLE 2 (Fold.sconcat x)
1013+-- > f x = Fold.take 2 (Fold.sconcat x)
10141014-- > s = Stream.map Sum $ Stream.fromList [1..10]
10151015-- > Stream.toList $ Stream.map getSum $ Stream.foldIterate f 0 s
10161016-- [3,10,21,36,55,55]
@@ -1715,10 +1715,10 @@ splitOnSuffixSeqAny subseq f m = undefined
17151715-- >>> Stream.toList $ Stream.chunksOf 2 Fold.sum (Stream.enumerateFromTo 1 10)
17161716-- [3,7,11,15,19]
17171717--
1718−-- This can be considered as an n-fold version of 'takeLE' where we apply
1719−-- 'takeLE' repeatedly on the leftover stream until the stream exhausts.
1718+-- This can be considered as an n-fold version of 'take' where we apply
1719+-- 'take' repeatedly on the leftover stream until the stream exhausts.
17201720--
1721−-- @chunksOf n f = foldMany (FL.takeLE n f)@
1721+-- @chunksOf n f = foldMany (FL.take n f)@
17221722--
17231723-- @since 0.7.0
17241724{-# INLINE chunksOf #-}
src/Streamly/Internal/Data/Stream/StreamD/Type.hs+1−1
@@ -898,7 +898,7 @@ foldMany (Fold fstep initial extract) (Stream step state) =
898898
899899{-# INLINE chunksOf #-}
900900chunksOf :: Monad m => Int -> Fold m a b -> Stream m a -> Stream m b
901−chunksOf n f = foldMany (FL.takeLE n f)
901+chunksOf n f = foldMany (FL.take n f)
902902
903903data GroupState2 s fs
904904 = GroupStart2 s
src/Streamly/Internal/FileSystem/Event/Linux.hs+1−1
@@ -787,7 +787,7 @@ readOneEvent cfg wt@(Watch _ wdMap) = do
787787 pth <-
788788 PR.fromFold
789789 $ FL.sliceSepBy (== 0)
790− $ FL.takeLE pathLen (A.writeN pathLen)
790+ $ FL.take pathLen (A.writeN pathLen)
791791 let remaining = pathLen - A.length pth - 1
792792 when (remaining /= 0) $ PR.takeEQ remaining FL.drain
793793 return pth
test/Streamly/Test/Data/Fold.hs+9−9
@@ -22,7 +22,7 @@ import qualified Streamly.Prelude as S
2222import qualified Streamly.Data.Fold as FL
2323
2424import Prelude hiding
25− (maximum, minimum, elem, notElem, null, product, sum, head, last)
25+ (maximum, minimum, elem, notElem, null, product, sum, head, last, take)
2626import Test.Hspec as H
2727import Test.Hspec.QuickCheck
2828
@@ -147,7 +147,7 @@ find f ls = do
147147 let fld = S.fold (FL.find f) (S.fromList ls)
148148 in fld `shouldReturn` Nothing
149149 Just idx ->
150− let fld = S.fold (FL.any f) (S.fromList $ take idx ls)
150+ let fld = S.fold (FL.any f) (S.fromList $ Prelude.take idx ls)
151151 in fld `shouldReturn` False
152152
153153neg :: (a -> Bool) -> a -> Bool
@@ -165,7 +165,7 @@ findIndex f ls = do
165165 then
166166 S.fold (FL.all f) (S.fromList []) `shouldReturn` True
167167 else
168− S.fold (FL.all f) (S.fromList $ take idx ls)
168+ S.fold (FL.all f) (S.fromList $ Prelude.take idx ls)
169169 `shouldReturn` False
170170
171171predicate :: Int -> Bool
@@ -179,7 +179,7 @@ elemIndex elm ls = do
179179 let fld = S.fold (FL.any (== elm)) (S.fromList ls)
180180 in fld `shouldReturn` False
181181 Just idx ->
182− let fld = S.fold (FL.any (== elm)) (S.fromList $ take idx ls)
182+ let fld = S.fold (FL.any (== elm)) (S.fromList $ Prelude.take idx ls)
183183 in fld `shouldReturn` False
184184
185185null :: [Int] -> Expectation
@@ -215,10 +215,10 @@ and ls = S.fold FL.and (S.fromList ls) `shouldReturn` Prelude.and ls
215215or :: [Bool] -> Expectation
216216or ls = S.fold FL.or (S.fromList ls) `shouldReturn` Prelude.or ls
217217
218−takeLE :: [Int] -> Property
219−takeLE ls =
218+take :: [Int] -> Property
219+take ls =
220220 forAll (chooseInt (-1, Prelude.length ls + 2)) $ \n ->
221− S.fold (F.takeLE n FL.toList) (S.fromList ls)
221+ S.fold (F.take n FL.toList) (S.fromList ls)
222222 `shouldReturn` Prelude.take n ls
223223
224224sliceSepBy :: Property
@@ -236,7 +236,7 @@ sliceSepByMax =
236236 forAll (chooseInt (min_value, max_value)) $ \n ->
237237 forAll (listOf (chooseInt (0, 1))) $ \ls ->
238238 let p = (== 1)
239− f = F.sliceSepBy p (F.takeLE n FL.toList)
239+ f = F.sliceSepBy p (F.take n FL.toList)
240240 ys = Prelude.take n (Prelude.takeWhile (not . p) ls)
241241 in case S.fold f (S.fromList ls) of
242242 Right xs -> checkListEqual xs ys
@@ -443,7 +443,7 @@ main = hspec $
443443 prop "And" Main.and
444444 prop "Or" Main.or
445445 prop "mapMaybe" mapMaybe
446− prop "takeLE" takeLE
446+ prop "take" take
447447 prop "sliceSepBy" sliceSepBy
448448 prop "sliceSepByMax" sliceSepByMax
449449 prop "drain" Main.drain
test/Streamly/Test/Data/Parser.hs+6−6
@@ -554,8 +554,8 @@ applicative =
554554 forAll (listOf (chooseAny :: Gen Int)) $ \ list2 ->
555555 let parser =
556556 (,)
557− <$> P.fromFold (FL.takeLE (length list1) FL.toList)
558− <*> P.fromFold (FL.takeLE (length list2) FL.toList)
557+ <$> P.fromFold (FL.take (length list1) FL.toList)
558+ <*> P.fromFold (FL.take (length list2) FL.toList)
559559 in monadicIO $ do
560560 (olist1, olist2) <-
561561 run $ S.parse parser (S.fromList $ list1 ++ list2)
@@ -565,7 +565,7 @@ applicative =
565565sequence :: Property
566566sequence =
567567 forAll (vectorOf 11 (listOf (chooseAny :: Gen Int))) $ \ ins ->
568− let p xs = P.fromFold (FL.takeLE (length xs) FL.toList)
568+ let p xs = P.fromFold (FL.take (length xs) FL.toList)
569569 in monadicIO $ do
570570 outs <- run $
571571 S.parse
@@ -578,8 +578,8 @@ monad =
578578 forAll (listOf (chooseAny :: Gen Int)) $ \ list1 ->
579579 forAll (listOf (chooseAny :: Gen Int)) $ \ list2 ->
580580 let parser = do
581− olist1 <- P.fromFold (FL.takeLE (length list1) FL.toList)
582− olist2 <- P.fromFold (FL.takeLE (length list2) FL.toList)
581+ olist1 <- P.fromFold (FL.take (length list1) FL.toList)
582+ olist2 <- P.fromFold (FL.take (length list2) FL.toList)
583583 return (olist1, olist2)
584584 in monadicIO $ do
585585 (olist1, olist2) <-
@@ -597,7 +597,7 @@ parseMany =
597597 forAll (listOf (vectorOf len (chooseAny :: Gen Int))) $ \ ins ->
598598 monadicIO $ do
599599 outs <- do
600− let p = P.fromFold $ FL.takeLE len FL.toList
600+ let p = P.fromFold $ FL.take len FL.toList
601601 run
602602 $ S.toList
603603 $ S.parseMany p (S.fromList $ concat ins)
test/Streamly/Test/Data/Parser/ParserD.hs+12−12
@@ -185,7 +185,7 @@ take :: Property
185185take =
186186 forAll (chooseInt (min_value, max_value)) $ \n ->
187187 forAll (listOf (chooseInt (min_value, max_value))) $ \ls ->
188− case S.parseD (P.fromFold $ FL.takeLE n FL.toList) (S.fromList ls) of
188+ case S.parseD (P.fromFold $ FL.take n FL.toList) (S.fromList ls) of
189189 Right parsed_list -> checkListEqual parsed_list (Prelude.take n ls)
190190 Left _ -> property False
191191
@@ -266,7 +266,7 @@ lookAheadPass :: Property
266266lookAheadPass =
267267 forAll (chooseInt (min_value, max_value)) $ \n ->
268268 let
269− takeWithoutConsume = P.lookAhead $ P.fromFold $ FL.takeLE n FL.toList
269+ takeWithoutConsume = P.lookAhead $ P.fromFold $ FL.take n FL.toList
270270 parseTwice = do
271271 parsed_list_1 <- takeWithoutConsume
272272 parsed_list_2 <- takeWithoutConsume
@@ -282,7 +282,7 @@ lookAhead :: Property
282282lookAhead =
283283 forAll (chooseInt (min_value, max_value)) $ \n ->
284284 let
285− takeWithoutConsume = P.lookAhead $ P.fromFold $ FL.takeLE n FL.toList
285+ takeWithoutConsume = P.lookAhead $ P.fromFold $ FL.take n FL.toList
286286 parseTwice = do
287287 parsed_list_1 <- takeWithoutConsume
288288 parsed_list_2 <- takeWithoutConsume
@@ -360,7 +360,7 @@ sliceSepByMax :: Property
360360sliceSepByMax =
361361 forAll (chooseInt (min_value, max_value)) $ \n ->
362362 forAll (listOf (chooseInt (0, 1))) $ \ls ->
363− case S.parseD (P.fromFold $ FL.sliceSepBy predicate (FL.takeLE n FL.toList)) (S.fromList ls) of
363+ case S.parseD (P.fromFold $ FL.sliceSepBy predicate (FL.take n FL.toList)) (S.fromList ls) of
364364 Right parsed_list -> checkListEqual parsed_list (Prelude.take n (Prelude.takeWhile (not . predicate) ls))
365365 Left _ -> property False
366366 where
@@ -417,7 +417,7 @@ teeWithPass =
417417 forAll (chooseInt (min_value, max_value)) $ \n ->
418418 forAll (listOf (chooseInt (0, 1))) $ \ls ->
419419 let
420− prsr = P.fromFold $ FL.takeLE n FL.toList
420+ prsr = P.fromFold $ FL.take n FL.toList
421421 in
422422 case S.parseD (P.teeWith (,) prsr prsr) (S.fromList ls) of
423423 Right (ls_1, ls_2) -> checkListEqual (Prelude.take n ls) ls_1 .&&. checkListEqual ls_1 ls_2
@@ -557,8 +557,8 @@ applicative =
557557 forAll (listOf (chooseAny :: Gen Int)) $ \ list2 ->
558558 let parser =
559559 (,)
560− <$> P.fromFold (FL.takeLE (length list1) FL.toList)
561− <*> P.fromFold (FL.takeLE (length list2) FL.toList)
560+ <$> P.fromFold (FL.take (length list1) FL.toList)
561+ <*> P.fromFold (FL.take (length list2) FL.toList)
562562 in monadicIO $ do
563563 (olist1, olist2) <-
564564 run $ S.parseD parser (S.fromList $ list1 ++ list2)
@@ -568,7 +568,7 @@ applicative =
568568sequence :: Property
569569sequence =
570570 forAll (vectorOf 11 (listOf (chooseAny :: Gen Int))) $ \ ins ->
571− let parsers = fmap (\xs -> P.fromFold $ FL.takeLE (length xs) FL.toList) ins
571+ let parsers = fmap (\xs -> P.fromFold $ FL.take (length xs) FL.toList) ins
572572 in monadicIO $ do
573573 outs <- run $
574574 S.parseD
@@ -581,8 +581,8 @@ monad =
581581 forAll (listOf (chooseAny :: Gen Int)) $ \ list1 ->
582582 forAll (listOf (chooseAny :: Gen Int)) $ \ list2 ->
583583 let parser = do
584− olist1 <- P.fromFold (FL.takeLE (length list1) FL.toList)
585− olist2 <- P.fromFold (FL.takeLE (length list2) FL.toList)
584+ olist1 <- P.fromFold (FL.take (length list1) FL.toList)
585+ olist2 <- P.fromFold (FL.take (length list2) FL.toList)
586586 return (olist1, olist2)
587587 in monadicIO $ do
588588 (olist1, olist2) <-
@@ -603,7 +603,7 @@ parseMany =
603603 ( run
604604 $ S.toList
605605 $ S.parseManyD
606− (P.fromFold $ FL.takeLE len FL.toList) (S.fromList $ concat ins)
606+ (P.fromFold $ FL.take len FL.toList) (S.fromList $ concat ins)
607607 )
608608 listEquals (==) outs ins
609609
@@ -622,7 +622,7 @@ parseUnfold = do
622622 monadicIO $ do
623623 arrays <- S.toList $ S.arraysOf clen (S.fromList ls)
624624 let src = Source.source (Just (Producer.OuterLoop arrays))
625− let parser = P.fromFold (FL.takeLE tlen FL.toList)
625+ let parser = P.fromFold (FL.take tlen FL.toList)
626626 let readSrc =
627627 Source.producer
628628 $ Producer.concat Producer.fromList A.producer