From bbfffe8e797a96802eb65f540b8465ad7bdd0502 Mon Sep 17 00:00:00 2001 From: Sanchayan Maity Date: Sun, 16 Feb 2020 18:23:05 +0530 Subject: [PATCH] Streamly: Internal: Cleanup hlint warnings for Mutable and Network Signed-off-by: Sanchayan Maity --- src/Streamly/Internal/Mutable/Prim/Var.hs | 2 -- src/Streamly/Internal/Network/Inet/TCP.hs | 11 +++-------- src/Streamly/Internal/Network/Socket.hs | 15 ++++----------- 3 files changed, 7 insertions(+), 21 deletions(-) diff --git a/src/Streamly/Internal/Mutable/Prim/Var.hs b/src/Streamly/Internal/Mutable/Prim/Var.hs index dd438ef025..4eef14cc3d 100644 --- a/src/Streamly/Internal/Mutable/Prim/Var.hs +++ b/src/Streamly/Internal/Mutable/Prim/Var.hs @@ -1,9 +1,7 @@ -{-# LANGUAGE BangPatterns #-} {-# LANGUAGE ConstraintKinds #-} {-# LANGUAGE CPP #-} {-# LANGUAGE ExistentialQuantification #-} {-# LANGUAGE MagicHash #-} -{-# LANGUAGE RecordWildCards #-} {-# LANGUAGE UnboxedTuples #-} {-# LANGUAGE ScopedTypeVariables #-} diff --git a/src/Streamly/Internal/Network/Inet/TCP.hs b/src/Streamly/Internal/Network/Inet/TCP.hs index d0ec60e7ae..d0888d031f 100644 --- a/src/Streamly/Internal/Network/Inet/TCP.hs +++ b/src/Streamly/Internal/Network/Inet/TCP.hs @@ -1,9 +1,5 @@ {-# LANGUAGE CPP #-} -{-# LANGUAGE BangPatterns #-} {-# LANGUAGE FlexibleContexts #-} -{-# LANGUAGE MagicHash #-} -{-# LANGUAGE RecordWildCards #-} -{-# LANGUAGE UnboxedTuples #-} #include "inline.hs" @@ -359,13 +355,12 @@ writeChunks addr port = Fold step initial extract where initial = do skt <- liftIO (connect addr port) - fld <- FL.initialize (SK.writeChunks skt) - `MC.onException` (liftIO $ Net.close skt) + fld <- FL.initialize (SK.writeChunks skt) `MC.onException` liftIO (Net.close skt) return (fld, skt) step (fld, skt) x = do - r <- FL.runStep fld x `MC.onException` (liftIO $ Net.close skt) + r <- FL.runStep fld x `MC.onException` liftIO (Net.close skt) return (r, skt) - extract ((Fold _ initial1 extract1), skt) = do + extract (Fold _ initial1 extract1, skt) = do liftIO $ Net.close skt initial1 >>= extract1 diff --git a/src/Streamly/Internal/Network/Socket.hs b/src/Streamly/Internal/Network/Socket.hs index e88deea5bb..5008424e37 100644 --- a/src/Streamly/Internal/Network/Socket.hs +++ b/src/Streamly/Internal/Network/Socket.hs @@ -1,9 +1,6 @@ {-# LANGUAGE CPP #-} -{-# LANGUAGE BangPatterns #-} {-# LANGUAGE FlexibleContexts #-} -{-# LANGUAGE MagicHash #-} {-# LANGUAGE RecordWildCards #-} -{-# LANGUAGE UnboxedTuples #-} #include "inline.hs" @@ -78,11 +75,10 @@ import Foreign.ForeignPtr.Unsafe (unsafeForeignPtrToPtr) import Foreign.Ptr (minusPtr, plusPtr, Ptr, castPtr) import Foreign.Storable (Storable(..)) import GHC.ForeignPtr (mallocPlainForeignPtrBytes) -import Network.Socket (sendBuf, recvBuf) import Network.Socket (Socket, SocketOption(..), Family(..), SockAddr(..), ProtocolNumber, withSocketsDo, SocketType(..), socket, bind, - setSocketOption) + setSocketOption, sendBuf, recvBuf) #if MIN_VERSION_network(3,1,0) import Network.Socket (withFdSocket) #else @@ -160,9 +156,7 @@ listenTuples :: MonadIO m => Unfold m (Int, SockSpec, SockAddr) (Socket, SockAddr) listenTuples = Unfold step inject where - inject (listenQLen, spec, addr) = do - listener <- liftIO $ initListener listenQLen spec addr - return listener + inject (listenQLen, spec, addr) = liftIO $ initListener listenQLen spec addr step listener = do r <- liftIO $ Net.accept listener @@ -208,8 +202,7 @@ recvConnectionTuplesWith tcpListenQ spec addr = S.unfoldrM step Nothing -- /Internal/ {-# INLINE connections #-} connections :: MonadAsync m => Int -> SockSpec -> SockAddr -> SerialT m Socket -connections tcpListenQ spec addr = fmap fst $ - recvConnectionTuplesWith tcpListenQ spec addr +connections tcpListenQ spec addr = fst <$> recvConnectionTuplesWith tcpListenQ spec addr ------------------------------------------------------------------------------- -- Array IO (Input) @@ -416,7 +409,7 @@ read = UF.supplyFirst readWithBufferOf A.defaultChunkSize {-# INLINE fromChunks #-} fromChunks :: (MonadIO m, Storable a) => Socket -> SerialT m (Array a) -> m () -fromChunks h m = S.mapM_ (liftIO . writeChunk h) m +fromChunks h = S.mapM_ (liftIO . writeChunk h) -- | Write a stream of arrays to a socket. Each array in the stream is written -- to the socket as a separate IO request.