@@ -1,4 +1,5 @@
11{-# LANGUAGE TemplateHaskell #-}
2+{- HLINT ignore -}
23
34#undef FUSION_CHECK
45#ifdef FUSION_CHECK
@@ -18,6 +19,7 @@ module Main (main) where
1819-------------------------------------------------------------------------------
1920
2021import Control.DeepSeq (NFData(..), deepseq)
22+import Control.Monad (when, void)
2123import GHC.Generics (Generic)
2224import System.Random (randomRIO)
2325#ifndef USE_UNBOX
@@ -264,13 +266,13 @@ $(deriveSerialize [d|instance Serialize a => Serialize (BinTree a)|])
264266instance NFData a => NFData (BinTree a) where
265267 {-# INLINE rnf #-}
266268 rnf (Leaf a) = rnf a `seq` ()
267− rnf (Tree l r) = rnf l `seq` rnf r `seq` ()
269+ rnf (Tree l r) = rnf l `seq` rnf r
268270
269271instance Arbitrary a => Arbitrary (BinTree a) where
270272 arbitrary = oneof [Leaf <$> arbitrary, Tree <$> arbitrary <*> arbitrary]
271273
272274mkBinTree :: (Arbitrary a) => Int -> IO (BinTree a)
273−mkBinTree = go (generate $ arbitrary)
275+mkBinTree = go (generate arbitrary)
274276
275277 where
276278
@@ -295,16 +297,14 @@ getSize = addSizeTo 0
295297-- Common helpers
296298-------------------------------------------------------------------------------
297299
300+{- HLINT ignore "Eta reduce" -}
298301-- Parts of "f" that are dependent on val will not be optimized out.
299302{-# INLINE loop #-}
300303loop :: Int -> (a -> IO b) -> a -> IO ()
301304loop count f val = go count val
302305 where
303306
304− go n x = do
305− if n > 0
306− then f x >> go (n-1) x
307− else return ()
307+ go n x = when (n > 0) $ f x >> go (n-1) x
308308
309309-- The first arg of "f" is the environment which is not threaded around in the
310310-- loop.
@@ -313,10 +313,7 @@ loopWith :: Int -> (e -> a -> IO b) -> e -> a -> IO ()
313313loopWith count f e val = go count val
314314 where
315315
316− go n x = do
317− if n > 0
318− then f e x >> go (n-1) x
319− else return ()
316+ go n x = when (n > 0) $ f e x >> go (n-1) x
320317
321318benchSink :: NFData b => String -> Int -> (Int -> IO b) -> Benchmark
322319benchSink name times f = bench name (nfIO (randomRIO (times, times) >>= f))
@@ -342,7 +339,7 @@ pokeTimesWithSize val times = do
342339
343340{-# INLINE poke #-}
344341poke :: SERIALIZE_CLASS a => MutByteArray -> a -> IO ()
345−poke arr val = SERIALIZE_OP 0 arr val >> return ()
342+poke arr val = void (SERIALIZE_OP 0 arr val)
346343
347344{-# INLINE pokeTimes #-}
348345pokeTimes :: SERIALIZE_CLASS a => a -> Int -> IO ()
@@ -356,7 +353,7 @@ encode :: SERIALIZE_CLASS a => a -> IO ()
356353encode val = do
357354 let n = getSize val
358355 arr <- MBA.new n
359− SERIALIZE_OP 0 arr val >> return ()
356+ void (SERIALIZE_OP 0 arr val)
360357
361358{-# INLINE encodeTimes #-}
362359encodeTimes :: SERIALIZE_CLASS a => a -> Int -> IO ()