mirror of
https://github.com/ilyakooo0/streamly.git
synced 2024-09-11 08:25:40 +03:00
Fix hlint in multiple streamly-core files
This commit is contained in:
parent
3ae32c55d9
commit
6f68b50d18
@ -1,11 +1,3 @@
|
||||
core/src/Streamly/Internal/Data/Fold.hs
|
||||
core/src/Streamly/Internal/Data/Unboxed.hs
|
||||
core/src/Streamly/Internal/Data/Array/Unboxed.hs
|
||||
core/src/Streamly/Internal/Data/Array/Unboxed/Type.hs
|
||||
core/src/Streamly/Internal/Data/Array/Unboxed/Mut/Type.hs
|
||||
core/src/Streamly/Internal/Data/Ring/Foreign.hs
|
||||
core/src/Streamly/Internal/Data/IORef/Unboxed.hs
|
||||
core/src/Streamly/Internal/Data/Stream/Zip.hs
|
||||
core/src/Streamly/Internal/Data/Stream/StreamK/Type.hs
|
||||
core/src/Streamly/Internal/Data/Pipe/Type.hs
|
||||
src/Streamly/Internal/Data/SmallArray/Type.hs
|
||||
|
@ -222,9 +222,7 @@ unsafeRead = Unfold step inject
|
||||
--
|
||||
-- This should be safe as the array contents are guaranteed to be
|
||||
-- evaluated/written to before we peek at them.
|
||||
let !x = unsafeInlineIO $ do
|
||||
r <- peekWith contents p
|
||||
return r
|
||||
let !x = unsafeInlineIO $ peekWith contents p
|
||||
let !p1 = INDEX_NEXT(p,a)
|
||||
return $ D.Yield x (ArrayUnsafe contents end p1)
|
||||
|
||||
|
@ -359,13 +359,13 @@ data Array a =
|
||||
|
||||
{-# INLINE pin #-}
|
||||
pin :: Array a -> IO (Array a)
|
||||
pin arr@(Array{..}) = do
|
||||
pin arr@Array{..} = do
|
||||
contents <- Unboxed.pin arrContents
|
||||
return $ arr {arrContents = contents}
|
||||
|
||||
{-# INLINE unpin #-}
|
||||
unpin :: Array a -> IO (Array a)
|
||||
unpin arr@(Array{..}) = do
|
||||
unpin arr@Array{..} = do
|
||||
contents <- Unboxed.unpin arrContents
|
||||
return $ arr {arrContents = contents}
|
||||
|
||||
@ -491,7 +491,7 @@ withNewArrayUnsafe count f = do
|
||||
{-# INLINE putIndexUnsafe #-}
|
||||
putIndexUnsafe :: forall m a. (MonadIO m, Unboxed a)
|
||||
=> Int -> a -> Array a -> m ()
|
||||
putIndexUnsafe i x (Array {..}) = do
|
||||
putIndexUnsafe i x Array{..} = do
|
||||
let index = INDEX_OF(arrStart, i, a)
|
||||
assert (i >= 0 && INDEX_VALID(index, aEnd, a)) (return ())
|
||||
liftIO $ pokeWith arrContents index x
|
||||
@ -534,7 +534,7 @@ putIndices arr = FL.foldlM' step (return ())
|
||||
-- /Pre-release/
|
||||
modifyIndexUnsafe :: forall m a b. (MonadIO m, Unboxed a) =>
|
||||
Int -> (a -> (a, b)) -> Array a -> m b
|
||||
modifyIndexUnsafe i f (Array{..}) = liftIO $ do
|
||||
modifyIndexUnsafe i f Array{..} = liftIO $ do
|
||||
let index = INDEX_OF(arrStart,i,a)
|
||||
assert (i >= 0 && INDEX_NEXT(index,a) <= aEnd) (return ())
|
||||
r <- peekWith arrContents index
|
||||
@ -982,7 +982,7 @@ snoc = snocWith f
|
||||
-- Unsafe because it does not check the bounds of the array.
|
||||
{-# INLINE_NORMAL getIndexUnsafe #-}
|
||||
getIndexUnsafe :: forall m a. (MonadIO m, Unboxed a) => Int -> Array a -> m a
|
||||
getIndexUnsafe i (Array {..}) = do
|
||||
getIndexUnsafe i Array{..} = do
|
||||
let index = INDEX_OF(arrStart,i,a)
|
||||
assert (i >= 0 && INDEX_VALID(index,aEnd,a)) (return ())
|
||||
liftIO $ peekWith arrContents index
|
||||
@ -1416,9 +1416,7 @@ flattenArraysRev (D.Stream step state) = D.Stream step' (OuterLoop state)
|
||||
return $ D.Skip $ OuterLoop st
|
||||
|
||||
step' _ (InnerLoop st contents p start) = do
|
||||
x <- liftIO $ do
|
||||
r <- peekWith contents p
|
||||
return r
|
||||
x <- liftIO $ peekWith contents p
|
||||
let cur = INDEX_PREV(p,a)
|
||||
return $ D.Yield x (InnerLoop st contents cur start)
|
||||
|
||||
@ -1574,9 +1572,7 @@ toStreamKWith liftio Array{..} = go arrStart
|
||||
|
||||
go p | assert (p <= aEnd) (p == aEnd) = K.nil
|
||||
| otherwise =
|
||||
let elemM = do
|
||||
r <- peekWith arrContents p
|
||||
return r
|
||||
let elemM = peekWith arrContents p
|
||||
in liftio elemM `K.consM` go (INDEX_NEXT(p,a))
|
||||
|
||||
{-# INLINE toStreamK #-}
|
||||
@ -1620,9 +1616,7 @@ toStreamKRevWith liftio Array {..} =
|
||||
|
||||
go p | p < arrStart = K.nil
|
||||
| otherwise =
|
||||
let elemM = do
|
||||
r <- peekWith arrContents p
|
||||
return r
|
||||
let elemM = peekWith arrContents p
|
||||
in liftio elemM `K.consM` go (INDEX_PREV(p,a))
|
||||
|
||||
{-# INLINE toStreamKRev #-}
|
||||
|
@ -1,4 +1,3 @@
|
||||
{-# LANGUAGE UnboxedTuples #-}
|
||||
-- |
|
||||
-- Module : Streamly.Internal.Data.Array.Unboxed.Type
|
||||
-- Copyright : (c) 2020 Composewell Technologies
|
||||
|
@ -722,7 +722,7 @@ length = genericLength
|
||||
--
|
||||
{-# INLINE countDistinct #-}
|
||||
countDistinct :: (Monad m, Ord a) => Fold m a Int
|
||||
countDistinct = postscan nub $ catMaybes $ length
|
||||
countDistinct = postscan nub $ catMaybes length
|
||||
{-
|
||||
countDistinct = fmap (\(Tuple' _ n) -> n) $ foldl' step initial
|
||||
|
||||
@ -747,7 +747,7 @@ countDistinct = fmap (\(Tuple' _ n) -> n) $ foldl' step initial
|
||||
-- /Pre-release/
|
||||
{-# INLINE countDistinctInt #-}
|
||||
countDistinctInt :: Monad m => Fold m Int Int
|
||||
countDistinctInt = postscan nubInt $ catMaybes $ length
|
||||
countDistinctInt = postscan nubInt $ catMaybes length
|
||||
{-
|
||||
countDistinctInt = fmap (\(Tuple' _ n) -> n) $ foldl' step initial
|
||||
|
||||
|
@ -1,5 +1,3 @@
|
||||
{-# LANGUAGE UnboxedTuples #-}
|
||||
|
||||
-- |
|
||||
-- Module : Streamly.Internal.Data.IORef.Unboxed
|
||||
-- Copyright : (c) 2019 Composewell Technologies
|
||||
@ -69,7 +67,7 @@ newIORef x = do
|
||||
-- /Pre-release/
|
||||
{-# INLINE writeIORef #-}
|
||||
writeIORef :: Unboxed a => IORef a -> a -> IO ()
|
||||
writeIORef (IORef var) x = pokeWith var 0 x
|
||||
writeIORef (IORef var) = pokeWith var 0
|
||||
|
||||
-- | Read a value from an 'IORef'.
|
||||
--
|
||||
|
@ -562,7 +562,7 @@ data Tuple4' a b c d = Tuple4' !a !b !c !d deriving Show
|
||||
-- of the ring at a particular time.
|
||||
{-# INLINE slidingWindowWith #-}
|
||||
slidingWindowWith :: forall m a b. (MonadIO m, Storable a, Unboxed a)
|
||||
=> Int -> Fold m ((a, Maybe a), (m (Array a))) b -> Fold m a b
|
||||
=> Int -> Fold m ((a, Maybe a), m (Array a)) b -> Fold m a b
|
||||
slidingWindowWith n (Fold step1 initial1 extract1) = Fold step initial extract
|
||||
|
||||
where
|
||||
|
@ -137,86 +137,86 @@ unpin arr@(ArrayContents marr#) =
|
||||
{-# INLINE readWord8ArrayAsWideChar# #-}
|
||||
readWord8ArrayAsWideChar# ::
|
||||
MutableByteArray# d -> Int# -> State# d -> (# State# d, Char# #)
|
||||
readWord8ArrayAsWideChar# arr# i# s# =
|
||||
readWideCharArray# arr# (quotInt# i# SIZEOF_HSCHAR_PRIMITIVE) s#
|
||||
readWord8ArrayAsWideChar# arr# i# =
|
||||
readWideCharArray# arr# (quotInt# i# SIZEOF_HSCHAR_PRIMITIVE)
|
||||
|
||||
{-# INLINE writeWord8ArrayAsWideChar# #-}
|
||||
writeWord8ArrayAsWideChar# ::
|
||||
MutableByteArray# d -> Int# -> Char# -> State# d -> State# d
|
||||
writeWord8ArrayAsWideChar# arr# i# a# s# =
|
||||
writeWideCharArray# arr# (quotInt# i# SIZEOF_HSCHAR_PRIMITIVE) a# s#
|
||||
writeWord8ArrayAsWideChar# arr# i# =
|
||||
writeWideCharArray# arr# (quotInt# i# SIZEOF_HSCHAR_PRIMITIVE)
|
||||
|
||||
{-# INLINE readWord8ArrayAsInt# #-}
|
||||
readWord8ArrayAsInt# ::
|
||||
MutableByteArray# d -> Int# -> State# d -> (# State# d, Int# #)
|
||||
readWord8ArrayAsInt# arr# i# s# =
|
||||
readIntArray# arr# (quotInt# i# SIZEOF_HSINT_PRIMITIVE) s#
|
||||
readWord8ArrayAsInt# arr# i# =
|
||||
readIntArray# arr# (quotInt# i# SIZEOF_HSINT_PRIMITIVE)
|
||||
|
||||
{-# INLINE writeWord8ArrayAsInt# #-}
|
||||
writeWord8ArrayAsInt# ::
|
||||
MutableByteArray# d -> Int# -> Int# -> State# d -> State# d
|
||||
writeWord8ArrayAsInt# arr# i# a# s# =
|
||||
writeIntArray# arr# (quotInt# i# SIZEOF_HSINT_PRIMITIVE) a# s#
|
||||
writeWord8ArrayAsInt# arr# i# =
|
||||
writeIntArray# arr# (quotInt# i# SIZEOF_HSINT_PRIMITIVE)
|
||||
|
||||
{-# INLINE readWord8ArrayAsInt32# #-}
|
||||
readWord8ArrayAsInt32# ::
|
||||
MutableByteArray# d -> Int# -> State# d -> (# State# d, Int# #)
|
||||
readWord8ArrayAsInt32# arr# i# s# =
|
||||
readInt32Array# arr# (quotInt# i# SIZEOF_INT32_PRIMITIVE) s#
|
||||
readWord8ArrayAsInt32# arr# i# =
|
||||
readInt32Array# arr# (quotInt# i# SIZEOF_INT32_PRIMITIVE)
|
||||
|
||||
{-# INLINE writeWord8ArrayAsInt32# #-}
|
||||
writeWord8ArrayAsInt32# ::
|
||||
MutableByteArray# d -> Int# -> Int# -> State# d -> State# d
|
||||
writeWord8ArrayAsInt32# arr# i# a# s# =
|
||||
writeInt32Array# arr# (quotInt# i# SIZEOF_INT32_PRIMITIVE) a# s#
|
||||
writeWord8ArrayAsInt32# arr# i# =
|
||||
writeInt32Array# arr# (quotInt# i# SIZEOF_INT32_PRIMITIVE)
|
||||
|
||||
{-# INLINE readWord8ArrayAsInt64# #-}
|
||||
readWord8ArrayAsInt64# ::
|
||||
MutableByteArray# d -> Int# -> State# d -> (# State# d, INT64TYP #)
|
||||
readWord8ArrayAsInt64# arr# i# s# =
|
||||
readInt64Array# arr# (quotInt# i# SIZEOF_INT64_PRIMITIVE) s#
|
||||
readWord8ArrayAsInt64# arr# i# =
|
||||
readInt64Array# arr# (quotInt# i# SIZEOF_INT64_PRIMITIVE)
|
||||
|
||||
{-# INLINE writeWord8ArrayAsInt64# #-}
|
||||
writeWord8ArrayAsInt64# ::
|
||||
MutableByteArray# d -> Int# -> INT64TYP -> State# d -> State# d
|
||||
writeWord8ArrayAsInt64# arr# i# a# s# =
|
||||
writeInt64Array# arr# (quotInt# i# SIZEOF_INT64_PRIMITIVE) a# s#
|
||||
writeWord8ArrayAsInt64# arr# i# =
|
||||
writeInt64Array# arr# (quotInt# i# SIZEOF_INT64_PRIMITIVE)
|
||||
|
||||
{-# INLINE readWord8ArrayAsWord# #-}
|
||||
readWord8ArrayAsWord# ::
|
||||
MutableByteArray# d -> Int# -> State# d -> (# State# d, Word# #)
|
||||
readWord8ArrayAsWord# arr# i# s# =
|
||||
readWordArray# arr# (quotInt# i# SIZEOF_HSWORD_PRIMITIVE) s#
|
||||
readWord8ArrayAsWord# arr# i# =
|
||||
readWordArray# arr# (quotInt# i# SIZEOF_HSWORD_PRIMITIVE)
|
||||
|
||||
{-# INLINE writeWord8ArrayAsWord# #-}
|
||||
writeWord8ArrayAsWord# ::
|
||||
MutableByteArray# d -> Int# -> Word# -> State# d -> State# d
|
||||
writeWord8ArrayAsWord# arr# i# a# s# =
|
||||
writeWordArray# arr# (quotInt# i# SIZEOF_HSWORD_PRIMITIVE) a# s#
|
||||
writeWord8ArrayAsWord# arr# i# =
|
||||
writeWordArray# arr# (quotInt# i# SIZEOF_HSWORD_PRIMITIVE)
|
||||
|
||||
{-# INLINE readWord8ArrayAsWord64# #-}
|
||||
readWord8ArrayAsWord64# ::
|
||||
MutableByteArray# d -> Int# -> State# d -> (# State# d, WORD64TYP #)
|
||||
readWord8ArrayAsWord64# arr# i# s# =
|
||||
readWord64Array# arr# (quotInt# i# SIZEOF_WORD64_PRIMITIVE) s#
|
||||
readWord8ArrayAsWord64# arr# i# =
|
||||
readWord64Array# arr# (quotInt# i# SIZEOF_WORD64_PRIMITIVE)
|
||||
|
||||
{-# INLINE writeWord8ArrayAsWord64# #-}
|
||||
writeWord8ArrayAsWord64# ::
|
||||
MutableByteArray# d -> Int# -> WORD64TYP -> State# d -> State# d
|
||||
writeWord8ArrayAsWord64# arr# i# a# s# =
|
||||
writeWord64Array# arr# (quotInt# i# SIZEOF_WORD64_PRIMITIVE) a# s#
|
||||
writeWord8ArrayAsWord64# arr# i# =
|
||||
writeWord64Array# arr# (quotInt# i# SIZEOF_WORD64_PRIMITIVE)
|
||||
|
||||
{-# INLINE readWord8ArrayAsDouble# #-}
|
||||
readWord8ArrayAsDouble# ::
|
||||
MutableByteArray# d -> Int# -> State# d -> (# State# d, Double# #)
|
||||
readWord8ArrayAsDouble# arr# i# s# =
|
||||
readDoubleArray# arr# (quotInt# i# SIZEOF_HSDOUBLE_PRIMITIVE) s#
|
||||
readWord8ArrayAsDouble# arr# i# =
|
||||
readDoubleArray# arr# (quotInt# i# SIZEOF_HSDOUBLE_PRIMITIVE)
|
||||
|
||||
{-# INLINE writeWord8ArrayAsDouble# #-}
|
||||
writeWord8ArrayAsDouble# ::
|
||||
MutableByteArray# d -> Int# -> Double# -> State# d -> State# d
|
||||
writeWord8ArrayAsDouble# arr# i# a# s# =
|
||||
writeDoubleArray# arr# (quotInt# i# SIZEOF_HSDOUBLE_PRIMITIVE) a# s#
|
||||
writeWord8ArrayAsDouble# arr# i# =
|
||||
writeDoubleArray# arr# (quotInt# i# SIZEOF_HSDOUBLE_PRIMITIVE)
|
||||
|
||||
#endif
|
||||
|
||||
@ -351,9 +351,9 @@ instance Unboxed Bool where
|
||||
|
||||
{-# INLINE writeByteArray #-}
|
||||
writeByteArray arr i a =
|
||||
case a of
|
||||
True -> writeByteArray (castContents arr) i (1 :: Word8)
|
||||
False -> writeByteArray (castContents arr) i (0 :: Word8)
|
||||
if a
|
||||
then writeByteArray (castContents arr) i (1 :: Word8)
|
||||
else writeByteArray (castContents arr) i (0 :: Word8)
|
||||
|
||||
instance forall a. Unboxed a => Unboxed (Complex a) where
|
||||
{-# INLINE sizeOf #-}
|
||||
|
Loading…
Reference in New Issue
Block a user