From 02cf6f84d3a225220df6d52182834cebd02a3c8a Mon Sep 17 00:00:00 2001 From: Michael Snoyman Date: Mon, 31 Jan 2011 07:11:05 +0200 Subject: [PATCH] Change some ByteString to String --- Yesod/Core.hs | 29 ++++++++++------------------- Yesod/Dispatch.hs | 8 ++------ 2 files changed, 12 insertions(+), 25 deletions(-) diff --git a/Yesod/Core.hs b/Yesod/Core.hs index 6acfe834..b1c9093d 100644 --- a/Yesod/Core.hs +++ b/Yesod/Core.hs @@ -81,9 +81,9 @@ class Eq u => RenderRoute u where -- | This class is automatically instantiated when you use the template haskell -- mkYesod function. You should never need to deal with it directly. -class Yesod master => YesodDispatch a master where +class YesodDispatch a master where yesodDispatch - :: (Yesod master) + :: Yesod master => a -> Maybe CS.Key -> [String] @@ -111,9 +111,7 @@ class RenderRoute (Route a) => Yesod a where -- -- * You do not use any features that require absolute URLs, such as Atom -- feeds and XML sitemaps. - -- - -- FIXME: is this the right typesig? - approot :: a -> S.ByteString + approot :: a -> String -- | The encryption key to be used for encrypting client sessions. -- Returning 'Nothing' disables sessions. @@ -150,7 +148,7 @@ class RenderRoute (Route a) => Yesod a where -- | Override the rendering function for a particular URL. One use case for -- this is to offload static hosting to a different domain name to avoid -- sending cookies. - urlRenderOverride :: a -> Route a -> Maybe S.ByteString + urlRenderOverride :: a -> Route a -> Maybe String urlRenderOverride _ _ = Nothing -- | Determine if a request is authorized or not. @@ -203,19 +201,12 @@ class RenderRoute (Route a) => Yesod a where -- | Join the pieces of a path together into an absolute URL. This should -- be the inverse of 'splitPath'. - -- - -- FIXME is this the right type sig? joinPath :: a - -> S.ByteString -- ^ application root + -> String -- ^ application root -> [String] -- ^ path pieces -> [(String, String)] -- ^ query string - -> S.ByteString - joinPath _ ar pieces qs = - S.concat - [ ar - , S8.singleton '/' - , S8.pack $ encodePathInfo pieces qs - ] + -> String + joinPath _ ar pieces qs = ar ++ '/' : encodePathInfo pieces qs -- | This function is used to store some static content to be served as an -- external file. The most common case of this is stashing CSS and @@ -493,9 +484,9 @@ yesodRender :: Yesod y -> [(String, String)] -> String yesodRender y u qs = - S8.unpack $ fromMaybe - (joinPath y (approot y) ps $ qs ++ qs') - (urlRenderOverride y u) + fromMaybe + (joinPath y (approot y) ps $ qs ++ qs') + (urlRenderOverride y u) where (ps, qs') = renderRoute u diff --git a/Yesod/Dispatch.hs b/Yesod/Dispatch.hs index 85c52a83..cbc447ef 100644 --- a/Yesod/Dispatch.hs +++ b/Yesod/Dispatch.hs @@ -203,14 +203,10 @@ toWaiApp' y key' env = do dest' = if S.null (W.queryString env) then dest - else S.concat - [ dest - , B.singleton '?' - , W.queryString env - ] + else dest ++ '?' : B.unpack (W.queryString env) in return $ W.responseLBS W.status301 [ ("Content-Type", "text/plain") - , ("Location", dest') + , ("Location", B.pack $ dest') ] "Redirecting" #if TEST