我瀏覽了yesod書籍和源代碼,並且學習了幾乎所有的工作。但是在寫我自己的東西之前,腳手架網站上有一件事我只是不明白。我不明白yesod中這種類型的家庭資料是用於
所以我腳手架網站「copywww」,並在文件CopyWWWState.hs有代碼:
instance YesodPersist CopyWWWState where
type YesodDB CopyWWWState = SqlPersist
runDB db = liftIOHandler
$ fmap connPool getYesod >>= Settings.runConnectionPool db
instance YesodAuth CopyWWWState where
type AuthId CopyWWWState = UserId
-- Where to send a user after successful login
loginDest _ = RootR
-- Where to send a user after logout
logoutDest _ = RootR
getAuthId creds = runDB $ do
x <- getBy $ UniqueUser $ credsIdent creds
case x of
Just (uid, _) -> return $ Just uid
Nothing -> do
fmap Just $ insert $ User (credsIdent creds) Nothing
authPlugins = [ authOpenId
, authEmail
]
,我不知道該線是那些:
type AuthId CopyWWWState = UserId
type YesodDB CopyWWWState = SqlPersist
當我刪除它們時,我顯然會遇到錯誤,但我不確定爲什麼它們是首要的。當我搜索「UserId」或「SqlPersist」的源代碼時,我沒有提到任何看起來很有希望的東西。這段代碼到底需要做什麼? yesod在這些類中使用類型族有什麼好處?