Workarounds for older bytestrings

This commit is contained in:
Michael Snoyman 2014-04-16 14:31:54 +03:00
parent e8ce5650da
commit dfd7965b6b
3 changed files with 17 additions and 5 deletions

View File

@ -49,7 +49,19 @@ import Yesod.Core.Types
import Yesod.Core.Internal.Request (parseWaiRequest,
tooLargeResponse)
import Yesod.Routes.Class (Route, renderRoute)
import Control.DeepSeq (($!!))
import Control.DeepSeq (($!!), NFData)
import Control.Monad (liftM)
returnDeepSessionMap :: Monad m => SessionMap -> m SessionMap
#if MIN_VERSION_bytestring(0, 10, 0)
returnDeepSessionMap sm = return $!! sm
#else
returnDeepSessionMap sm = fmap unWrappedBS `liftM` (return $!! fmap WrappedBS sm)
-- | Work around missing NFData instance for bytestring 0.9.
newtype WrappedBS = WrappedBS { unWrappedBS :: S8.ByteString }
instance NFData WrappedBS
#endif
-- | Function used internally by Yesod in the process of converting a
-- 'HandlerT' into an 'Application'. Should not be needed by users.
@ -82,7 +94,7 @@ runHandler rhe@RunHandlerEnv {..} handler yreq = withInternalState $ \resState -
state <- liftIO $ I.readIORef istate
(finalSession, mcontents1) <- (do
finalSession <- return $!! ghsSession state
finalSession <- returnDeepSessionMap (ghsSession state)
return (finalSession, Nothing)) `E.catch` \e -> return
(Map.empty, Just $! HCError $! InternalError $! T.pack $! show (e :: E.SomeException))

View File

@ -318,8 +318,8 @@ data Header =
-- annotations to SetCookie in the cookie package.
instance NFData Header where
rnf (AddCookie x) = rnf x
rnf (DeleteCookie x y) = rnf x `seq` rnf y
rnf (Header x y) = rnf x `seq` rnf y
rnf (DeleteCookie x y) = x `seq` y `seq` ()
rnf (Header x y) = x `seq` y `seq` ()
data Location url = Local url | Remote Text
deriving (Show, Eq)

View File

@ -1,5 +1,5 @@
name: yesod-core
version: 1.2.13
version: 1.2.13.1
license: MIT
license-file: LICENSE
author: Michael Snoyman <michael@snoyman.com>