on master help sign in
Streamly: Internal: Cleanup hlint warnings for Mutable and Network
bbfffe8Sanchayan Maity
src/Streamly/Internal/Mutable/Prim/Var.hs−2
@@ -1,9 +1,7 @@
1−{-# LANGUAGE BangPatterns #-}
2{-# LANGUAGE ConstraintKinds #-}
1{-# LANGUAGE ConstraintKinds #-}
3{-# LANGUAGE CPP #-}
2{-# LANGUAGE CPP #-}
4{-# LANGUAGE ExistentialQuantification #-}
3{-# LANGUAGE ExistentialQuantification #-}
5{-# LANGUAGE MagicHash #-}
4{-# LANGUAGE MagicHash #-}
6−{-# LANGUAGE RecordWildCards #-}
7{-# LANGUAGE UnboxedTuples #-}
5{-# LANGUAGE UnboxedTuples #-}
8{-# LANGUAGE ScopedTypeVariables #-}
6{-# LANGUAGE ScopedTypeVariables #-}
9
7
src/Streamly/Internal/Network/Inet/TCP.hs+3−8
@@ -1,9 +1,5 @@
1{-# LANGUAGE CPP #-}
1{-# LANGUAGE CPP #-}
2−{-# LANGUAGE BangPatterns #-}
3{-# LANGUAGE FlexibleContexts #-}
2{-# LANGUAGE FlexibleContexts #-}
4−{-# LANGUAGE MagicHash #-}
5−{-# LANGUAGE RecordWildCards #-}
6−{-# LANGUAGE UnboxedTuples #-}
7
3
8#include "inline.hs"
4#include "inline.hs"
9
5
@@ -359,13 +355,12 @@ writeChunks addr port = Fold step initial extract
359 where
355 where
360 initial = do
356 initial = do
361 skt <- liftIO (connect addr port)
357 skt <- liftIO (connect addr port)
362− fld <- FL.initialize (SK.writeChunks skt)
358+ fld <- FL.initialize (SK.writeChunks skt) `MC.onException` liftIO (Net.close skt)
363− `MC.onException` (liftIO $ Net.close skt)
364 return (fld, skt)
359 return (fld, skt)
365 step (fld, skt) x = do
360 step (fld, skt) x = do
366− r <- FL.runStep fld x `MC.onException` (liftIO $ Net.close skt)
361+ r <- FL.runStep fld x `MC.onException` liftIO (Net.close skt)
367 return (r, skt)
362 return (r, skt)
368− extract ((Fold _ initial1 extract1), skt) = do
363+ extract (Fold _ initial1 extract1, skt) = do
369 liftIO $ Net.close skt
364 liftIO $ Net.close skt
370 initial1 >>= extract1
365 initial1 >>= extract1
371
366
src/Streamly/Internal/Network/Socket.hs+4−11
@@ -1,9 +1,6 @@
1{-# LANGUAGE CPP #-}
1{-# LANGUAGE CPP #-}
2−{-# LANGUAGE BangPatterns #-}
3{-# LANGUAGE FlexibleContexts #-}
2{-# LANGUAGE FlexibleContexts #-}
4−{-# LANGUAGE MagicHash #-}
5{-# LANGUAGE RecordWildCards #-}
3{-# LANGUAGE RecordWildCards #-}
6−{-# LANGUAGE UnboxedTuples #-}
7
4
8#include "inline.hs"
5#include "inline.hs"
9
6
@@ -78,11 +75,10 @@ import Foreign.ForeignPtr.Unsafe (unsafeForeignPtrToPtr)
78import Foreign.Ptr (minusPtr, plusPtr, Ptr, castPtr)
75import Foreign.Ptr (minusPtr, plusPtr, Ptr, castPtr)
79import Foreign.Storable (Storable(..))
76import Foreign.Storable (Storable(..))
80import GHC.ForeignPtr (mallocPlainForeignPtrBytes)
77import GHC.ForeignPtr (mallocPlainForeignPtrBytes)
81−import Network.Socket (sendBuf, recvBuf)
82import Network.Socket
78import Network.Socket
83 (Socket, SocketOption(..), Family(..), SockAddr(..),
79 (Socket, SocketOption(..), Family(..), SockAddr(..),
84 ProtocolNumber, withSocketsDo, SocketType(..), socket, bind,
80 ProtocolNumber, withSocketsDo, SocketType(..), socket, bind,
85− setSocketOption)
81+ setSocketOption, sendBuf, recvBuf)
86#if MIN_VERSION_network(3,1,0)
82#if MIN_VERSION_network(3,1,0)
87import Network.Socket (withFdSocket)
83import Network.Socket (withFdSocket)
88#else
84#else
@@ -160,9 +156,7 @@ listenTuples :: MonadIO m
160 => Unfold m (Int, SockSpec, SockAddr) (Socket, SockAddr)
156 => Unfold m (Int, SockSpec, SockAddr) (Socket, SockAddr)
161listenTuples = Unfold step inject
157listenTuples = Unfold step inject
162 where
158 where
163− inject (listenQLen, spec, addr) = do
164− listener <- liftIO $ initListener listenQLen spec addr
159+ inject (listenQLen, spec, addr) = liftIO $ initListener listenQLen spec addr
165− return listener
166
160
167 step listener = do
161 step listener = do
168 r <- liftIO $ Net.accept listener
162 r <- liftIO $ Net.accept listener
@@ -208,8 +202,7 @@ recvConnectionTuplesWith tcpListenQ spec addr = S.unfoldrM step Nothing
208-- /Internal/
202-- /Internal/
209{-# INLINE connections #-}
203{-# INLINE connections #-}
210connections :: MonadAsync m => Int -> SockSpec -> SockAddr -> SerialT m Socket
204connections :: MonadAsync m => Int -> SockSpec -> SockAddr -> SerialT m Socket
211−connections tcpListenQ spec addr = fmap fst $
212− recvConnectionTuplesWith tcpListenQ spec addr
205+connections tcpListenQ spec addr = fst <$> recvConnectionTuplesWith tcpListenQ spec addr
213
206
214-------------------------------------------------------------------------------
207-------------------------------------------------------------------------------
215-- Array IO (Input)
208-- Array IO (Input)
@@ -416,7 +409,7 @@ read = UF.supplyFirst readWithBufferOf A.defaultChunkSize
416{-# INLINE fromChunks #-}
409{-# INLINE fromChunks #-}
417fromChunks :: (MonadIO m, Storable a)
410fromChunks :: (MonadIO m, Storable a)
418 => Socket -> SerialT m (Array a) -> m ()
411 => Socket -> SerialT m (Array a) -> m ()
419−fromChunks h m = S.mapM_ (liftIO . writeChunk h) m
412+fromChunks h = S.mapM_ (liftIO . writeChunk h)
420
413
421-- | Write a stream of arrays to a socket. Each array in the stream is written
414-- | Write a stream of arrays to a socket. Each array in the stream is written
422-- to the socket as a separate IO request.
415-- to the socket as a separate IO request.