Skip to content

Commit

Permalink
"Fix" existing unused monadic result warnings by adding _ <-
Browse files Browse the repository at this point in the history
They all look dubious and should be reviewed properly
  • Loading branch information
hsenag committed Aug 30, 2012
1 parent f04fb16 commit 4fa0e24
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 14 deletions.
16 changes: 10 additions & 6 deletions Network/HTTP/HandleStream.hs
@@ -1,4 +1,3 @@
{-# OPTIONS_GHC -fno-warn-unused-do-bind #-}
----------------------------------------------------------------------------- -----------------------------------------------------------------------------
-- | -- |
-- Module : Network.HTTP.HandleStream -- Module : Network.HTTP.HandleStream
Expand Down Expand Up @@ -114,9 +113,11 @@ sendMain conn rqst onSendComplete = do
--let str = if null (rqBody rqst) --let str = if null (rqBody rqst)
-- then show rqst -- then show rqst
-- else show (insertHeader HdrExpect "100-continue" 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 -- write body immediately, don't wait for 100 CONTINUE
writeBlock conn (rqBody rqst) -- TODO review throwing away of result
_ <- writeBlock conn (rqBody rqst)
onSendComplete onSendComplete
rsp <- getResponseHead conn rsp <- getResponseHead conn
switchResponse conn True False rsp rqst switchResponse conn True False rsp rqst
Expand Down Expand Up @@ -152,7 +153,8 @@ switchResponse conn allow_retry bdy_sent (Right (cd,rn,hdrs)) rqst =
Retry -> do {- Request with "Expect" header failed. Retry -> do {- Request with "Expect" header failed.
Trouble is the request contains Expects Trouble is the request contains Expects
other than "100-Continue" -} 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)) (buf_fromStr bufferOps (show rqst))
(rqBody rqst)) (rqBody rqst))
rsp <- getResponseHead conn rsp <- getResponseHead conn
Expand Down Expand Up @@ -230,9 +232,11 @@ receiveHTTP conn = getRequestHead >>= either (return . Left) processRequest
-- server interactions, performing the dual role to 'sendHTTP'. -- server interactions, performing the dual role to 'sendHTTP'.
respondHTTP :: HStream ty => HandleStream ty -> Response ty -> IO () respondHTTP :: HStream ty => HandleStream ty -> Response ty -> IO ()
respondHTTP conn rsp = do 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 -- write body immediately, don't wait for 100 CONTINUE
writeBlock conn (rspBody rsp) -- TODO: review throwing away of result
_ <- writeBlock conn (rspBody rsp)
return () return ()


------------------------------------------------------------------------------ ------------------------------------------------------------------------------
Expand Down
5 changes: 3 additions & 2 deletions Network/HTTP/Proxy.hs
@@ -1,4 +1,3 @@
{-# OPTIONS_GHC -fno-warn-unused-do-bind #-}
{-# LANGUAGE CPP #-} {-# LANGUAGE CPP #-}
----------------------------------------------------------------------------- -----------------------------------------------------------------------------
-- | -- |
Expand Down Expand Up @@ -165,7 +164,9 @@ uri2proxy _ = Nothing
#if defined(WIN32) #if defined(WIN32)
regQueryValueDWORD :: HKEY -> String -> IO DWORD regQueryValueDWORD :: HKEY -> String -> IO DWORD
regQueryValueDWORD hkey name = alloca $ \ptr -> do 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 peek ptr


#endif #endif
16 changes: 10 additions & 6 deletions Network/HTTP/Stream.hs
@@ -1,4 +1,3 @@
{-# OPTIONS_GHC -fno-warn-unused-do-bind #-}
----------------------------------------------------------------------------- -----------------------------------------------------------------------------
-- | -- |
-- Module : Network.HTTP.Stream -- Module : Network.HTTP.Stream
Expand Down Expand Up @@ -108,9 +107,11 @@ sendMain conn rqst onSendComplete = do
--let str = if null (rqBody rqst) --let str = if null (rqBody rqst)
-- then show rqst -- then show rqst
-- else show (insertHeader HdrExpect "100-continue" 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 -- write body immediately, don't wait for 100 CONTINUE
writeBlock conn (rqBody rqst) -- TODO review throwing away of result
_ <- writeBlock conn (rqBody rqst)
onSendComplete onSendComplete
rsp <- getResponseHead conn rsp <- getResponseHead conn
switchResponse conn True False rsp rqst switchResponse conn True False rsp rqst
Expand Down Expand Up @@ -155,7 +156,8 @@ switchResponse conn allow_retry bdy_sent (Right (cd,rn,hdrs)) rqst =
Retry -> {- Request with "Expect" header failed. Retry -> {- Request with "Expect" header failed.
Trouble is the request contains Expects Trouble is the request contains Expects
other than "100-Continue" -} 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 ; rsp <- getResponseHead conn
; switchResponse conn False bdy_sent rsp rqst ; switchResponse conn False bdy_sent rsp rqst
} }
Expand Down Expand Up @@ -226,7 +228,9 @@ receiveHTTP conn = getRequestHead >>= processRequest
-- | Very simple function, send a HTTP response over the given stream. This -- | Very simple function, send a HTTP response over the given stream. This
-- could be improved on to use different transfer types. -- could be improved on to use different transfer types.
respondHTTP :: Stream s => s -> Response_String -> IO () 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 -- write body immediately, don't wait for 100 CONTINUE
writeBlock conn (rspBody rsp) -- TODO review throwing away of result
_ <- writeBlock conn (rspBody rsp)
return () return ()

0 comments on commit 4fa0e24

Please sign in to comment.