on d1146fb help sign in
771 lines 23 kB history raw
1module Main (main) where
3import Data.Semigroup (Sum(..), getSum)
4import Streamly.Test.Common (checkListEqual, listEquals)
5import Test.QuickCheck
6 ( Gen
7 , Property
8 , arbitrary
9 , choose
10 , forAll
11 , listOf
12 , listOf1
13 , property
14 , vectorOf
15 , withMaxSuccess
16 )
17import Test.QuickCheck.Monadic (monadicIO, assert, run)
19import qualified Data.Map
20import qualified Prelude
21import qualified Streamly.Internal.Data.Fold as F
22import qualified Streamly.Prelude as S
23import qualified Streamly.Internal.Data.Stream.IsStream as Stream
24import qualified Streamly.Data.Fold as FL
26import Prelude hiding
27 (maximum, minimum, elem, notElem, null, product, sum, head, last, take)
28import Test.Hspec as H
29import Test.Hspec.QuickCheck
31maxStreamLen :: Int
32maxStreamLen = 1000
34intMin :: Int
35intMin = minBound
37intMax :: Int
38intMax = maxBound
40min_value :: Int
41min_value = 0
43max_value :: Int
44max_value = 10000
46chooseInt :: (Int, Int) -> Gen Int
47chooseInt = choose
49{-# INLINE maxStreamLen #-}
50{-# INLINE intMin #-}
51{-# INLINE intMax #-}
53rollingHashFirstN :: Property
54rollingHashFirstN =
55 forAll (choose (0, maxStreamLen)) $ \len ->
56 forAll (choose (0, len)) $ \n ->
57 forAll (vectorOf len (arbitrary :: Gen Int)) $ \vec ->
58 monadicIO $ do
59 a <- run $ S.fold F.rollingHash $ S.take n $ S.fromList vec
60 b <- run $ S.fold (F.rollingHashFirstN n) $ S.fromList vec
61 assert $ a == b
63head :: [Int] -> Expectation
64head ls = S.fold FL.head (S.fromList ls) `shouldReturn` headl ls
66headl :: [a] -> Maybe a
67headl [] = Nothing
68headl (x:_) = Just x
70length :: [Int] -> Expectation
71length ls = S.fold FL.length (S.fromList ls) `shouldReturn` Prelude.length ls
73sum :: [Int] -> Expectation
74sum ls = S.fold FL.sum (S.fromList ls) `shouldReturn` Prelude.sum ls
76product :: [Int] -> Expectation
77product ls =
78 S.fold FL.product (S.fromList ls) `shouldReturn` Prelude.product ls
80lesser :: (a -> a -> Ordering) -> a -> a -> a
81lesser f x y = if f x y == LT then x else y
83greater :: (a -> a -> Ordering) -> a -> a -> a
84greater f x y = if f x y == GT then x else y
86foldMaybe :: (b -> a -> b) -> b -> [a] -> Maybe b
87foldMaybe f acc ls =
88 case ls of
89 [] -> Nothing
90 _ -> Just (foldl f acc ls)
92maximumBy :: (Ord a, Show a) => a -> (a -> a -> Ordering) -> [a] -> Expectation
93maximumBy genmin f ls =
94 S.fold (FL.maximumBy f) (S.fromList ls)
95 `shouldReturn` foldMaybe (greater f) genmin ls
97maximum :: (Show a, Ord a) => a -> [a] -> Expectation
98maximum genmin ls =
99 S.fold FL.maximum (S.fromList ls)
100 `shouldReturn` foldMaybe (greater compare) genmin ls
102minimumBy :: (Ord a, Show a) => a -> (a -> a -> Ordering) -> [a] -> Expectation
103minimumBy genmax f ls =
104 S.fold (FL.minimumBy f) (S.fromList ls)
105 `shouldReturn` foldMaybe (lesser f) genmax ls
107minimum :: (Show a, Ord a) => a -> [a] -> Expectation
108minimum genmax ls =
109 S.fold FL.minimum (S.fromList ls)
110 `shouldReturn` foldMaybe (lesser compare) genmax ls
112toList :: [Int] -> Expectation
113toList ls = S.fold FL.toList (S.fromList ls) `shouldReturn` ls
115toListRev :: [Int] -> Expectation
116toListRev ls = S.fold FL.toListRev (S.fromList ls) `shouldReturn` reverse ls
118safeLast :: [a] -> Maybe a
119safeLast [] = Nothing
120safeLast (x:[]) = Just x
121safeLast (_:xs) = safeLast xs
123last :: [String] -> Expectation
124last ls = S.fold FL.last (S.fromList ls) `shouldReturn` safeLast ls
126mapMaybe :: [Int] -> Expectation
127mapMaybe ls =
128 let maybeEven x =
129 if even x
130 then Just x
131 else Nothing
132 f = FL.mapMaybe maybeEven FL.toList
133 in S.fold f (S.fromList ls) `shouldReturn` filter even ls
135nth :: Int -> [a] -> Maybe a
136nth idx (x : xs)
137 | idx == 0 = Just x
138 | idx < 0 = Nothing
139 | otherwise = nth (idx - 1) xs
140nth _ [] = Nothing
142index :: Int -> [String] -> Expectation
143index idx ls =
144 let x = S.fold (FL.index idx) (S.fromList ls)
145 in x `shouldReturn` nth idx ls
147find :: (Show a, Eq a) => (a -> Bool) -> [a] -> Expectation
148find f ls = do
149 y <- S.fold (FL.findIndex f) (S.fromList ls)
150 case y of
151 Nothing ->
152 let fld = S.fold (FL.find f) (S.fromList ls)
153 in fld `shouldReturn` Nothing
154 Just idx ->
155 let fld = S.fold (FL.any f) (S.fromList $ Prelude.take idx ls)
156 in fld `shouldReturn` False
158neg :: (a -> Bool) -> a -> Bool
159neg f x = not (f x)
161findIndex :: (a -> Bool) -> [a] -> Expectation
162findIndex f ls = do
163 y <- S.fold (FL.findIndex f) (S.fromList ls)
164 case y of
165 Nothing ->
166 let fld = S.fold (FL.all $ neg f) (S.fromList ls)
167 in fld `shouldReturn` True
168 Just idx ->
169 if idx == 0
170 then
171 S.fold (FL.all f) (S.fromList []) `shouldReturn` True
172 else
173 S.fold (FL.all f) (S.fromList $ Prelude.take idx ls)
174 `shouldReturn` False
176predicate :: Int -> Bool
177predicate x = x * x < 100
179elemIndex :: Int -> [Int] -> Expectation
180elemIndex elm ls = do
181 y <- S.fold (FL.elemIndex elm) (S.fromList ls)
182 case y of
183 Nothing ->
184 let fld = S.fold (FL.any (== elm)) (S.fromList ls)
185 in fld `shouldReturn` False
186 Just idx ->
187 let fld =
188 S.fold (FL.any (== elm)) (S.fromList $ Prelude.take idx ls)
189 in fld `shouldReturn` False
191null :: [Int] -> Expectation
192null ls =
193 S.fold FL.null (S.fromList ls)
194 `shouldReturn`
195 case ls of
196 [] -> True
197 _ -> False
199elem :: Int -> [Int] -> Expectation
200elem elm ls = do
201 y <- S.fold (FL.elem elm) (S.fromList ls)
202 let fld = S.fold (FL.any (== elm)) (S.fromList ls)
203 fld `shouldReturn` y
205notElem :: Int -> [Int] -> Expectation
206notElem elm ls = do
207 y <- S.fold (FL.notElem elm) (S.fromList ls)
208 let fld = S.fold (FL.any (== elm)) (S.fromList ls)
209 fld `shouldReturn` not y
211all :: (a -> Bool) -> [a] -> Expectation
212all f ls =
213 S.fold (FL.all f) (S.fromList ls) `shouldReturn` Prelude.all f ls
215any :: (a -> Bool) -> [a] -> Expectation
216any f ls = S.fold (FL.any f) (S.fromList ls) `shouldReturn` Prelude.any f ls
218and :: [Bool] -> Expectation
219and ls = S.fold FL.and (S.fromList ls) `shouldReturn` Prelude.and ls
221or :: [Bool] -> Expectation
222or ls = S.fold FL.or (S.fromList ls) `shouldReturn` Prelude.or ls
224take :: [Int] -> Property
225take ls =
226 forAll (chooseInt (-1, Prelude.length ls + 2)) $ \n ->
227 S.fold (FL.take n FL.toList) (S.fromList ls)
228 `shouldReturn` Prelude.take n ls
230takeEndBy_ :: Property
231takeEndBy_ =
232 forAll (listOf (chooseInt (0, 1))) $ \ls ->
233 let p = (== 1)
234 f = FL.takeEndBy_ p FL.toList
235 ys = Prelude.takeWhile (not . p) ls
236 in case S.fold f (S.fromList ls) of
237 Right xs -> checkListEqual xs ys
238 Left _ -> property False
240takeEndByOrMax :: Property
241takeEndByOrMax =
242 forAll (chooseInt (min_value, max_value)) $ \n ->
243 forAll (listOf (chooseInt (0, 1))) $ \ls ->
244 let p = (== 1)
245 f = FL.takeEndBy_ p (FL.take n FL.toList)
246 ys = Prelude.take n (Prelude.takeWhile (not . p) ls)
247 in case S.fold f (S.fromList ls) of
248 Right xs -> checkListEqual xs ys
249 Left _ -> property False
251chooseFloat :: (Float, Float) -> Gen Float
252chooseFloat = choose
254drain :: [Int] -> Expectation
255drain ls = S.fold FL.drain (S.fromList ls) `shouldReturn` ()
257drainBy :: [Int] -> Expectation
258drainBy ls = S.fold (FL.drainBy return) (S.fromList ls) `shouldReturn` ()
260mean :: Property
261mean =
262 forAll (listOf1 (chooseFloat (-100.0, 100.0)))
263 $ \ls0 -> withMaxSuccess 1000 $ monadicIO $ action ls0
265 where
267 action ls = do
268 v1 <- run $ S.fold FL.mean (S.fromList ls)
269 let v2 = Prelude.sum ls / fromIntegral (Prelude.length ls)
270 assert (abs (v1 - v2) < 0.0001)
272stdDev :: Property
273stdDev =
274 forAll (listOf1 (chooseFloat (-100.0, 100.0)))
275 $ \ls0 -> withMaxSuccess 1000 $ monadicIO $ action ls0
277 where
279 action ls = do
280 v1 <- run $ S.fold FL.stdDev (S.fromList ls)
281 let avg = Prelude.sum ls / fromIntegral (Prelude.length ls)
282 se = Prelude.sum (fmap (\x -> (x - avg) * (x - avg)) ls)
283 sd = sqrt $ se / fromIntegral (Prelude.length ls)
284 assert (abs (v1 - sd) < 0.0001 )
286variance :: Property
287variance =
288 forAll (listOf1 (chooseFloat (-100.0, 100.0)))
289 $ \ls0 -> withMaxSuccess 1000 $ monadicIO $ action ls0
291 where
293 action ls = do
294 v1 <- run $ S.fold FL.variance (S.fromList ls)
295 let avg = Prelude.sum ls / fromIntegral (Prelude.length ls)
296 se = Prelude.sum (fmap (\x -> (x - avg) * (x - avg)) ls)
297 vr = se / fromIntegral (Prelude.length ls)
298 assert (abs (v1 - vr) < 0.01 )
300mconcat :: Property
301mconcat =
302 forAll (listOf1 (chooseInt (intMin, intMax)))
303 $ \ls0 -> monadicIO $ action ls0
305 where
307 action ls = do
308 v1 <- run $ S.fold FL.mconcat (S.map Sum $ S.fromList ls)
309 let v2 = Prelude.sum ls
310 assert (getSum v1 == v2)
312foldMap :: Property
313foldMap =
314 forAll (listOf1 (chooseInt (intMin, intMax)))
315 $ \ls0 -> monadicIO $ action ls0
317 where
319 action ls = do
320 v1 <- run $ S.fold (FL.foldMap Sum) $ S.fromList ls
321 let v2 = Prelude.sum ls
322 assert (getSum v1 == v2)
324foldMapM :: Property
325foldMapM =
326 forAll (listOf1 (chooseInt (intMin, intMax)))
327 $ \ls0 -> monadicIO $ action ls0
329 where
331 action ls = do
332 v1 <- run $ S.fold (FL.foldMapM (return . Sum)) $ S.fromList ls
333 let v2 = Prelude.sum ls
334 assert (getSum v1 == v2)
336lookup :: Property
337lookup =
338 forAll (chooseInt (1, 15))
339 $ \key0 ->monadicIO $ action key0
341 where
343 action key = do
344 let ls = [ (1, "first"), (2, "second"), (3, "third"), (4, "fourth")
345 , (5, "fifth"), (6, "fifth+first"), (7, "fifth+second")
346 , (8, "fifth+third"), (9, "fifth+fourth")
347 , (10, "fifth+fifth")
348 ]
349 v1 <- run $ S.fold (FL.lookup key) $ S.fromList ls
350 let v2 = Prelude.lookup key ls
351 assert (v1 == v2)
353rmapM :: Property
354rmapM =
355 forAll (listOf1 (chooseInt (intMin, intMax)))
356 $ \ls0 -> monadicIO $ action ls0
358 where
360 action ls = do
361 let addLen x = return $ x + Prelude.length ls
362 fld = FL.rmapM addLen FL.sum
363 v2 = foldl (+) (Prelude.length ls) ls
364 v1 <- run $ S.fold fld $ S.fromList ls
365 assert (v1 == v2)
367teeWithLength :: Property
368teeWithLength =
369 forAll (listOf1 (chooseInt (intMin, intMax)))
370 $ \ls0 -> monadicIO $ action ls0
372 where
374 action ls = do
375 v1 <- run $ S.fold (FL.tee FL.sum FL.length) $ S.fromList ls
376 let v2 = Prelude.sum ls
377 v3 = Prelude.length ls
378 assert (v1 == (v2, v3))
380teeWithFstLength :: Property
381teeWithFstLength =
382 forAll (listOf1 (chooseInt (intMin, intMax)))
383 $ \ls0 -> monadicIO $ action ls0
385 where
387 action ls = do
388 v1 <- run $ S.fold (F.teeWithFst (,) (FL.take 5 FL.sum) FL.length) $ S.fromList ls
389 let v2 = Prelude.sum (Prelude.take 5 ls)
390 v3 = Prelude.length (Prelude.take 5 ls)
391 assert (v1 == (v2, v3))
393partitionByM :: Property
394partitionByM =
395 forAll (listOf1 (chooseInt (intMin, intMax)))
396 $ \ls0 -> monadicIO $ action ls0
398 where
400 action ls = do
401 let f = \x -> if odd x then return (Left x) else return (Right x)
402 v1 <- run $ S.fold (F.partitionByM f FL.length FL.length) $ S.fromList ls
403 let v2 = foldl (\b a -> if odd a then b+1 else b) 0 ls
404 v3 = foldl (\b a -> if even a then b+1 else b) 0 ls
405 assert (v1 == (v2, v3))
407partitionByFstM :: Property
408partitionByFstM =
409 forAll (listOf1 (chooseInt (intMin, intMax)))
410 $ \ls0 -> monadicIO $ action ls0
412 where
414 action _ = do
415 let f = \x -> if odd x then return (Left x) else return (Right x)
416 v1 <- run $ S.fold (F.partitionByFstM f (FL.take 25 FL.length) FL.length) (S.fromList ([1..100]:: [Int]))
417 let v2 = foldl (\b a -> if odd a then b+1 else b) 0 ([1..49] :: [Int])
418 v3 = foldl (\b a -> if even a then b+1 else b) 0 ([1..49] :: [Int])
419 assert (v1 == (v2, v3))
421partitionByMinM1 :: Property
422partitionByMinM1 =
423 forAll (listOf1 (chooseInt (intMin, intMax)))
424 $ \ls0 -> monadicIO $ action ls0
426 where
428 action _ = do
429 let f = \x -> if odd x then return (Left x) else return (Right x)
430 v1 <- run $ S.fold (F.partitionByMinM f FL.length (FL.take 25 FL.length)) (S.fromList ([1..100]:: [Int]))
431 let v2 = foldl (\b a -> if odd a then b+1 else b) 0 ([1..50] :: [Int])
432 v3 = foldl (\b a -> if even a then b+1 else b) 0 ([1..50] :: [Int])
433 assert (v1 == (v2, v3))
435partitionByMinM2 :: Property
436partitionByMinM2 =
437 forAll (listOf1 (chooseInt (intMin, intMax)))
438 $ \ls0 -> monadicIO $ action ls0
440 where
442 action _ = do
443 let f = \x -> if odd x then return (Left x) else return (Right x)
444 v1 <- run $ S.fold (F.partitionByMinM f (FL.take 25 FL.length) FL.length) (S.fromList ([1..100]:: [Int]))
445 let v2 = foldl (\b a -> if odd a then b+1 else b) 0 ([1..49] :: [Int])
446 v3 = foldl (\b a -> if even a then b+1 else b) 0 ([1..49] :: [Int])
447 assert (v1 == (v2, v3))
449teeWithMinLength1 :: Property
450teeWithMinLength1 =
451 forAll (listOf1 (chooseInt (intMin, intMax)))
452 $ \ls0 -> monadicIO $ action ls0
454 where
456 action ls = do
457 v1 <- run $ S.fold (F.teeWithMin (,) (FL.take 5 FL.sum) FL.length) $ S.fromList ls
458 let v2 = Prelude.sum (Prelude.take 5 ls)
459 v3 = Prelude.length (Prelude.take 5 ls)
460 assert (v1 == (v2, v3))
463teeWithMinLength2 :: Property
464teeWithMinLength2 =
465 forAll (listOf1 (chooseInt (intMin, intMax)))
466 $ \ls0 -> monadicIO $ action ls0
468 where
470 action ls = do
471 v1 <- run $ S.fold (F.teeWithMin (,) FL.sum (FL.take 5 FL.length)) $ S.fromList ls
472 let v2 = Prelude.sum (Prelude.take 5 ls)
473 v3 = Prelude.length (Prelude.take 5 ls)
474 assert (v1 == (v2, v3))
475teeWithMax :: Property
476teeWithMax =
477 forAll (listOf1 (chooseInt (intMin, intMax)))
478 $ \ls0 -> monadicIO $ action ls0
480 where
482 action ls = do
483 v1 <- run $ S.fold (FL.tee FL.sum FL.maximum) $ S.fromList ls
484 let v2 = Prelude.sum ls
485 v3 = foldMaybe (greater compare) intMin ls
486 assert (v1 == (v2, v3))
488distribute :: Property
489distribute =
490 forAll (listOf1 (chooseInt (intMin, intMax)))
491 $ \ls0 -> monadicIO $ action ls0
493 where
495 action ls = do
496 v1 <- run $ S.fold (FL.distribute [FL.sum, FL.length]) $ S.fromList ls
497 let v2 = Prelude.sum ls
498 v3 = Prelude.length ls
499 assert (v1 == [v2, v3])
501partition :: Property
502partition =
503 monadicIO $ do
504 v1 :: (Int, [String]) <-
505 run
506 $ S.fold (FL.partition FL.sum FL.toList)
507 $ S.fromList
508 [Left 1, Right "abc", Left 3, Right "xy", Right "pp2"]
509 let v2 = (4,["abc","xy","pp2"])
510 assert (v1 == v2)
512unzip :: Property
513unzip =
514 monadicIO $ do
515 v1 :: (Int, [String]) <-
516 run
517 $ S.fold (FL.unzip FL.sum FL.toList)
518 $ S.fromList [(1, "aa"), (2, "bb"), (3, "cc")]
519 let v2 = (6, ["aa", "bb", "cc"])
520 assert (v1 == v2)
522many :: Property
523many =
524 forAll (listOf (chooseInt (0, 100))) $ \lst ->
525 forAll (chooseInt (1, 100)) $ \i ->
526 monadicIO $ do
527 let strm = S.fromList lst
528 r1 <- S.fold (FL.many (split i) FL.toList) strm
529 r2 <- S.toList $ Stream.foldMany (split i) strm
530 assert $ r1 == r2
532 where
534 split i = FL.take i FL.toList
536headAndRest :: [Int] -> Property
537headAndRest ls = monadicIO $ do
538 (mbh, rest) <- run $ Stream.fold_ FL.head (S.fromList ls)
539 rests <- run $ S.toList rest
540 assert (mbh == headl ls)
541 listEquals (==) rests (taill ls)
543 where
545 taill :: [a] -> [a]
546 taill [] = []
547 taill (_:xs) = xs
549demux :: Expectation
550demux =
551 let table = Data.Map.fromList [("SUM", FL.sum), ("PRODUCT", FL.product)]
552 input = Stream.fromList (
553 [ ("SUM", 1)
554 , ("PRODUCT", 2)
555 , ("SUM",3)
556 , ("PRODUCT", 4)
557 ] :: [(String, Int)])
558 in Stream.fold
559 (F.demux table)
560 input
561 `shouldReturn`
562 Data.Map.fromList [("PRODUCT", 8),("SUM", 4)]
565demuxWithSum :: Expectation
566demuxWithSum =
567 let f x = ("SUM", x::Int)
568 table = Data.Map.fromList [("SUM", FL.sum)]
569 input = Stream.fromList [1, 4]
570 in Stream.fold
571 (F.demuxWith f table)
572 input
573 `shouldReturn`
574 Data.Map.fromList [("SUM", 5)]
576demuxWithProduct :: Expectation
577demuxWithProduct =
578 let f x = ("PRODUCT", x::Int)
579 table = Data.Map.fromList [("PRODUCT", FL.product)]
580 input = Stream.fromList [2, 4]
581 in Stream.fold
582 (F.demuxWith f table)
583 input
584 `shouldReturn`
585 Data.Map.fromList [("PRODUCT", 8)]
587demuxDefaultWithSum :: Expectation
588demuxDefaultWithSum =
589 let f x = ("SUM", x::Int)
590 table = Data.Map.fromList [("SUM", FL.sum)]
591 input = Stream.fromList [2, 4]
592 in Stream.fold
593 (F.demuxDefaultWith f table (FL.lmap snd FL.sum))
594 input
595 `shouldReturn`
596 (Data.Map.fromList [("SUM" , 6)] , 0)
598demuxDefaultWithProduct :: Expectation
599demuxDefaultWithProduct =
600 let f x = ("PRODUCT", x::Int)
601 table = Data.Map.fromList [("PRODUCT", FL.product)]
602 input = Stream.fromList [2, 4]
603 in Stream.fold
604 (F.demuxDefaultWith f table (FL.lmap snd FL.product))
605 input
606 `shouldReturn`
607 (Data.Map.fromList [("PRODUCT" , 8)] , 1)
609demuxDefault :: Expectation
610demuxDefault =
611 let table = Data.Map.fromList [("SUM", FL.sum), ("PRODUCT", FL.product)]
612 input = Stream.fromList
613 [ ("SUM", 1::Int)
614 , ("PRODUCT", 2::Int)
615 , ("SUM",3)
616 , ("PRODUCT", 4::Int)
617 ]
618 in Stream.fold
619 (F.demuxDefault table (FL.lmap snd FL.product))
620 input
621 `shouldReturn`
622 (Data.Map.fromList [("PRODUCT", 8), ("SUM", 4)], 1)
624demuxDefaultEmpty :: Expectation
625demuxDefaultEmpty =
626 let table = Data.Map.empty
627 input = Stream.fromList []
628 in Stream.fold
629 (F.demuxDefault table (FL.lmap snd FL.product))
630 input
631 `shouldReturn`
632 (Data.Map.fromList ([]::[(String, Int)]), 1)
634classifyWith :: Expectation
635classifyWith =
636 let input = Stream.fromList [("ONE",1),("ONE",1.1),("TWO",2), ("TWO",2.2)]
637 in Stream.fold
638 (F.classifyWith fst (FL.lmap snd FL.toList))
639 input
640 `shouldReturn`
641 Data.Map.fromList
642 [("ONE",[1.0, 1.1 :: Double]), ("TWO",[2.0, 2.2])]
644classify :: Expectation
645classify =
646 let input =
647 Stream.fromList
648 [
649 ("ONE", (1::Int, 1))
650 , ("ONE", (1, 1.1:: Double))
651 , ("TWO", (2, 2))
652 , ("TWO",(2, 2.2))
653 ]
654 in Stream.fold
655 (F.classify (FL.lmap snd FL.toList))
656 input
657 `shouldReturn`
658 Data.Map.fromList
659 [("ONE",[1.0, 1.1 :: Double]), ("TWO",[2.0, 2.2])]
661splitAt :: Expectation
662splitAt =
663 Stream.fold
664 (F.splitAt 6 FL.toList FL.toList)
665 (Stream.fromList "Hello World!")
666 `shouldReturn`
667 ("Hello ","World!")
669moduleName :: String
670moduleName = "Data.Fold"
672main :: IO ()
673main = hspec $ do
674 describe moduleName $ do
675 -- Folds
676 -- Accumulators
677 prop "mconcat" Main.mconcat
678 prop "foldMap" Main.foldMap
679 prop "foldMapM" Main.foldMapM
681 prop "drain" Main.drain
682 prop "drainBy" Main.drainBy
683 prop "last" last
684 prop "length" Main.length
685 prop "sum" sum
686 prop "product" product
687 prop "maximumBy" $ maximumBy intMin compare
688 prop "maximum" $ maximum intMin
689 prop "minimumBy" $ minimumBy intMax compare
690 prop "minimum" $ minimum intMax
691 prop "mean" Main.mean
692 prop "stdDev" Main.stdDev
693 prop "variance" Main.variance
694 prop "rollingHashFirstN" rollingHashFirstN
696 prop "toList" toList
697 prop "toListRev" toListRev
698 prop "demux" demux
699 prop "demuxWithSum" demuxWithSum
700 prop "demuxWithProduct" demuxWithProduct
701 prop "demuxDefaultWithSum" demuxDefaultWithSum
702 prop "demuxDefaultWithProduct" demuxDefaultWithProduct
703 prop "demuxDefault" demuxDefault
704 prop "demuxDefaultEmpty" demuxDefaultEmpty
705 prop "classifyWith" classifyWith
706 prop "classify" classify
708 -- Terminating folds
709 prop "index" index
710 prop "head" head
711 prop "find" $ find predicate
712 prop "lookup" Main.lookup
713 prop "findIndex" $ findIndex predicate
714 prop "elemIndex" $ elemIndex 10
715 prop "null" null
716 prop "elem" $ elem 10
717 prop "notElem" $ notElem 10
718 prop "all" $ Main.all predicate
719 prop "any" $ Main.any predicate
720 prop "and" Main.and
721 prop "or" Main.or
723 -- Combinators
725 -- Transformation
726 -- rsequence
727 -- Functor instance
728 prop "rmapM" Main.rmapM
729 -- lmap/lmapM
731 -- Filtering
732 -- filter/filterM
733 -- catMaybes
734 prop "mapMaybe" mapMaybe
736 -- Trimming
737 prop "take" take
738 -- takeEndBy
739 prop "takeEndBy_" takeEndBy_
740 prop "takeEndByOrMax" takeEndByOrMax
742 -- Appending
743 -- serialWith
745 -- Distributing
746 -- tee
747 prop "teeWithLength" Main.teeWithLength
748 prop "teeWithFstLength" Main.teeWithFstLength
749 prop "teeWithMinLength1" Main.teeWithMinLength1
750 prop "teeWithMinLength2" Main.teeWithMinLength2
751 prop "teeWithMax" Main.teeWithMax
752 prop "partitionByM" Main.partitionByM
753 prop "partitionByFstM" Main.partitionByFstM
754 prop "partitionByMinM1" Main.partitionByMinM1
755 prop "partitionByMinM2" Main.partitionByMinM2
756 prop "distribute" Main.distribute
758 -- Partitioning
759 prop "partition" Main.partition
760 prop "partitionByM" partitionByM
762 -- Unzipping
763 prop "unzip" Main.unzip
764 prop "splitAt" Main.splitAt
766 -- Nesting
767 prop "many" Main.many
768 -- concatMap
769 -- chunksOf
771 prop "head from fold_" headAndRest