on master help sign in
Fix hlint in multiple streamly-core files
6f68b50Ranjeet Kumar Ranjan
.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
9core/src/Streamly/Internal/Data/Stream/StreamK/Type.hs
1core/src/Streamly/Internal/Data/Stream/StreamK/Type.hs
10core/src/Streamly/Internal/Data/Pipe/Type.hs
2core/src/Streamly/Internal/Data/Pipe/Type.hs
11src/Streamly/Internal/Data/SmallArray/Type.hs
3src/Streamly/Internal/Data/SmallArray/Type.hs
core/src/Streamly/Internal/Data/Array/Unboxed.hs+1−3
@@ -222,9 +222,7 @@ unsafeRead = Unfold step inject
222 --
222 --
223 -- This should be safe as the array contents are guaranteed to be
223 -- This should be safe as the array contents are guaranteed to be
224 -- evaluated/written to before we peek at them.
224 -- evaluated/written to before we peek at them.
225− let !x = unsafeInlineIO $ do
225+ let !x = unsafeInlineIO $ peekWith contents p
226− r <- peekWith contents p
227− return r
228 let !p1 = INDEX_NEXT(p,a)
226 let !p1 = INDEX_NEXT(p,a)
229 return $ D.Yield x (ArrayUnsafe contents end p1)
227 return $ D.Yield x (ArrayUnsafe contents end p1)
230
228
core/src/Streamly/Internal/Data/Array/Unboxed/Mut/Type.hs+8−14
@@ -359,13 +359,13 @@ data Array a =
359
359
360{-# INLINE pin #-}
360{-# INLINE pin #-}
361pin :: Array a -> IO (Array a)
361pin :: Array a -> IO (Array a)
362−pin arr@(Array{..}) = do
362+pin arr@Array{..} = do
363 contents <- Unboxed.pin arrContents
363 contents <- Unboxed.pin arrContents
364 return $ arr {arrContents = contents}
364 return $ arr {arrContents = contents}
365
365
366{-# INLINE unpin #-}
366{-# INLINE unpin #-}
367unpin :: Array a -> IO (Array a)
367unpin :: Array a -> IO (Array a)
368−unpin arr@(Array{..}) = do
368+unpin arr@Array{..} = do
369 contents <- Unboxed.unpin arrContents
369 contents <- Unboxed.unpin arrContents
370 return $ arr {arrContents = contents}
370 return $ arr {arrContents = contents}
371
371
@@ -491,7 +491,7 @@ withNewArrayUnsafe count f = do
491{-# INLINE putIndexUnsafe #-}
491{-# INLINE putIndexUnsafe #-}
492putIndexUnsafe :: forall m a. (MonadIO m, Unboxed a)
492putIndexUnsafe :: forall m a. (MonadIO m, Unboxed a)
493 => Int -> a -> Array a -> m ()
493 => Int -> a -> Array a -> m ()
494−putIndexUnsafe i x (Array {..}) = do
494+putIndexUnsafe i x Array{..} = do
495 let index = INDEX_OF(arrStart, i, a)
495 let index = INDEX_OF(arrStart, i, a)
496 assert (i >= 0 && INDEX_VALID(index, aEnd, a)) (return ())
496 assert (i >= 0 && INDEX_VALID(index, aEnd, a)) (return ())
497 liftIO $ pokeWith arrContents index x
497 liftIO $ pokeWith arrContents index x
@@ -534,7 +534,7 @@ putIndices arr = FL.foldlM' step (return ())
534-- /Pre-release/
534-- /Pre-release/
535modifyIndexUnsafe :: forall m a b. (MonadIO m, Unboxed a) =>
535modifyIndexUnsafe :: forall m a b. (MonadIO m, Unboxed a) =>
536 Int -> (a -> (a, b)) -> Array a -> m b
536 Int -> (a -> (a, b)) -> Array a -> m b
537−modifyIndexUnsafe i f (Array{..}) = liftIO $ do
537+modifyIndexUnsafe i f Array{..} = liftIO $ do
538 let index = INDEX_OF(arrStart,i,a)
538 let index = INDEX_OF(arrStart,i,a)
539 assert (i >= 0 && INDEX_NEXT(index,a) <= aEnd) (return ())
539 assert (i >= 0 && INDEX_NEXT(index,a) <= aEnd) (return ())
540 r <- peekWith arrContents index
540 r <- peekWith arrContents index
@@ -982,7 +982,7 @@ snoc = snocWith f
982-- Unsafe because it does not check the bounds of the array.
982-- Unsafe because it does not check the bounds of the array.
983{-# INLINE_NORMAL getIndexUnsafe #-}
983{-# INLINE_NORMAL getIndexUnsafe #-}
984getIndexUnsafe :: forall m a. (MonadIO m, Unboxed a) => Int -> Array a -> m a
984getIndexUnsafe :: forall m a. (MonadIO m, Unboxed a) => Int -> Array a -> m a
985−getIndexUnsafe i (Array {..}) = do
985+getIndexUnsafe i Array{..} = do
986 let index = INDEX_OF(arrStart,i,a)
986 let index = INDEX_OF(arrStart,i,a)
987 assert (i >= 0 && INDEX_VALID(index,aEnd,a)) (return ())
987 assert (i >= 0 && INDEX_VALID(index,aEnd,a)) (return ())
988 liftIO $ peekWith arrContents index
988 liftIO $ peekWith arrContents index
@@ -1416,9 +1416,7 @@ flattenArraysRev (D.Stream step state) = D.Stream step' (OuterLoop state)
1416 return $ D.Skip $ OuterLoop st
1416 return $ D.Skip $ OuterLoop st
1417
1417
1418 step' _ (InnerLoop st contents p start) = do
1418 step' _ (InnerLoop st contents p start) = do
1419− x <- liftIO $ do
1420− r <- peekWith contents p
1419+ x <- liftIO $ peekWith contents p
1421− return r
1422 let cur = INDEX_PREV(p,a)
1420 let cur = INDEX_PREV(p,a)
1423 return $ D.Yield x (InnerLoop st contents cur start)
1421 return $ D.Yield x (InnerLoop st contents cur start)
1424
1422
@@ -1574,9 +1572,7 @@ toStreamKWith liftio Array{..} = go arrStart
1574
1572
1575 go p | assert (p <= aEnd) (p == aEnd) = K.nil
1573 go p | assert (p <= aEnd) (p == aEnd) = K.nil
1576 | otherwise =
1574 | otherwise =
1577− let elemM = do
1578− r <- peekWith arrContents p
1575+ let elemM = peekWith arrContents p
1579− return r
1580 in liftio elemM `K.consM` go (INDEX_NEXT(p,a))
1576 in liftio elemM `K.consM` go (INDEX_NEXT(p,a))
1581
1577
1582{-# INLINE toStreamK #-}
1578{-# INLINE toStreamK #-}
@@ -1620,9 +1616,7 @@ toStreamKRevWith liftio Array {..} =
1620
1616
1621 go p | p < arrStart = K.nil
1617 go p | p < arrStart = K.nil
1622 | otherwise =
1618 | otherwise =
1623− let elemM = do
1624− r <- peekWith arrContents p
1619+ let elemM = peekWith arrContents p
1625− return r
1626 in liftio elemM `K.consM` go (INDEX_PREV(p,a))
1620 in liftio elemM `K.consM` go (INDEX_PREV(p,a))
1627
1621
1628{-# INLINE toStreamKRev #-}
1622{-# INLINE toStreamKRev #-}
core/src/Streamly/Internal/Data/Array/Unboxed/Type.hs−1
@@ -1,4 +1,3 @@
1−{-# LANGUAGE UnboxedTuples #-}
2-- |
1-- |
3-- Module : Streamly.Internal.Data.Array.Unboxed.Type
2-- Module : Streamly.Internal.Data.Array.Unboxed.Type
4-- Copyright : (c) 2020 Composewell Technologies
3-- Copyright : (c) 2020 Composewell Technologies
core/src/Streamly/Internal/Data/Fold.hs+2−2
@@ -722,7 +722,7 @@ length = genericLength
722--
722--
723{-# INLINE countDistinct #-}
723{-# INLINE countDistinct #-}
724countDistinct :: (Monad m, Ord a) => Fold m a Int
724countDistinct :: (Monad m, Ord a) => Fold m a Int
725−countDistinct = postscan nub $ catMaybes $ length
725+countDistinct = postscan nub $ catMaybes length
726{-
726{-
727countDistinct = fmap (\(Tuple' _ n) -> n) $ foldl' step initial
727countDistinct = fmap (\(Tuple' _ n) -> n) $ foldl' step initial
728
728
@@ -747,7 +747,7 @@ countDistinct = fmap (\(Tuple' _ n) -> n) $ foldl' step initial
747-- /Pre-release/
747-- /Pre-release/
748{-# INLINE countDistinctInt #-}
748{-# INLINE countDistinctInt #-}
749countDistinctInt :: Monad m => Fold m Int Int
749countDistinctInt :: Monad m => Fold m Int Int
750−countDistinctInt = postscan nubInt $ catMaybes $ length
750+countDistinctInt = postscan nubInt $ catMaybes length
751{-
751{-
752countDistinctInt = fmap (\(Tuple' _ n) -> n) $ foldl' step initial
752countDistinctInt = fmap (\(Tuple' _ n) -> n) $ foldl' step initial
753
753
core/src/Streamly/Internal/Data/IORef/Unboxed.hs+1−3
@@ -1,5 +1,3 @@
1−{-# LANGUAGE UnboxedTuples #-}
2−
3-- |
1-- |
4-- Module : Streamly.Internal.Data.IORef.Unboxed
2-- Module : Streamly.Internal.Data.IORef.Unboxed
5-- Copyright : (c) 2019 Composewell Technologies
3-- Copyright : (c) 2019 Composewell Technologies
@@ -69,7 +67,7 @@ newIORef x = do
69-- /Pre-release/
67-- /Pre-release/
70{-# INLINE writeIORef #-}
68{-# INLINE writeIORef #-}
71writeIORef :: Unboxed a => IORef a -> a -> IO ()
69writeIORef :: Unboxed a => IORef a -> a -> IO ()
72−writeIORef (IORef var) x = pokeWith var 0 x
70+writeIORef (IORef var) = pokeWith var 0
73
71
74-- | Read a value from an 'IORef'.
72-- | Read a value from an 'IORef'.
75--
73--
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
562-- of the ring at a particular time.
562-- of the ring at a particular time.
563{-# INLINE slidingWindowWith #-}
563{-# INLINE slidingWindowWith #-}
564slidingWindowWith :: forall m a b. (MonadIO m, Storable a, Unboxed a)
564slidingWindowWith :: 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
566slidingWindowWith n (Fold step1 initial1 extract1) = Fold step initial extract
566slidingWindowWith n (Fold step1 initial1 extract1) = Fold step initial extract
567
567
568 where
568 where
core/src/Streamly/Internal/Data/Unboxed.hs+31−31
@@ -137,86 +137,86 @@ unpin arr@(ArrayContents marr#) =
137{-# INLINE readWord8ArrayAsWideChar# #-}
137{-# INLINE readWord8ArrayAsWideChar# #-}
138readWord8ArrayAsWideChar# ::
138readWord8ArrayAsWideChar# ::
139 MutableByteArray# d -> Int# -> State# d -> (# State# d, Char# #)
139 MutableByteArray# d -> Int# -> State# d -> (# State# d, Char# #)
140−readWord8ArrayAsWideChar# arr# i# s# =
140+readWord8ArrayAsWideChar# arr# i# =
141− readWideCharArray# arr# (quotInt# i# SIZEOF_HSCHAR_PRIMITIVE) s#
141+ readWideCharArray# arr# (quotInt# i# SIZEOF_HSCHAR_PRIMITIVE)
142
142
143{-# INLINE writeWord8ArrayAsWideChar# #-}
143{-# INLINE writeWord8ArrayAsWideChar# #-}
144writeWord8ArrayAsWideChar# ::
144writeWord8ArrayAsWideChar# ::
145 MutableByteArray# d -> Int# -> Char# -> State# d -> State# d
145 MutableByteArray# d -> Int# -> Char# -> State# d -> State# d
146−writeWord8ArrayAsWideChar# arr# i# a# s# =
146+writeWord8ArrayAsWideChar# arr# i# =
147− writeWideCharArray# arr# (quotInt# i# SIZEOF_HSCHAR_PRIMITIVE) a# s#
147+ writeWideCharArray# arr# (quotInt# i# SIZEOF_HSCHAR_PRIMITIVE)
148
148
149{-# INLINE readWord8ArrayAsInt# #-}
149{-# INLINE readWord8ArrayAsInt# #-}
150readWord8ArrayAsInt# ::
150readWord8ArrayAsInt# ::
151 MutableByteArray# d -> Int# -> State# d -> (# State# d, Int# #)
151 MutableByteArray# d -> Int# -> State# d -> (# State# d, Int# #)
152−readWord8ArrayAsInt# arr# i# s# =
152+readWord8ArrayAsInt# arr# i# =
153− readIntArray# arr# (quotInt# i# SIZEOF_HSINT_PRIMITIVE) s#
153+ readIntArray# arr# (quotInt# i# SIZEOF_HSINT_PRIMITIVE)
154
154
155{-# INLINE writeWord8ArrayAsInt# #-}
155{-# INLINE writeWord8ArrayAsInt# #-}
156writeWord8ArrayAsInt# ::
156writeWord8ArrayAsInt# ::
157 MutableByteArray# d -> Int# -> Int# -> State# d -> State# d
157 MutableByteArray# d -> Int# -> Int# -> State# d -> State# d
158−writeWord8ArrayAsInt# arr# i# a# s# =
158+writeWord8ArrayAsInt# arr# i# =
159− writeIntArray# arr# (quotInt# i# SIZEOF_HSINT_PRIMITIVE) a# s#
159+ writeIntArray# arr# (quotInt# i# SIZEOF_HSINT_PRIMITIVE)
160
160
161{-# INLINE readWord8ArrayAsInt32# #-}
161{-# INLINE readWord8ArrayAsInt32# #-}
162readWord8ArrayAsInt32# ::
162readWord8ArrayAsInt32# ::
163 MutableByteArray# d -> Int# -> State# d -> (# State# d, Int# #)
163 MutableByteArray# d -> Int# -> State# d -> (# State# d, Int# #)
164−readWord8ArrayAsInt32# arr# i# s# =
164+readWord8ArrayAsInt32# arr# i# =
165− readInt32Array# arr# (quotInt# i# SIZEOF_INT32_PRIMITIVE) s#
165+ readInt32Array# arr# (quotInt# i# SIZEOF_INT32_PRIMITIVE)
166
166
167{-# INLINE writeWord8ArrayAsInt32# #-}
167{-# INLINE writeWord8ArrayAsInt32# #-}
168writeWord8ArrayAsInt32# ::
168writeWord8ArrayAsInt32# ::
169 MutableByteArray# d -> Int# -> Int# -> State# d -> State# d
169 MutableByteArray# d -> Int# -> Int# -> State# d -> State# d
170−writeWord8ArrayAsInt32# arr# i# a# s# =
170+writeWord8ArrayAsInt32# arr# i# =
171− writeInt32Array# arr# (quotInt# i# SIZEOF_INT32_PRIMITIVE) a# s#
171+ writeInt32Array# arr# (quotInt# i# SIZEOF_INT32_PRIMITIVE)
172
172
173{-# INLINE readWord8ArrayAsInt64# #-}
173{-# INLINE readWord8ArrayAsInt64# #-}
174readWord8ArrayAsInt64# ::
174readWord8ArrayAsInt64# ::
175 MutableByteArray# d -> Int# -> State# d -> (# State# d, INT64TYP #)
175 MutableByteArray# d -> Int# -> State# d -> (# State# d, INT64TYP #)
176−readWord8ArrayAsInt64# arr# i# s# =
176+readWord8ArrayAsInt64# arr# i# =
177− readInt64Array# arr# (quotInt# i# SIZEOF_INT64_PRIMITIVE) s#
177+ readInt64Array# arr# (quotInt# i# SIZEOF_INT64_PRIMITIVE)
178
178
179{-# INLINE writeWord8ArrayAsInt64# #-}
179{-# INLINE writeWord8ArrayAsInt64# #-}
180writeWord8ArrayAsInt64# ::
180writeWord8ArrayAsInt64# ::
181 MutableByteArray# d -> Int# -> INT64TYP -> State# d -> State# d
181 MutableByteArray# d -> Int# -> INT64TYP -> State# d -> State# d
182−writeWord8ArrayAsInt64# arr# i# a# s# =
182+writeWord8ArrayAsInt64# arr# i# =
183− writeInt64Array# arr# (quotInt# i# SIZEOF_INT64_PRIMITIVE) a# s#
183+ writeInt64Array# arr# (quotInt# i# SIZEOF_INT64_PRIMITIVE)
184
184
185{-# INLINE readWord8ArrayAsWord# #-}
185{-# INLINE readWord8ArrayAsWord# #-}
186readWord8ArrayAsWord# ::
186readWord8ArrayAsWord# ::
187 MutableByteArray# d -> Int# -> State# d -> (# State# d, Word# #)
187 MutableByteArray# d -> Int# -> State# d -> (# State# d, Word# #)
188−readWord8ArrayAsWord# arr# i# s# =
188+readWord8ArrayAsWord# arr# i# =
189− readWordArray# arr# (quotInt# i# SIZEOF_HSWORD_PRIMITIVE) s#
189+ readWordArray# arr# (quotInt# i# SIZEOF_HSWORD_PRIMITIVE)
190
190
191{-# INLINE writeWord8ArrayAsWord# #-}
191{-# INLINE writeWord8ArrayAsWord# #-}
192writeWord8ArrayAsWord# ::
192writeWord8ArrayAsWord# ::
193 MutableByteArray# d -> Int# -> Word# -> State# d -> State# d
193 MutableByteArray# d -> Int# -> Word# -> State# d -> State# d
194−writeWord8ArrayAsWord# arr# i# a# s# =
194+writeWord8ArrayAsWord# arr# i# =
195− writeWordArray# arr# (quotInt# i# SIZEOF_HSWORD_PRIMITIVE) a# s#
195+ writeWordArray# arr# (quotInt# i# SIZEOF_HSWORD_PRIMITIVE)
196
196
197{-# INLINE readWord8ArrayAsWord64# #-}
197{-# INLINE readWord8ArrayAsWord64# #-}
198readWord8ArrayAsWord64# ::
198readWord8ArrayAsWord64# ::
199 MutableByteArray# d -> Int# -> State# d -> (# State# d, WORD64TYP #)
199 MutableByteArray# d -> Int# -> State# d -> (# State# d, WORD64TYP #)
200−readWord8ArrayAsWord64# arr# i# s# =
200+readWord8ArrayAsWord64# arr# i# =
201− readWord64Array# arr# (quotInt# i# SIZEOF_WORD64_PRIMITIVE) s#
201+ readWord64Array# arr# (quotInt# i# SIZEOF_WORD64_PRIMITIVE)
202
202
203{-# INLINE writeWord8ArrayAsWord64# #-}
203{-# INLINE writeWord8ArrayAsWord64# #-}
204writeWord8ArrayAsWord64# ::
204writeWord8ArrayAsWord64# ::
205 MutableByteArray# d -> Int# -> WORD64TYP -> State# d -> State# d
205 MutableByteArray# d -> Int# -> WORD64TYP -> State# d -> State# d
206−writeWord8ArrayAsWord64# arr# i# a# s# =
206+writeWord8ArrayAsWord64# arr# i# =
207− writeWord64Array# arr# (quotInt# i# SIZEOF_WORD64_PRIMITIVE) a# s#
207+ writeWord64Array# arr# (quotInt# i# SIZEOF_WORD64_PRIMITIVE)
208
208
209{-# INLINE readWord8ArrayAsDouble# #-}
209{-# INLINE readWord8ArrayAsDouble# #-}
210readWord8ArrayAsDouble# ::
210readWord8ArrayAsDouble# ::
211 MutableByteArray# d -> Int# -> State# d -> (# State# d, Double# #)
211 MutableByteArray# d -> Int# -> State# d -> (# State# d, Double# #)
212−readWord8ArrayAsDouble# arr# i# s# =
212+readWord8ArrayAsDouble# arr# i# =
213− readDoubleArray# arr# (quotInt# i# SIZEOF_HSDOUBLE_PRIMITIVE) s#
213+ readDoubleArray# arr# (quotInt# i# SIZEOF_HSDOUBLE_PRIMITIVE)
214
214
215{-# INLINE writeWord8ArrayAsDouble# #-}
215{-# INLINE writeWord8ArrayAsDouble# #-}
216writeWord8ArrayAsDouble# ::
216writeWord8ArrayAsDouble# ::
217 MutableByteArray# d -> Int# -> Double# -> State# d -> State# d
217 MutableByteArray# d -> Int# -> Double# -> State# d -> State# d
218−writeWord8ArrayAsDouble# arr# i# a# s# =
218+writeWord8ArrayAsDouble# arr# i# =
219− writeDoubleArray# arr# (quotInt# i# SIZEOF_HSDOUBLE_PRIMITIVE) a# s#
219+ writeDoubleArray# arr# (quotInt# i# SIZEOF_HSDOUBLE_PRIMITIVE)
220
220
221#endif
221#endif
222
222
@@ -351,9 +351,9 @@ instance Unboxed Bool where
351
351
352 {-# INLINE writeByteArray #-}
352 {-# INLINE writeByteArray #-}
353 writeByteArray arr i a =
353 writeByteArray arr i a =
354− case a of
354+ if a
355− True -> writeByteArray (castContents arr) i (1 :: Word8)
355+ then writeByteArray (castContents arr) i (1 :: Word8)
356− False -> writeByteArray (castContents arr) i (0 :: Word8)
356+ else writeByteArray (castContents arr) i (0 :: Word8)
357
357
358instance forall a. Unboxed a => Unboxed (Complex a) where
358instance forall a. Unboxed a => Unboxed (Complex a) where
359 {-# INLINE sizeOf #-}
359 {-# INLINE sizeOf #-}