From 366127527acf7907f49a6b1c4bc9e86f0a708143 Mon Sep 17 00:00:00 2001 From: Michael Snoyman Date: Mon, 19 Aug 2013 13:20:44 +0300 Subject: [PATCH] Fix some CPP --- yesod-core/Yesod/Core/Handler.hs | 4 ++-- yesod-core/Yesod/Core/Internal/Response.hs | 2 +- yesod-core/Yesod/Core/Internal/Run.hs | 18 +++++++++--------- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/yesod-core/Yesod/Core/Handler.hs b/yesod-core/Yesod/Core/Handler.hs index c956abc4..205e1a66 100644 --- a/yesod-core/Yesod/Core/Handler.hs +++ b/yesod-core/Yesod/Core/Handler.hs @@ -230,7 +230,7 @@ runRequestBody = do Just rbc -> return rbc Nothing -> do rr <- waiRequest -#if MIN_VERSION_wai(0, 2, 0) +#if MIN_VERSION_wai(2, 0, 0) rbc <- liftIO $ rbHelper upload rr #else rbc <- liftResourceT $ rbHelper upload rr @@ -986,7 +986,7 @@ rawRequestBody :: MonadHandler m => Source m S.ByteString rawRequestBody = do req <- lift waiRequest transPipe -#if MIN_VERSION_wai(0, 2, 0) +#if MIN_VERSION_wai(2, 0, 0) liftIO #else liftResourceT diff --git a/yesod-core/Yesod/Core/Internal/Response.hs b/yesod-core/Yesod/Core/Internal/Response.hs index 411713ac..c9151ed4 100644 --- a/yesod-core/Yesod/Core/Internal/Response.hs +++ b/yesod-core/Yesod/Core/Internal/Response.hs @@ -54,7 +54,7 @@ yarToResponse (YRPlain s' hs ct c newSess) saveSession yreq req = do let hs' = maybe finalHeaders finalHeaders' mlen in ResponseBuilder s hs' b go (ContentFile fp p) = ResponseFile s finalHeaders fp p -#if MIN_VERSION_wai(0, 2, 0) +#if MIN_VERSION_wai(2, 0, 0) go (ContentSource body) = ResponseSource s finalHeaders $ transPipe (flip runInternalState $ resourceInternalState req) body #else go (ContentSource body) = ResponseSource s finalHeaders body diff --git a/yesod-core/Yesod/Core/Internal/Run.hs b/yesod-core/Yesod/Core/Internal/Run.hs index f60dd701..615af0e2 100644 --- a/yesod-core/Yesod/Core/Internal/Run.hs +++ b/yesod-core/Yesod/Core/Internal/Run.hs @@ -32,7 +32,7 @@ import Data.Text.Encoding.Error (lenientDecode) import Language.Haskell.TH.Syntax (Loc, qLocation) import qualified Network.HTTP.Types as H import Network.Wai -#if MIN_VERSION_wai(0, 2, 0) +#if MIN_VERSION_wai(2, 0, 0) import Network.Wai.Internal #endif import Prelude hiding (catch) @@ -165,14 +165,14 @@ runFakeHandler fakeSessionMap logger site handler = liftIO $ do ret <- I.newIORef (Left $ InternalError "runFakeHandler: no result") let handler' = do liftIO . I.writeIORef ret . Right =<< handler return () -#if MIN_VERSION_wai(0, 2, 0) +#if MIN_VERSION_wai(2, 0, 0) let yapp internalState = runHandler #else let yapp = runHandler #endif RunHandlerEnv { rheRender = yesodRender site $ resolveApproot site $ fakeWaiRequest -#if MIN_VERSION_wai(0, 2, 0) +#if MIN_VERSION_wai(2, 0, 0) internalState #endif , rheRoute = Nothing @@ -191,7 +191,7 @@ runFakeHandler fakeSessionMap logger site handler = liftIO $ do (toContent ("runFakeHandler: errHandler" :: S8.ByteString)) (reqSession req) fakeWaiRequest -#if MIN_VERSION_wai(0, 2, 0) +#if MIN_VERSION_wai(2, 0, 0) internalState #endif = @@ -200,7 +200,7 @@ runFakeHandler fakeSessionMap logger site handler = liftIO $ do , httpVersion = H.http11 , rawPathInfo = "/runFakeHandler/pathInfo" , rawQueryString = "" -#if MIN_VERSION_wai(0, 2, 0) +#if MIN_VERSION_wai(2, 0, 0) , resourceInternalState = internalState #else , serverName = "runFakeHandler-serverName" @@ -215,7 +215,7 @@ runFakeHandler fakeSessionMap logger site handler = liftIO $ do , vault = mempty , requestBodyLength = KnownLength 0 } -#if MIN_VERSION_wai(0, 2, 0) +#if MIN_VERSION_wai(2, 0, 0) fakeRequest internalState = #else fakeRequest = @@ -224,7 +224,7 @@ runFakeHandler fakeSessionMap logger site handler = liftIO $ do { reqGetParams = [] , reqCookies = [] , reqWaiRequest = fakeWaiRequest -#if MIN_VERSION_wai(0, 2, 0) +#if MIN_VERSION_wai(2, 0, 0) internalState #endif , reqLangs = [] @@ -232,7 +232,7 @@ runFakeHandler fakeSessionMap logger site handler = liftIO $ do , reqAccept = [] , reqSession = fakeSessionMap } -#if MIN_VERSION_wai(0, 2, 0) +#if MIN_VERSION_wai(2, 0, 0) _ <- runResourceT $ do is <- getInternalState yapp is $ fakeRequest is @@ -276,7 +276,7 @@ yesodRunner handler' YesodRunnerEnv {..} route req { rheOnError = runHandler rheSafe . errorHandler } yar <- -#if MIN_VERSION_wai(0, 2, 0) +#if MIN_VERSION_wai(2, 0, 0) flip runInternalState (resourceInternalState req) $ #endif runHandler rhe handler yreq