Skip to content

Commit

Permalink
Streamly: Internal: Cleanup hlint warnings for Mutable and Network
Browse files Browse the repository at this point in the history
Signed-off-by: Sanchayan Maity <maitysanchayan@gmail.com>
  • Loading branch information
SanchayanMaity committed Feb 16, 2020
1 parent b1b0ae0 commit bbfffe8
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 21 deletions.
2 changes: 0 additions & 2 deletions src/Streamly/Internal/Mutable/Prim/Var.hs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE CPP #-}
{-# LANGUAGE ExistentialQuantification #-}
{-# LANGUAGE MagicHash #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE UnboxedTuples #-}
{-# LANGUAGE ScopedTypeVariables #-}

Expand Down
11 changes: 3 additions & 8 deletions src/Streamly/Internal/Network/Inet/TCP.hs
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE MagicHash #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE UnboxedTuples #-}

#include "inline.hs"

Expand Down Expand Up @@ -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

Expand Down
15 changes: 4 additions & 11 deletions src/Streamly/Internal/Network/Socket.hs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE MagicHash #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE UnboxedTuples #-}

#include "inline.hs"

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit bbfffe8

Please sign in to comment.