@@ -1,4 +1,5 @@
1{-# LANGUAGE TemplateHaskell #-}
1{-# LANGUAGE TemplateHaskell #-}
3#undef FUSION_CHECK
4#undef FUSION_CHECK
4#ifdef FUSION_CHECK
5#ifdef FUSION_CHECK
@@ -18,6 +19,7 @@ module Main (main) where
18-------------------------------------------------------------------------------
19-------------------------------------------------------------------------------
20import Control.DeepSeq (NFData(..), deepseq)
21import Control.DeepSeq (NFData(..), deepseq)
22+import Control.Monad (when, void)
21import GHC.Generics (Generic)
23import GHC.Generics (Generic)
22import System.Random (randomRIO)
24import System.Random (randomRIO)
23#ifndef USE_UNBOX
25#ifndef USE_UNBOX
@@ -264,13 +266,13 @@ $(deriveSerialize [d|instance Serialize a => Serialize (BinTree a)|])
264instance NFData a => NFData (BinTree a) where
266instance NFData a => NFData (BinTree a) where
265 {-# INLINE rnf #-}
267 {-# INLINE rnf #-}
266 rnf (Leaf a) = rnf a `seq` ()
268 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
269instance Arbitrary a => Arbitrary (BinTree a) where
271instance Arbitrary a => Arbitrary (BinTree a) where
270 arbitrary = oneof [Leaf <$> arbitrary, Tree <$> arbitrary <*> arbitrary]
272 arbitrary = oneof [Leaf <$> arbitrary, Tree <$> arbitrary <*> arbitrary]
272mkBinTree :: (Arbitrary a) => Int -> IO (BinTree a)
274mkBinTree :: (Arbitrary a) => Int -> IO (BinTree a)
273−mkBinTree = go (generate $ arbitrary)
275+mkBinTree = go (generate arbitrary)
@@ -295,16 +297,14 @@ getSize = addSizeTo 0
295-- Common helpers
297-- Common helpers
296-------------------------------------------------------------------------------
298-------------------------------------------------------------------------------
300+{- HLINT ignore "Eta reduce" -}
298-- Parts of "f" that are dependent on val will not be optimized out.
301-- Parts of "f" that are dependent on val will not be optimized out.
299{-# INLINE loop #-}
302{-# INLINE loop #-}
300loop :: Int -> (a -> IO b) -> a -> IO ()
303loop :: Int -> (a -> IO b) -> a -> IO ()
301loop count f val = go count val
304loop count f val = go count val
306− then f x >> go (n-1) x
307+ go n x = when (n > 0) $ f x >> go (n-1) x
309-- The first arg of "f" is the environment which is not threaded around in the
309-- The first arg of "f" is the environment which is not threaded around in the
@@ -313,10 +313,7 @@ loopWith :: Int -> (e -> a -> IO b) -> e -> a -> IO ()
313loopWith count f e val = go count val
313loopWith count f e val = go count val
318− then f e x >> go (n-1) x
316+ go n x = when (n > 0) $ f e x >> go (n-1) x
321benchSink :: NFData b => String -> Int -> (Int -> IO b) -> Benchmark
318benchSink :: NFData b => String -> Int -> (Int -> IO b) -> Benchmark
322benchSink name times f = bench name (nfIO (randomRIO (times, times) >>= f))
319benchSink name times f = bench name (nfIO (randomRIO (times, times) >>= f))
@@ -342,7 +339,7 @@ pokeTimesWithSize val times = do
343{-# INLINE poke #-}
340{-# INLINE poke #-}
344poke :: SERIALIZE_CLASS a => MutByteArray -> a -> IO ()
341poke :: 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)
347{-# INLINE pokeTimes #-}
344{-# INLINE pokeTimes #-}
348pokeTimes :: SERIALIZE_CLASS a => a -> Int -> IO ()
345pokeTimes :: SERIALIZE_CLASS a => a -> Int -> IO ()
@@ -356,7 +353,7 @@ encode :: SERIALIZE_CLASS a => a -> IO ()
356encode val = do
353encode val = do
357 let n = getSize val
354 let n = getSize val
358 arr <- MBA.new n
355 arr <- MBA.new n
359− SERIALIZE_OP 0 arr val >> return ()
356+ void (SERIALIZE_OP 0 arr val)
361{-# INLINE encodeTimes #-}
358{-# INLINE encodeTimes #-}
362encodeTimes :: SERIALIZE_CLASS a => a -> Int -> IO ()
359encodeTimes :: SERIALIZE_CLASS a => a -> Int -> IO ()