on master help sign in
Fix hlint in multiple streamly-core files
commit6f68b50d183a57698c8088f14a98895229c2de2b authorRanjeet Kumar Ranjan <ranjeetr@composewell.com> dateWed 10 Aug 2022, 12:21 (4 years ago) parent3ae32c5
8 files changed+44−63
.hlint.ignore−8 core/src/Streamly/Internal/Data/Array/Unboxed.hs+1−3 core/src/Streamly/Internal/Data/Array/Unboxed/Mut/Type.hs+8−14 core/src/Streamly/Internal/Data/Array/Unboxed/Type.hs−1 core/src/Streamly/Internal/Data/Fold.hs+2−2 core/src/Streamly/Internal/Data/IORef/Unboxed.hs+1−3 core/src/Streamly/Internal/Data/Ring/Foreign.hs+1−1 core/src/Streamly/Internal/Data/Unboxed.hs+31−31
.hlint.ignore−8
@@ -1,11 +1,3 @@
1−core/src/Streamly/Internal/Data/Fold.hs
2−core/src/Streamly/Internal/Data/Unboxed.hs
3−core/src/Streamly/Internal/Data/Array/Unboxed.hs
4−core/src/Streamly/Internal/Data/Array/Unboxed/Type.hs
5−core/src/Streamly/Internal/Data/Array/Unboxed/Mut/Type.hs
6−core/src/Streamly/Internal/Data/Ring/Foreign.hs
7−core/src/Streamly/Internal/Data/IORef/Unboxed.hs
8−core/src/Streamly/Internal/Data/Stream/Zip.hs
91core/src/Streamly/Internal/Data/Stream/StreamK/Type.hs
102core/src/Streamly/Internal/Data/Pipe/Type.hs
113src/Streamly/Internal/Data/SmallArray/Type.hs
core/src/Streamly/Internal/Data/Array/Unboxed.hs+1−3
@@ -222,9 +222,7 @@ unsafeRead = Unfold step inject
222222 --
223223 -- This should be safe as the array contents are guaranteed to be
224224 -- evaluated/written to before we peek at them.
225− let !x = unsafeInlineIO $ do
226− r <- peekWith contents p
227− return r
225+ let !x = unsafeInlineIO $ peekWith contents p
228226 let !p1 = INDEX_NEXT(p,a)
229227 return $ D.Yield x (ArrayUnsafe contents end p1)
230228
core/src/Streamly/Internal/Data/Array/Unboxed/Mut/Type.hs+8−14
@@ -359,13 +359,13 @@ data Array a =
359359
360360{-# INLINE pin #-}
361361pin :: Array a -> IO (Array a)
362−pin arr@(Array{..}) = do
362+pin arr@Array{..} = do
363363 contents <- Unboxed.pin arrContents
364364 return $ arr {arrContents = contents}
365365
366366{-# INLINE unpin #-}
367367unpin :: Array a -> IO (Array a)
368−unpin arr@(Array{..}) = do
368+unpin arr@Array{..} = do
369369 contents <- Unboxed.unpin arrContents
370370 return $ arr {arrContents = contents}
371371
@@ -491,7 +491,7 @@ withNewArrayUnsafe count f = do
491491{-# INLINE putIndexUnsafe #-}
492492putIndexUnsafe :: forall m a. (MonadIO m, Unboxed a)
493493 => Int -> a -> Array a -> m ()
494−putIndexUnsafe i x (Array {..}) = do
494+putIndexUnsafe i x Array{..} = do
495495 let index = INDEX_OF(arrStart, i, a)
496496 assert (i >= 0 && INDEX_VALID(index, aEnd, a)) (return ())
497497 liftIO $ pokeWith arrContents index x
@@ -534,7 +534,7 @@ putIndices arr = FL.foldlM' step (return ())
534534-- /Pre-release/
535535modifyIndexUnsafe :: forall m a b. (MonadIO m, Unboxed a) =>
536536 Int -> (a -> (a, b)) -> Array a -> m b
537−modifyIndexUnsafe i f (Array{..}) = liftIO $ do
537+modifyIndexUnsafe i f Array{..} = liftIO $ do
538538 let index = INDEX_OF(arrStart,i,a)
539539 assert (i >= 0 && INDEX_NEXT(index,a) <= aEnd) (return ())
540540 r <- peekWith arrContents index
@@ -982,7 +982,7 @@ snoc = snocWith f
982982-- Unsafe because it does not check the bounds of the array.
983983{-# INLINE_NORMAL getIndexUnsafe #-}
984984getIndexUnsafe :: forall m a. (MonadIO m, Unboxed a) => Int -> Array a -> m a
985−getIndexUnsafe i (Array {..}) = do
985+getIndexUnsafe i Array{..} = do
986986 let index = INDEX_OF(arrStart,i,a)
987987 assert (i >= 0 && INDEX_VALID(index,aEnd,a)) (return ())
988988 liftIO $ peekWith arrContents index
@@ -1416,9 +1416,7 @@ flattenArraysRev (D.Stream step state) = D.Stream step' (OuterLoop state)
14161416 return $ D.Skip $ OuterLoop st
14171417
14181418 step' _ (InnerLoop st contents p start) = do
1419− x <- liftIO $ do
1420− r <- peekWith contents p
1421− return r
1419+ x <- liftIO $ peekWith contents p
14221420 let cur = INDEX_PREV(p,a)
14231421 return $ D.Yield x (InnerLoop st contents cur start)
14241422
@@ -1574,9 +1572,7 @@ toStreamKWith liftio Array{..} = go arrStart
15741572
15751573 go p | assert (p <= aEnd) (p == aEnd) = K.nil
15761574 | otherwise =
1577− let elemM = do
1578− r <- peekWith arrContents p
1579− return r
1575+ let elemM = peekWith arrContents p
15801576 in liftio elemM `K.consM` go (INDEX_NEXT(p,a))
15811577
15821578{-# INLINE toStreamK #-}
@@ -1620,9 +1616,7 @@ toStreamKRevWith liftio Array {..} =
16201616
16211617 go p | p < arrStart = K.nil
16221618 | otherwise =
1623− let elemM = do
1624− r <- peekWith arrContents p
1625− return r
1619+ let elemM = peekWith arrContents p
16261620 in liftio elemM `K.consM` go (INDEX_PREV(p,a))
16271621
16281622{-# INLINE toStreamKRev #-}
core/src/Streamly/Internal/Data/Array/Unboxed/Type.hs−1
@@ -1,4 +1,3 @@
1−{-# LANGUAGE UnboxedTuples #-}
21-- |
32-- Module : Streamly.Internal.Data.Array.Unboxed.Type
43-- Copyright : (c) 2020 Composewell Technologies
core/src/Streamly/Internal/Data/Fold.hs+2−2
@@ -722,7 +722,7 @@ length = genericLength
722722--
723723{-# INLINE countDistinct #-}
724724countDistinct :: (Monad m, Ord a) => Fold m a Int
725−countDistinct = postscan nub $ catMaybes $ length
725+countDistinct = postscan nub $ catMaybes length
726726{-
727727countDistinct = fmap (\(Tuple' _ n) -> n) $ foldl' step initial
728728
@@ -747,7 +747,7 @@ countDistinct = fmap (\(Tuple' _ n) -> n) $ foldl' step initial
747747-- /Pre-release/
748748{-# INLINE countDistinctInt #-}
749749countDistinctInt :: Monad m => Fold m Int Int
750−countDistinctInt = postscan nubInt $ catMaybes $ length
750+countDistinctInt = postscan nubInt $ catMaybes length
751751{-
752752countDistinctInt = fmap (\(Tuple' _ n) -> n) $ foldl' step initial
753753
core/src/Streamly/Internal/Data/IORef/Unboxed.hs+1−3
@@ -1,5 +1,3 @@
1−{-# LANGUAGE UnboxedTuples #-}
2−
31-- |
42-- Module : Streamly.Internal.Data.IORef.Unboxed
53-- Copyright : (c) 2019 Composewell Technologies
@@ -69,7 +67,7 @@ newIORef x = do
6967-- /Pre-release/
7068{-# INLINE writeIORef #-}
7169writeIORef :: Unboxed a => IORef a -> a -> IO ()
72−writeIORef (IORef var) x = pokeWith var 0 x
70+writeIORef (IORef var) = pokeWith var 0
7371
7472-- | Read a value from an 'IORef'.
7573--
core/src/Streamly/Internal/Data/Ring/Foreign.hs+1−1
@@ -562,7 +562,7 @@ data Tuple4' a b c d = Tuple4' !a !b !c !d deriving Show
562562-- of the ring at a particular time.
563563{-# INLINE slidingWindowWith #-}
564564slidingWindowWith :: forall m a b. (MonadIO m, Storable a, Unboxed a)
565− => Int -> Fold m ((a, Maybe a), (m (Array a))) b -> Fold m a b
565+ => Int -> Fold m ((a, Maybe a), m (Array a)) b -> Fold m a b
566566slidingWindowWith n (Fold step1 initial1 extract1) = Fold step initial extract
567567
568568 where
core/src/Streamly/Internal/Data/Unboxed.hs+31−31
@@ -137,86 +137,86 @@ unpin arr@(ArrayContents marr#) =
137137{-# INLINE readWord8ArrayAsWideChar# #-}
138138readWord8ArrayAsWideChar# ::
139139 MutableByteArray# d -> Int# -> State# d -> (# State# d, Char# #)
140−readWord8ArrayAsWideChar# arr# i# s# =
141− readWideCharArray# arr# (quotInt# i# SIZEOF_HSCHAR_PRIMITIVE) s#
140+readWord8ArrayAsWideChar# arr# i# =
141+ readWideCharArray# arr# (quotInt# i# SIZEOF_HSCHAR_PRIMITIVE)
142142
143143{-# INLINE writeWord8ArrayAsWideChar# #-}
144144writeWord8ArrayAsWideChar# ::
145145 MutableByteArray# d -> Int# -> Char# -> State# d -> State# d
146−writeWord8ArrayAsWideChar# arr# i# a# s# =
147− writeWideCharArray# arr# (quotInt# i# SIZEOF_HSCHAR_PRIMITIVE) a# s#
146+writeWord8ArrayAsWideChar# arr# i# =
147+ writeWideCharArray# arr# (quotInt# i# SIZEOF_HSCHAR_PRIMITIVE)
148148
149149{-# INLINE readWord8ArrayAsInt# #-}
150150readWord8ArrayAsInt# ::
151151 MutableByteArray# d -> Int# -> State# d -> (# State# d, Int# #)
152−readWord8ArrayAsInt# arr# i# s# =
153− readIntArray# arr# (quotInt# i# SIZEOF_HSINT_PRIMITIVE) s#
152+readWord8ArrayAsInt# arr# i# =
153+ readIntArray# arr# (quotInt# i# SIZEOF_HSINT_PRIMITIVE)
154154
155155{-# INLINE writeWord8ArrayAsInt# #-}
156156writeWord8ArrayAsInt# ::
157157 MutableByteArray# d -> Int# -> Int# -> State# d -> State# d
158−writeWord8ArrayAsInt# arr# i# a# s# =
159− writeIntArray# arr# (quotInt# i# SIZEOF_HSINT_PRIMITIVE) a# s#
158+writeWord8ArrayAsInt# arr# i# =
159+ writeIntArray# arr# (quotInt# i# SIZEOF_HSINT_PRIMITIVE)
160160
161161{-# INLINE readWord8ArrayAsInt32# #-}
162162readWord8ArrayAsInt32# ::
163163 MutableByteArray# d -> Int# -> State# d -> (# State# d, Int# #)
164−readWord8ArrayAsInt32# arr# i# s# =
165− readInt32Array# arr# (quotInt# i# SIZEOF_INT32_PRIMITIVE) s#
164+readWord8ArrayAsInt32# arr# i# =
165+ readInt32Array# arr# (quotInt# i# SIZEOF_INT32_PRIMITIVE)
166166
167167{-# INLINE writeWord8ArrayAsInt32# #-}
168168writeWord8ArrayAsInt32# ::
169169 MutableByteArray# d -> Int# -> Int# -> State# d -> State# d
170−writeWord8ArrayAsInt32# arr# i# a# s# =
171− writeInt32Array# arr# (quotInt# i# SIZEOF_INT32_PRIMITIVE) a# s#
170+writeWord8ArrayAsInt32# arr# i# =
171+ writeInt32Array# arr# (quotInt# i# SIZEOF_INT32_PRIMITIVE)
172172
173173{-# INLINE readWord8ArrayAsInt64# #-}
174174readWord8ArrayAsInt64# ::
175175 MutableByteArray# d -> Int# -> State# d -> (# State# d, INT64TYP #)
176−readWord8ArrayAsInt64# arr# i# s# =
177− readInt64Array# arr# (quotInt# i# SIZEOF_INT64_PRIMITIVE) s#
176+readWord8ArrayAsInt64# arr# i# =
177+ readInt64Array# arr# (quotInt# i# SIZEOF_INT64_PRIMITIVE)
178178
179179{-# INLINE writeWord8ArrayAsInt64# #-}
180180writeWord8ArrayAsInt64# ::
181181 MutableByteArray# d -> Int# -> INT64TYP -> State# d -> State# d
182−writeWord8ArrayAsInt64# arr# i# a# s# =
183− writeInt64Array# arr# (quotInt# i# SIZEOF_INT64_PRIMITIVE) a# s#
182+writeWord8ArrayAsInt64# arr# i# =
183+ writeInt64Array# arr# (quotInt# i# SIZEOF_INT64_PRIMITIVE)
184184
185185{-# INLINE readWord8ArrayAsWord# #-}
186186readWord8ArrayAsWord# ::
187187 MutableByteArray# d -> Int# -> State# d -> (# State# d, Word# #)
188−readWord8ArrayAsWord# arr# i# s# =
189− readWordArray# arr# (quotInt# i# SIZEOF_HSWORD_PRIMITIVE) s#
188+readWord8ArrayAsWord# arr# i# =
189+ readWordArray# arr# (quotInt# i# SIZEOF_HSWORD_PRIMITIVE)
190190
191191{-# INLINE writeWord8ArrayAsWord# #-}
192192writeWord8ArrayAsWord# ::
193193 MutableByteArray# d -> Int# -> Word# -> State# d -> State# d
194−writeWord8ArrayAsWord# arr# i# a# s# =
195− writeWordArray# arr# (quotInt# i# SIZEOF_HSWORD_PRIMITIVE) a# s#
194+writeWord8ArrayAsWord# arr# i# =
195+ writeWordArray# arr# (quotInt# i# SIZEOF_HSWORD_PRIMITIVE)
196196
197197{-# INLINE readWord8ArrayAsWord64# #-}
198198readWord8ArrayAsWord64# ::
199199 MutableByteArray# d -> Int# -> State# d -> (# State# d, WORD64TYP #)
200−readWord8ArrayAsWord64# arr# i# s# =
201− readWord64Array# arr# (quotInt# i# SIZEOF_WORD64_PRIMITIVE) s#
200+readWord8ArrayAsWord64# arr# i# =
201+ readWord64Array# arr# (quotInt# i# SIZEOF_WORD64_PRIMITIVE)
202202
203203{-# INLINE writeWord8ArrayAsWord64# #-}
204204writeWord8ArrayAsWord64# ::
205205 MutableByteArray# d -> Int# -> WORD64TYP -> State# d -> State# d
206−writeWord8ArrayAsWord64# arr# i# a# s# =
207− writeWord64Array# arr# (quotInt# i# SIZEOF_WORD64_PRIMITIVE) a# s#
206+writeWord8ArrayAsWord64# arr# i# =
207+ writeWord64Array# arr# (quotInt# i# SIZEOF_WORD64_PRIMITIVE)
208208
209209{-# INLINE readWord8ArrayAsDouble# #-}
210210readWord8ArrayAsDouble# ::
211211 MutableByteArray# d -> Int# -> State# d -> (# State# d, Double# #)
212−readWord8ArrayAsDouble# arr# i# s# =
213− readDoubleArray# arr# (quotInt# i# SIZEOF_HSDOUBLE_PRIMITIVE) s#
212+readWord8ArrayAsDouble# arr# i# =
213+ readDoubleArray# arr# (quotInt# i# SIZEOF_HSDOUBLE_PRIMITIVE)
214214
215215{-# INLINE writeWord8ArrayAsDouble# #-}
216216writeWord8ArrayAsDouble# ::
217217 MutableByteArray# d -> Int# -> Double# -> State# d -> State# d
218−writeWord8ArrayAsDouble# arr# i# a# s# =
219− writeDoubleArray# arr# (quotInt# i# SIZEOF_HSDOUBLE_PRIMITIVE) a# s#
218+writeWord8ArrayAsDouble# arr# i# =
219+ writeDoubleArray# arr# (quotInt# i# SIZEOF_HSDOUBLE_PRIMITIVE)
220220
221221#endif
222222
@@ -351,9 +351,9 @@ instance Unboxed Bool where
351351
352352 {-# INLINE writeByteArray #-}
353353 writeByteArray arr i a =
354− case a of
355− True -> writeByteArray (castContents arr) i (1 :: Word8)
356− False -> writeByteArray (castContents arr) i (0 :: Word8)
354+ if a
355+ then writeByteArray (castContents arr) i (1 :: Word8)
356+ else writeByteArray (castContents arr) i (0 :: Word8)
357357
358358instance forall a. Unboxed a => Unboxed (Complex a) where
359359 {-# INLINE sizeOf #-}