on master help sign in
Streamly: Internal: Data: Clean up hlint warnings

Signed-off-by: Sanchayan Maity <maitysanchayan@gmail.com>

commitb5cf9dd9a7f74142fded6c81334105bf91339d4d authorSanchayan Maity <maitysanchayan@gmail.com> dateThu 4 Jun 2020, 19:54 (6 years ago) parent96f01fd
10 files changed+36−51
.hlint.ignore−6 src/Streamly/Internal/Data/Fold.hs+2−2 src/Streamly/Internal/Data/Pipe.hs−2 src/Streamly/Internal/Data/Pipe/Types.hs+13−13 src/Streamly/Internal/Data/Prim/Array.hs+3−5 src/Streamly/Internal/Data/SVar.hs+6−9 src/Streamly/Internal/Data/Sink/Types.hs+1−1 src/Streamly/Internal/Data/SmallArray.hs+2−2 src/Streamly/Internal/Data/SmallArray/Types.hs+3−3 src/Streamly/Internal/Data/Time/Units.hs+6−8
.hlint.ignore−6
@@ -1,6 +1,5 @@
11src/Streamly/Internal/BaseCompat.hs
22src/Streamly/Internal/Control/Monad.hs
3−src/Streamly/Internal/Data/SVar.hs
43src/Streamly/Internal/Data/Stream/SVar.hs
54src/Streamly/Internal/Data/Stream/Serial.hs
65src/Streamly/Internal/Data/Stream/Zip.hs
@@ -14,16 +13,11 @@ src/Streamly/Internal/Data/Stream/Ahead.hs
1413src/Streamly/Internal/Data/Stream/StreamD/Type.hs
1514src/Streamly/Internal/Data/Stream/StreamDK/Type.hs
1615src/Streamly/Internal/Data/Stream/StreamD.hs
17−src/Streamly/Internal/Data/SmallArray.hs
1816src/Streamly/Internal/Data/Pipe/Types.hs
19−src/Streamly/Internal/Data/Pipe.hs
20−src/Streamly/Internal/Data/Sink/Types.hs
2117src/Streamly/Internal/Data/Sink.hs
2218src/Streamly/Internal/Data/Zipper/Array.hs
2319src/Streamly/Internal/Data/Parser/ParserD/Types.hs
2420src/Streamly/Internal/Data/Parser/ParserD.hs
25−src/Streamly/Internal/Data/Time/Units.hs
26−src/Streamly/Internal/Data/Prim/Array.hs
2721src/Streamly/Internal/Data/Prim/Array/Types.hs
2822src/Streamly/Internal/Data/SmallArray/Types.hs
2923src/Streamly/Internal/Data/Unfold.hs
src/Streamly/Internal/Data/Fold.hs+2−2
@@ -1182,8 +1182,8 @@ distribute_ fs = Fold step initial extract
11821182 step ss a = do
11831183 Prelude.mapM_ (\(Fold s i _) -> i >>= \r -> void (s r a)) ss
11841184 return ss
1185− extract ss =
1186− Prelude.mapM_ (\(Fold _ i e) -> i >>= \r -> e r) ss
1185+ extract =
1186+ Prelude.mapM_ (\(Fold _ i e) -> i >>= \r -> e r)
11871187
11881188------------------------------------------------------------------------------
11891189-- Partitioning
src/Streamly/Internal/Data/Pipe.hs−2
@@ -1,9 +1,7 @@
1−{-# LANGUAGE BangPatterns #-}
21{-# LANGUAGE CPP #-}
32{-# LANGUAGE ExistentialQuantification #-}
43{-# LANGUAGE FlexibleContexts #-}
54{-# LANGUAGE RankNTypes #-}
6−{-# LANGUAGE RecordWildCards #-}
75{-# LANGUAGE ScopedTypeVariables #-}
86
97-- |
src/Streamly/Internal/Data/Pipe/Types.hs+13−13
@@ -158,18 +158,18 @@ zipWith f (Pipe consumeL produceL stateL) (Pipe consumeR produceR stateR) =
158158 where
159159
160160 {-# INLINE drive #-}
161− drive st res queue fConsume fProduce val = do
161+ drive st res queue fConsume fProduce val =
162162 case res of
163163 Nothing -> goConsume st queue val fConsume fProduce
164164 Just x -> return $
165165 case queue of
166− Nothing -> (st, Just x, Just $ (Deque [val] []))
166+ Nothing -> (st, Just x, Just $ Deque [val] [])
167167 Just q -> (st, Just x, Just $ snoc val q)
168168
169169 {-# INLINE goConsume #-}
170− goConsume stt queue val fConsume stp2 = do
170+ goConsume stt queue val fConsume stp2 =
171171 case stt of
172− Consume st -> do
172+ Consume st ->
173173 case queue of
174174 Nothing -> do
175175 r <- fConsume st val
@@ -200,15 +200,15 @@ zipWith f (Pipe consumeL produceL stateL) (Pipe consumeR produceR stateR) =
200200 where
201201
202202 {-# INLINE drive #-}
203− drive stt res q fConsume fProduce = do
203+ drive stt res q fConsume fProduce =
204204 case res of
205205 Nothing -> goProduce stt q fConsume fProduce
206206 Just x -> return (stt, Just x, q)
207207
208208 {-# INLINE goProduce #-}
209− goProduce stt queue fConsume fProduce = do
209+ goProduce stt queue fConsume fProduce =
210210 case stt of
211− Consume st -> do
211+ Consume st ->
212212 case queue of
213213 -- See yieldOutput. We enter produce mode only when
214214 -- each pipe is either in Produce state or the
@@ -269,7 +269,7 @@ tee (Pipe consumeL produceL stateL) (Pipe consumeR produceR stateR) =
269269
270270 state = Tuple' (Consume stateL) (Consume stateR)
271271
272− consume (Tuple' sL sR) a = do
272+ consume (Tuple' sL sR) a =
273273 case sL of
274274 Consume st -> do
275275 r <- consumeL st a
@@ -286,9 +286,9 @@ tee (Pipe consumeL produceL stateL) (Pipe consumeR produceR stateR) =
286286 Continue s -> Continue (Right (Tuple3' (Just a) s sR))
287287 -}
288288
289− produce (Tuple3' (Just a) sL sR) = do
289+ produce (Tuple3' (Just a) sL sR) =
290290 case sL of
291− Consume _ -> do
291+ Consume _ ->
292292 case sR of
293293 Consume st -> do
294294 r <- consumeR st a
@@ -309,7 +309,7 @@ tee (Pipe consumeL produceL stateL) (Pipe consumeR produceR stateR) =
309309 Yield x s -> Yield x (next s)
310310 Continue s -> Continue (next s)
311311
312− produce (Tuple3' Nothing sL sR) = do
312+ produce (Tuple3' Nothing sL sR) =
313313 case sR of
314314 Consume _ -> undefined -- should never occur
315315 Produce st -> do
@@ -359,7 +359,7 @@ compose (Pipe consumeL produceL stateL) (Pipe consumeR produceR stateR) =
359359
360360 state = Tuple' (Consume stateL) (Consume stateR)
361361
362− consume (Tuple' sL sR) a = do
362+ consume (Tuple' sL sR) a =
363363 case sL of
364364 Consume stt ->
365365 case sR of
@@ -392,7 +392,7 @@ compose (Pipe consumeL produceL stateL) (Pipe consumeR produceR stateR) =
392392
393393 -- XXX we need to write the code in mor optimized fashion. Use Continue
394394 -- more and less yield points.
395− produce (Tuple' sL sR) = do
395+ produce (Tuple' sL sR) =
396396 case sL of
397397 Produce st -> do
398398 r <- produceL st
src/Streamly/Internal/Data/Prim/Array.hs+3−5
@@ -1,8 +1,6 @@
11{-# OPTIONS_GHC -fno-warn-orphans #-}
22
33{-# LANGUAGE CPP #-}
4−{-# LANGUAGE MagicHash #-}
5−{-# LANGUAGE UnboxedTuples #-}
64
75#include "inline.hs"
86
@@ -80,7 +78,7 @@ toStreamD arr = D.Stream step 0
8078
8179{-# INLINE length #-}
8280length :: Prim a => PrimArray a -> Int
83−length arr = sizeofPrimArray arr
81+length = sizeofPrimArray
8482
8583{-# INLINE_NORMAL toStreamDRev #-}
8684toStreamDRev :: (Prim a, Monad m) => PrimArray a -> D.Stream m a
@@ -139,14 +137,14 @@ fromStreamDN limit str = do
139137 marr <- liftIO $ newPrimArray (max limit 0)
140138 _ <-
141139 D.foldlM'
142− (\i x -> i `seq` (liftIO $ writePrimArray marr i x) >> return (i + 1))
140+ (\i x -> i `seq` liftIO (writePrimArray marr i x) >> return (i + 1))
143141 0 $
144142 D.take limit str
145143 liftIO $ unsafeFreezePrimArray marr
146144
147145{-# INLINE fromStreamD #-}
148146fromStreamD :: (MonadIO m, Prim a) => D.Stream m a -> m (PrimArray a)
149−fromStreamD str = D.runFold write str
147+fromStreamD = D.runFold write
150148
151149{-# INLINABLE fromListN #-}
152150fromListN :: Prim a => Int -> [a] -> PrimArray a
src/Streamly/Internal/Data/SVar.hs+6−9
@@ -143,7 +143,7 @@ import Data.Kind (Type)
143143#endif
144144import Data.IORef
145145 (IORef, modifyIORef, newIORef, readIORef, writeIORef, atomicModifyIORef)
146−import Data.Maybe (fromJust)
146+import Data.Maybe (fromJust, fromMaybe)
147147#if __GLASGOW_HASKELL__ < 808
148148import Data.Semigroup ((<>))
149149#endif
@@ -704,7 +704,7 @@ collectWorkerPendingLatency cur col = do
704704 assert (latCount == 0 || latTime /= 0) (return ())
705705 let latPair =
706706 if latCount > 0 && latTime > 0
707− then Just $ (latCount, latTime)
707+ then Just (latCount, latTime)
708708 else Nothing
709709 return (totalCount, latPair)
710710
@@ -748,7 +748,7 @@ collectLatency sv yinfo drain = do
748748 case newLatPair of
749749 Nothing -> retWith prevLat
750750 Just (count, time) -> do
751− let newLat = time `div` (fromIntegral count)
751+ let newLat = time `div` fromIntegral count
752752 when (svarInspectMode sv) $ recordMinMaxLatency sv newLat
753753 -- When we have collected a significant sized batch we compute the
754754 -- new latency using that batch and return the new latency,
@@ -1102,7 +1102,7 @@ sendWithDoorBell q bell msg = do
11021102-- | This function is used by the producer threads to queue output for the
11031103-- consumer thread to consume. Returns whether the queue has more space.
11041104send :: SVar t m a -> ChildEvent a -> IO Int
1105−send sv msg = sendWithDoorBell (outputQueue sv) (outputDoorBell sv) msg
1105+send sv = sendWithDoorBell (outputQueue sv) (outputDoorBell sv)
11061106
11071107-- There is no bound implemented on the buffer, this is assumed to be low
11081108-- traffic.
@@ -1856,10 +1856,7 @@ dispatchWorkerPaced sv = do
18561856 let elapsed = fromRelTime64 $ diffAbsTime64 now baseTime
18571857 let latency =
18581858 if lat == 0
1859− then
1860− case workerBootstrapLatency yinfo of
1861− Nothing -> lat
1862− Just t -> t
1859+ then fromMaybe lat (workerBootstrapLatency yinfo)
18631860 else lat
18641861
18651862 return (yieldCount, elapsed, latency)
@@ -2349,7 +2346,7 @@ getParallelSVar ss st mrun = do
23492346 let bufLim =
23502347 case getMaxBuffer st of
23512348 Unlimited -> undefined
2352− Limited x -> (fromIntegral x)
2349+ Limited x -> fromIntegral x
23532350 remBuf <- newIORef bufLim
23542351 pbMVar <- newMVar ()
23552352
src/Streamly/Internal/Data/Sink/Types.hs+1−1
@@ -21,4 +21,4 @@ where
2121-- bit more efficient than a 'Fold' with '()' as the state, especially when
2222-- 'Sink's are composed with other operations. A Sink can be upgraded to a
2323-- 'Fold', but a 'Fold' cannot be converted into a Sink.
24−data Sink m a = Sink (a -> m ())
24+newtype Sink m a = Sink (a -> m ())
src/Streamly/Internal/Data/SmallArray.hs+2−2
@@ -65,7 +65,7 @@ bottomElement = undefined
6565
6666{-# INLINE length #-}
6767length :: SmallArray a -> Int
68−length arr = sizeofSmallArray arr
68+length = sizeofSmallArray
6969
7070{-# INLINE_NORMAL toStreamD #-}
7171toStreamD :: Monad m => SmallArray a -> D.Stream m a
@@ -124,7 +124,7 @@ fromStreamDN limit str = do
124124 marr <- liftIO $ newSmallArray (max limit 0) bottomElement
125125 i <-
126126 D.foldlM'
127− (\i x -> i `seq` (liftIO $ writeSmallArray marr i x) >> return (i + 1))
127+ (\i x -> i `seq` liftIO (writeSmallArray marr i x) >> return (i + 1))
128128 0 $
129129 D.take limit str
130130 liftIO $ freezeSmallArray marr 0 i
src/Streamly/Internal/Data/SmallArray/Types.hs+3−3
@@ -300,7 +300,7 @@ traverseSmallArrayP
300300 => (a -> m b)
301301 -> SmallArray a
302302 -> m (SmallArray b)
303−traverseSmallArrayP f = \ !ary ->
303+traverseSmallArrayP f !ary =
304304 let
305305 !sz = sizeofSmallArray ary
306306 go !i !mary
@@ -442,7 +442,7 @@ instance Ord1 SmallArray where
442442
443443-- | Lexicographic ordering. Subject to change between major versions.
444444instance Ord a => Ord (SmallArray a) where
445− compare sa1 sa2 = smallArrayLiftCompare compare sa1 sa2
445+ compare = smallArrayLiftCompare compare
446446
447447instance Foldable SmallArray where
448448 -- Note: we perform the array lookups eagerly so we won't
@@ -757,7 +757,7 @@ listLiftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> [a] -> Show
757757listLiftShowsPrec _ sl _ = sl
758758
759759instance Show a => Show (SmallArray a) where
760− showsPrec p sa = smallArrayLiftShowsPrec showsPrec showList p sa
760+ showsPrec = smallArrayLiftShowsPrec showsPrec showList
761761
762762#if MIN_VERSION_base(4,9,0) || MIN_VERSION_transformers(0,4,0)
763763-- | @since 0.6.4.0
src/Streamly/Internal/Data/Time/Units.hs+6−8
@@ -168,7 +168,7 @@ instance Ord TimeSpec where
168168addWithOverflow :: TimeSpec -> TimeSpec -> TimeSpec
169169addWithOverflow (TimeSpec s1 ns1) (TimeSpec s2 ns2) =
170170 let nsum = ns1 + ns2
171− (s', ns) = if (nsum > tenPower9 || nsum < negate tenPower9)
171+ (s', ns) = if nsum > tenPower9 || nsum < negate tenPower9
172172 then nsum `divMod` tenPower9
173173 else (0, nsum)
174174 in TimeSpec (s1 + s2 + s') ns
@@ -176,12 +176,10 @@ addWithOverflow (TimeSpec s1 ns1) (TimeSpec s2 ns2) =
176176-- make sure both sec and nsec have the same sign
177177{-# INLINE adjustSign #-}
178178adjustSign :: TimeSpec -> TimeSpec
179−adjustSign (t@(TimeSpec s ns)) =
180− if (s > 0 && ns < 0)
181− then TimeSpec (s - 1) (ns + tenPower9)
182− else if (s < 0 && ns > 0)
183− then TimeSpec (s + 1) (ns - tenPower9)
184− else t
179+adjustSign t@(TimeSpec s ns)
180+ | s > 0 && ns < 0 = TimeSpec (s - 1) (ns + tenPower9)
181+ | s < 0 && ns > 0 = TimeSpec (s + 1) (ns - tenPower9)
182+ | otherwise = t
185183
186184{-# INLINE timeSpecToInteger #-}
187185timeSpecToInteger :: TimeSpec -> Integer
@@ -193,7 +191,7 @@ instance Num TimeSpec where
193191
194192 -- XXX will this be more optimal if imlemented without "negate"?
195193 {-# INLINE (-) #-}
196− t1 - t2 = t1 + (negate t2)
194+ t1 - t2 = t1 + negate t2
197195 t1 * t2 = fromInteger $ timeSpecToInteger t1 * timeSpecToInteger t2
198196
199197 {-# INLINE negate #-}