Use functor

This commit is contained in:
Alexey Khudyakov 2011-06-14 19:14:14 +04:00
parent 77a4475f6e
commit f14cd14164

View File

@ -22,7 +22,8 @@ module Yesod.Dispatch
, toWaiAppPlain , toWaiAppPlain
) where ) where
import Data.Either (partitionEithers) import Data.Functor ((<$>))
import Data.Either (partitionEithers)
import Prelude hiding (exp) import Prelude hiding (exp)
import Yesod.Internal.Core import Yesod.Internal.Core
import Yesod.Handler import Yesod.Handler
@ -163,19 +164,13 @@ thResourceFromResource (Resource n _ _) =
-- middlewares: GZIP compression, JSON-P and path cleaning. This is the -- middlewares: GZIP compression, JSON-P and path cleaning. This is the
-- recommended approach for most users. -- recommended approach for most users.
toWaiApp :: (Yesod y, YesodDispatch y y) => y -> IO W.Application toWaiApp :: (Yesod y, YesodDispatch y y) => y -> IO W.Application
toWaiApp y = do toWaiApp y = gzip False . jsonp . autohead <$> toWaiAppPlain y
a <- toWaiAppPlain y
return $ gzip False
$ jsonp
$ autohead
a
-- | Convert the given argument into a WAI application, executable with any WAI -- | Convert the given argument into a WAI application, executable with any WAI
-- handler. This differs from 'toWaiApp' in that it uses no middlewares. -- handler. This differs from 'toWaiApp' in that it uses no middlewares.
toWaiAppPlain :: (Yesod y, YesodDispatch y y) => y -> IO W.Application toWaiAppPlain :: (Yesod y, YesodDispatch y y) => y -> IO W.Application
toWaiAppPlain a = do toWaiAppPlain a = toWaiApp' a <$> encryptKey a
key' <- encryptKey a
return $ toWaiApp' a key'
toWaiApp' :: (Yesod y, YesodDispatch y y) toWaiApp' :: (Yesod y, YesodDispatch y y)
=> y => y