Switch Routes back to type family.

There appears to be a bug in GHC, but I'm not certain. Look at the
output from compiling the previous commit; some kind of interaction with
a DataInstD and deriving instances.
This commit is contained in:
Michael Snoyman 2010-07-01 17:55:00 +03:00
parent 5568530a5d
commit 3ed97f4cfc
6 changed files with 12 additions and 10 deletions

View File

@ -141,7 +141,9 @@ mkYesodGeneral name args clazzes isSub res = do
$ map (\x -> (x, [])) ("master" : args) ++ clazzes $ map (\x -> (x, [])) ("master" : args) ++ clazzes
th <- mapM (thResourceFromResource arg) res -- FIXME now we cannot have multi-nested subsites th <- mapM (thResourceFromResource arg) res -- FIXME now we cannot have multi-nested subsites
w' <- createRoutes th w' <- createRoutes th
let w = DataInstD [] ''Routes [arg] w' [''Show, ''Read, ''Eq] let routesName = mkName $ name ++ "Routes"
let w = DataD [] routesName [] w' [''Show, ''Read, ''Eq]
let x = TySynInstD ''Routes [arg] $ ConT routesName
parse' <- createParse th parse' <- createParse th
parse'' <- newName "parse" parse'' <- newName "parse"
@ -166,7 +168,7 @@ mkYesodGeneral name args clazzes isSub res = do
let y = InstanceD ctx ytyp let y = InstanceD ctx ytyp
[ FunD (mkName yfunc) [Clause [] (NormalB site') []] [ FunD (mkName yfunc) [Clause [] (NormalB site') []]
] ]
return ([w], [y]) return ([w, x], [y])
isStatic :: Piece -> Bool isStatic :: Piece -> Bool
isStatic StaticPiece{} = True isStatic StaticPiece{} = True
@ -248,7 +250,7 @@ toWaiApp' y segments env = do
eurl = parsePathSegments site pathSegments eurl = parsePathSegments site pathSegments
render u = fromMaybe render u = fromMaybe
(fullRender (approot y) (formatPathSegments site) u) (fullRender (approot y) (formatPathSegments site) u)
(urlRenderOverride u) (urlRenderOverride y u)
rr <- parseWaiRequest env session' rr <- parseWaiRequest env session'
let h = do let h = do
onRequest onRequest

View File

@ -96,7 +96,7 @@ import Numeric (showIntAtBase)
import Data.Char (ord, chr) import Data.Char (ord, chr)
-- | The type-safe URLs associated with a site argument. -- | The type-safe URLs associated with a site argument.
data family Routes a type family Routes a
data HandlerData sub master = HandlerData data HandlerData sub master = HandlerData
{ handlerRequest :: Request { handlerRequest :: Request

View File

@ -22,7 +22,7 @@
module Yesod.Helpers.Auth module Yesod.Helpers.Auth
( -- * Subsite ( -- * Subsite
Auth (..) Auth (..)
, Routes (..) , AuthRoutes (..)
-- * Settings -- * Settings
, YesodAuth (..) , YesodAuth (..)
, Creds (..) , Creds (..)
@ -154,7 +154,7 @@ mkYesodSub "Auth" [("master", [''YesodAuth])] [$parseRoutes|
/facebook/start StartFacebookR GET /facebook/start StartFacebookR GET
/register EmailRegisterR GET POST /register EmailRegisterR GET POST
/verify/#EmailId/#String EmailVerifyR GET /verify/#Integer/#String EmailVerifyR GET
/login EmailLoginR GET POST /login EmailLoginR GET POST
/set-password EmailPasswordR GET POST /set-password EmailPasswordR GET POST
|] |]

View File

@ -6,7 +6,7 @@
module Yesod.Helpers.Crud module Yesod.Helpers.Crud
( Item (..) ( Item (..)
, Crud (..) , Crud (..)
, Routes (..) , CrudRoutes (..)
, defaultCrud , defaultCrud
) where ) where

View File

@ -27,7 +27,7 @@
module Yesod.Helpers.Static module Yesod.Helpers.Static
( -- * Subsite ( -- * Subsite
Static (..) Static (..)
, Routes (..) , StaticRoutes (..)
-- * Lookup files in filesystem -- * Lookup files in filesystem
, fileLookupDir , fileLookupDir
, staticFiles , staticFiles

View File

@ -93,8 +93,8 @@ class Yesod a where
-- | Override the rendering function for a particular URL. One use case for -- | 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 -- this is to offload static hosting to a different domain name to avoid
-- sending cookies. -- sending cookies.
urlRenderOverride :: Routes a -> Maybe String urlRenderOverride :: a -> Routes a -> Maybe String
urlRenderOverride _ = Nothing urlRenderOverride _ _ = Nothing
-- | Determine if a request is authorized or not. -- | Determine if a request is authorized or not.
-- --