Permalink
Browse files

"Fix" existing unused monadic result warnings by adding _ <-

They all look dubious and should be reviewed properly
  • Loading branch information...
1 parent f04fb16 commit 4fa0e24155a7f58b7e3ec41bdfc325d334cf43f6 @hsenag hsenag committed Aug 30, 2012
Showing with 23 additions and 14 deletions.
  1. +10 −6 Network/HTTP/HandleStream.hs
  2. +3 −2 Network/HTTP/Proxy.hs
  3. +10 −6 Network/HTTP/Stream.hs
View
16 Network/HTTP/HandleStream.hs
@@ -1,4 +1,3 @@
-{-# OPTIONS_GHC -fno-warn-unused-do-bind #-}
-----------------------------------------------------------------------------
-- |
-- Module : Network.HTTP.HandleStream
@@ -114,9 +113,11 @@ sendMain conn rqst onSendComplete = do
--let str = if null (rqBody rqst)
-- then show rqst
-- else show (insertHeader HdrExpect "100-continue" rqst)
- writeBlock conn (buf_fromStr bufferOps $ show rqst)
+ -- TODO review throwing away of result
+ _ <- writeBlock conn (buf_fromStr bufferOps $ show rqst)
-- write body immediately, don't wait for 100 CONTINUE
- writeBlock conn (rqBody rqst)
+ -- TODO review throwing away of result
+ _ <- writeBlock conn (rqBody rqst)
onSendComplete
rsp <- getResponseHead conn
switchResponse conn True False rsp rqst
@@ -152,7 +153,8 @@ switchResponse conn allow_retry bdy_sent (Right (cd,rn,hdrs)) rqst =
Retry -> do {- Request with "Expect" header failed.
Trouble is the request contains Expects
other than "100-Continue" -}
- writeBlock conn ((buf_append bufferOps)
+ -- TODO review throwing away of result
+ _ <- writeBlock conn ((buf_append bufferOps)
(buf_fromStr bufferOps (show rqst))
(rqBody rqst))
rsp <- getResponseHead conn
@@ -230,9 +232,11 @@ receiveHTTP conn = getRequestHead >>= either (return . Left) processRequest
-- server interactions, performing the dual role to 'sendHTTP'.
respondHTTP :: HStream ty => HandleStream ty -> Response ty -> IO ()
respondHTTP conn rsp = do
- writeBlock conn (buf_fromStr bufferOps $ show rsp)
+ -- TODO: review throwing away of result
+ _ <- writeBlock conn (buf_fromStr bufferOps $ show rsp)
-- write body immediately, don't wait for 100 CONTINUE
- writeBlock conn (rspBody rsp)
+ -- TODO: review throwing away of result
+ _ <- writeBlock conn (rspBody rsp)
return ()
------------------------------------------------------------------------------
View
5 Network/HTTP/Proxy.hs
@@ -1,4 +1,3 @@
-{-# OPTIONS_GHC -fno-warn-unused-do-bind #-}
{-# LANGUAGE CPP #-}
-----------------------------------------------------------------------------
-- |
@@ -165,7 +164,9 @@ uri2proxy _ = Nothing
#if defined(WIN32)
regQueryValueDWORD :: HKEY -> String -> IO DWORD
regQueryValueDWORD hkey name = alloca $ \ptr -> do
- regQueryValueEx hkey name (castPtr ptr) (sizeOf (undefined :: DWORD))
+ -- TODO: this throws away the key type returned by regQueryValueEx
+ -- we should check it's what we expect instead
+ _ <- regQueryValueEx hkey name (castPtr ptr) (sizeOf (undefined :: DWORD))
peek ptr
#endif
View
16 Network/HTTP/Stream.hs
@@ -1,4 +1,3 @@
-{-# OPTIONS_GHC -fno-warn-unused-do-bind #-}
-----------------------------------------------------------------------------
-- |
-- Module : Network.HTTP.Stream
@@ -108,9 +107,11 @@ sendMain conn rqst onSendComplete = do
--let str = if null (rqBody rqst)
-- then show rqst
-- else show (insertHeader HdrExpect "100-continue" rqst)
- writeBlock conn (show rqst)
+ -- TODO review throwing away of result
+ _ <- writeBlock conn (show rqst)
-- write body immediately, don't wait for 100 CONTINUE
- writeBlock conn (rqBody rqst)
+ -- TODO review throwing away of result
+ _ <- writeBlock conn (rqBody rqst)
onSendComplete
rsp <- getResponseHead conn
switchResponse conn True False rsp rqst
@@ -155,7 +156,8 @@ switchResponse conn allow_retry bdy_sent (Right (cd,rn,hdrs)) rqst =
Retry -> {- Request with "Expect" header failed.
Trouble is the request contains Expects
other than "100-Continue" -}
- do { writeBlock conn (show rqst ++ rqBody rqst)
+ do { -- TODO review throwing away of result
+ _ <- writeBlock conn (show rqst ++ rqBody rqst)
; rsp <- getResponseHead conn
; switchResponse conn False bdy_sent rsp rqst
}
@@ -226,7 +228,9 @@ receiveHTTP conn = getRequestHead >>= processRequest
-- | Very simple function, send a HTTP response over the given stream. This
-- could be improved on to use different transfer types.
respondHTTP :: Stream s => s -> Response_String -> IO ()
-respondHTTP conn rsp = do writeBlock conn (show rsp)
+respondHTTP conn rsp = do -- TODO review throwing away of result
+ _ <- writeBlock conn (show rsp)
-- write body immediately, don't wait for 100 CONTINUE
- writeBlock conn (rspBody rsp)
+ -- TODO review throwing away of result
+ _ <- writeBlock conn (rspBody rsp)
return ()

0 comments on commit 4fa0e24

Please sign in to comment.