on master help sign in
Fix hlint issues in tests
commitce86302f083eda655a47347373551071b2d87c5a authorHarendra Kumar <harendra@composewell.com> dateMon 18 Dec 2023, 22:51 (3 years ago) parent86ad39a
5 files changed+13−11
.hlint.ignore+1 test/Streamly/Test/Data/Fold.hs+7−6 test/Streamly/Test/Data/Serialize/TH.hs+2−2 test/Streamly/Test/FileSystem/Handle.hs+2−2 test/Streamly/Test/Unicode/Char.hs+1−1
.hlint.ignore+1
@@ -13,6 +13,7 @@ test/Streamly/Test/Data/Unfold.hs
1313test/Streamly/Test/FileSystem/Event.hs
1414test/Streamly/Test/Prelude/Concurrent.hs
1515test/Streamly/Test/Data/Stream/Concurrent.hs
16+test/lib/Streamly/Test/Prelude/Common.hs
1617test/Streamly/Test/Prelude/Fold.hs
1718test/Streamly/Test/Prelude/Rate.hs
1819test/Streamly/Test/Prelude/Serial.hs
test/Streamly/Test/Data/Fold.hs+7−6
@@ -2,7 +2,8 @@
22
33module Main (main) where
44
5−import Data.List (sort)
5+import Data.List (sort, sortBy)
6+import Data.Ord (comparing, Down(..))
67import Data.Semigroup (Sum(..), getSum)
78import Streamly.Test.Common (checkListEqual, listEquals)
89import Test.QuickCheck
@@ -412,7 +413,7 @@ partitionByM =
412413 where
413414
414415 action ls = do
415− let f = \x -> if odd x then return (Left x) else return (Right x)
416+ let f x = if odd x then return (Left x) else return (Right x)
416417 v1 <-
417418 run
418419 $ Stream.fold (Fold.partitionByM f Fold.length Fold.length)
@@ -429,7 +430,7 @@ partitionByFstM =
429430 where
430431
431432 action _ = do
432− let f = \x -> if odd x then return (Left x) else return (Right x)
433+ let f x = if odd x then return (Left x) else return (Right x)
433434 v1 <-
434435 run
435436 $ Stream.fold
@@ -447,7 +448,7 @@ partitionByMinM1 =
447448 where
448449
449450 action _ = do
450− let f = \x -> if odd x then return (Left x) else return (Right x)
451+ let f x = if odd x then return (Left x) else return (Right x)
451452 v1 <-
452453 run
453454 $ Stream.fold
@@ -465,7 +466,7 @@ partitionByMinM2 =
465466 where
466467
467468 action _ = do
468− let f = \x -> if odd x then return (Left x) else return (Right x)
469+ let f x = if odd x then return (Left x) else return (Right x)
469470 v1 <-
470471 run
471472 $ Stream.fold
@@ -690,7 +691,7 @@ topBy isTop = forAll (listOf (chooseInt (-50, 100))) $ \ls0 ->
690691 if isTop
691692 then do
692693 lst <- Stream.fold (Fold.top n) (Stream.fromList ls) >>= MArray.toList
693− assert ((Prelude.take n . Prelude.reverse . sort) ls == lst)
694+ assert ((Prelude.take n . sortBy (comparing Down)) ls == lst)
694695 else do
695696 lst <- Stream.fold (Fold.bottom n) (Stream.fromList ls) >>= MArray.toList
696697 assert ((Prelude.take n . sort) ls == lst)
test/Streamly/Test/Data/Serialize/TH.hs+2−2
@@ -26,7 +26,7 @@ import Test.QuickCheck.Gen (oneof)
2626genDatatype :: String -> Int -> Q [Dec]
2727genDatatype tyName numCons =
2828 sequence
29− ([ dataD
29+ [ dataD
3030 (pure [])
3131 (mkName tyName)
3232 []
@@ -49,7 +49,7 @@ genDatatype tyName numCons =
4949 []
5050 ]
5151 ]
52− ])
52+ ]
5353
5454 where
5555
test/Streamly/Test/FileSystem/Handle.hs+2−2
@@ -75,7 +75,7 @@ readFromHandle =
7575
7676readWithBufferFromHandle :: IO (Stream IO Char)
7777readWithBufferFromHandle =
78− let f1 = (\h -> (1024, h))
78+ let f1 h = (1024, h)
7979 f2 = Unicode.decodeUtf8 . Stream.unfold Handle.readerWith . f1
8080 in executor f2
8181
@@ -88,7 +88,7 @@ readChunksFromHandle =
8888
8989readChunksWithBuffer :: IO (Stream IO Char)
9090readChunksWithBuffer =
91− let f1 = (\h -> (1024, h))
91+ let f1 h = (1024, h)
9292 f2 =
9393 Unicode.decodeUtf8
9494 . Stream.concatMap Array.read
test/Streamly/Test/Unicode/Char.hs+1−1
@@ -54,7 +54,7 @@ checkEqual opName op (mc1, mc2) = do
5454checkOp :: String -> NormalizationMode -> [(Text, Text)] -> IO Bool
5555checkOp name op pairs = do
5656 res <- mapM (checkEqual name (normalize op)) pairs
57− return $ all (== True) res
57+ return $ and res
5858
5959checkNFC :: (Text, Text, Text, Text, Text) -> IO Bool
6060checkNFC (c1, c2, c3, c4, c5) =