on master help sign in
Using <$>.
commit5f27e17dc40498e60139f9e4c62675fbc83916b9 authorKazu Yamamoto <kazu@iij.ad.jp> dateTue 14 Aug 2012, 16:47 (14 years ago) parente5f87e4
3 files changed+10−7
warp/Network/Wai/Handler/Warp/Conduit.hs+2−1 warp/Network/Wai/Handler/Warp/Request.hs+3−2 warp/Network/Wai/Handler/Warp/Response.hs+5−4
warp/Network/Wai/Handler/Warp/Conduit.hs+2−1
@@ -1,5 +1,6 @@
11module Network.Wai.Handler.Warp.Conduit where
22
3+import Control.Applicative
34import Control.Exception
45import Control.Monad (unless)
56import Control.Monad.IO.Class (MonadIO, liftIO)
@@ -70,7 +71,7 @@ ibsIsolate ibs@(IsolatedBSSource ref) = do
7071-- | Extract the underlying @Source@ from an @IsolatedBSSource@, which will not
7172-- perform any more isolation.
7273ibsDone :: IsolatedBSSource -> IO (ResumableSource (ResourceT IO) ByteString)
73−ibsDone (IsolatedBSSource ref) = fmap snd $ I.readIORef ref
74+ibsDone (IsolatedBSSource ref) = snd <$> I.readIORef ref
7475
7576----------------------------------------------------------------
7677
warp/Network/Wai/Handler/Warp/Request.hs+3−2
@@ -3,6 +3,7 @@
33
44module Network.Wai.Handler.Warp.Request where
55
6+import Control.Applicative
67import Control.Exception.Lifted (throwIO)
78import Control.Monad.IO.Class (MonadIO, liftIO)
89import Data.ByteString (ByteString)
@@ -77,9 +78,9 @@ parseRequest' conn port (firstLine:otherLines) remoteHost' src = do
7778 if chunked
7879 then do
7980 ref <- I.newIORef (src, NeedLen)
80− return (chunkedSource ref, fmap fst $ I.readIORef ref)
81+ return (chunkedSource ref, fst <$> I.readIORef ref)
8182 else do
82− ibs <- fmap IsolatedBSSource $ I.newIORef (len0, src)
83+ ibs <- IsolatedBSSource <$> I.newIORef (len0, src)
8384 return (ibsIsolate ibs, ibsDone ibs)
8485
8586 return (Request
warp/Network/Wai/Handler/Warp/Response.hs+5−4
@@ -4,11 +4,10 @@
44
55module Network.Wai.Handler.Warp.Response where
66
7−import Data.List (foldl')
8−import qualified Data.Conduit.List as CL
97import Blaze.ByteString.Builder (copyByteString, Builder, toLazyByteString, toByteStringIO, flush)
108import Blaze.ByteString.Builder.Char8 (fromChar, fromShow)
119import Blaze.ByteString.Builder.HTTP (chunkedTransferEncoding, chunkedTransferTerminator)
10+import Control.Applicative
1211import Control.Exception
1312import Control.Monad.IO.Class (MonadIO, liftIO)
1413import qualified Data.ByteString.Char8 as B
@@ -16,6 +15,8 @@ import qualified Data.ByteString.Lazy as L
1615import qualified Data.CaseInsensitive as CI
1716import Data.Conduit
1817import Data.Conduit.Blaze (builderToByteString)
18+import qualified Data.Conduit.List as CL
19+import Data.List (foldl')
1920import Data.Maybe (isJust)
2021import Data.Monoid (mappend)
2122import qualified Network.HTTP.Types as H
@@ -40,10 +41,10 @@ sendResponse th req conn r = sendResponse' r
4041 sendResponse' :: Response -> ResourceT IO Bool
4142 sendResponse' (ResponseFile s hs fp mpart) = do
4243 eres <-
43− case (readInt `fmap` lookup H.hContentLength hs, mpart) of
44+ case (readInt <$> lookup H.hContentLength hs, mpart) of
4445 (Just cl, _) -> return $ Right (hs, cl)
4546 (Nothing, Nothing) -> liftIO $ try $ do
46− cl <- P.fileSize `fmap` P.getFileStatus fp
47+ cl <- P.fileSize <$> P.getFileStatus fp
4748 return $ addClToHeaders cl
4849 (Nothing, Just part) -> do
4950 let cl = filePartByteCount part