on master help sign in
Streamly: Internal: Cleanup hlint warnings for Mutable and Network

Signed-off-by: Sanchayan Maity <maitysanchayan@gmail.com>

commitbbfffe8e797a96802eb65f540b8465ad7bdd0502 authorSanchayan Maity <maitysanchayan@gmail.com> dateSun 16 Feb 2020, 18:23 (7 years ago) parentb1b0ae0
3 files changed+7−21
src/Streamly/Internal/Mutable/Prim/Var.hs−2 src/Streamly/Internal/Network/Inet/TCP.hs+3−8 src/Streamly/Internal/Network/Socket.hs+4−11
src/Streamly/Internal/Mutable/Prim/Var.hs−2
@@ -1,9 +1,7 @@
1−{-# LANGUAGE BangPatterns #-}
21{-# LANGUAGE ConstraintKinds #-}
32{-# LANGUAGE CPP #-}
43{-# LANGUAGE ExistentialQuantification #-}
54{-# LANGUAGE MagicHash #-}
6−{-# LANGUAGE RecordWildCards #-}
75{-# LANGUAGE UnboxedTuples #-}
86{-# LANGUAGE ScopedTypeVariables #-}
97
src/Streamly/Internal/Network/Inet/TCP.hs+3−8
@@ -1,9 +1,5 @@
11{-# LANGUAGE CPP #-}
2−{-# LANGUAGE BangPatterns #-}
32{-# LANGUAGE FlexibleContexts #-}
4−{-# LANGUAGE MagicHash #-}
5−{-# LANGUAGE RecordWildCards #-}
6−{-# LANGUAGE UnboxedTuples #-}
73
84#include "inline.hs"
95
@@ -359,13 +355,12 @@ writeChunks addr port = Fold step initial extract
359355 where
360356 initial = do
361357 skt <- liftIO (connect addr port)
362− fld <- FL.initialize (SK.writeChunks skt)
363− `MC.onException` (liftIO $ Net.close skt)
358+ fld <- FL.initialize (SK.writeChunks skt) `MC.onException` liftIO (Net.close skt)
364359 return (fld, skt)
365360 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)
367362 return (r, skt)
368− extract ((Fold _ initial1 extract1), skt) = do
363+ extract (Fold _ initial1 extract1, skt) = do
369364 liftIO $ Net.close skt
370365 initial1 >>= extract1
371366
src/Streamly/Internal/Network/Socket.hs+4−11
@@ -1,9 +1,6 @@
11{-# LANGUAGE CPP #-}
2−{-# LANGUAGE BangPatterns #-}
32{-# LANGUAGE FlexibleContexts #-}
4−{-# LANGUAGE MagicHash #-}
53{-# LANGUAGE RecordWildCards #-}
6−{-# LANGUAGE UnboxedTuples #-}
74
85#include "inline.hs"
96
@@ -78,11 +75,10 @@ import Foreign.ForeignPtr.Unsafe (unsafeForeignPtrToPtr)
7875import Foreign.Ptr (minusPtr, plusPtr, Ptr, castPtr)
7976import Foreign.Storable (Storable(..))
8077import GHC.ForeignPtr (mallocPlainForeignPtrBytes)
81−import Network.Socket (sendBuf, recvBuf)
8278import Network.Socket
8379 (Socket, SocketOption(..), Family(..), SockAddr(..),
8480 ProtocolNumber, withSocketsDo, SocketType(..), socket, bind,
85− setSocketOption)
81+ setSocketOption, sendBuf, recvBuf)
8682#if MIN_VERSION_network(3,1,0)
8783import Network.Socket (withFdSocket)
8884#else
@@ -160,9 +156,7 @@ listenTuples :: MonadIO m
160156 => Unfold m (Int, SockSpec, SockAddr) (Socket, SockAddr)
161157listenTuples = Unfold step inject
162158 where
163− inject (listenQLen, spec, addr) = do
164− listener <- liftIO $ initListener listenQLen spec addr
165− return listener
159+ inject (listenQLen, spec, addr) = liftIO $ initListener listenQLen spec addr
166160
167161 step listener = do
168162 r <- liftIO $ Net.accept listener
@@ -208,8 +202,7 @@ recvConnectionTuplesWith tcpListenQ spec addr = S.unfoldrM step Nothing
208202-- /Internal/
209203{-# INLINE connections #-}
210204connections :: 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
213206
214207-------------------------------------------------------------------------------
215208-- Array IO (Input)
@@ -416,7 +409,7 @@ read = UF.supplyFirst readWithBufferOf A.defaultChunkSize
416409{-# INLINE fromChunks #-}
417410fromChunks :: (MonadIO m, Storable a)
418411 => Socket -> SerialT m (Array a) -> m ()
419−fromChunks h m = S.mapM_ (liftIO . writeChunk h) m
412+fromChunks h = S.mapM_ (liftIO . writeChunk h)
420413
421414-- | Write a stream of arrays to a socket. Each array in the stream is written
422415-- to the socket as a separate IO request.