我对Haskell非常陌生,因为您可以猜测Yesod也是新手。我想玩弄这两种方法,以更多地了解Haskell和Web开发。Yesod:无法在另一个处理程序中访问LoginR
我有两个问题,他们都可能是由于我缺乏的Haskell知识愚蠢的错误,我做:
(1)我创建了SQLite的脚手架网站(我用耶索德1.2)。我试图在生成的homepage.hamlet文件中添加一行,它给了我一个错误(顺便说一句,该网站工作正常,没有这个补充)。我加了一行是:
<a [email protected]{AuthR LoginR}>Go to the login page
后,我收到此错误信息:
Handler/Home.hs:34:11:
Not in scope: data constructor `LoginR'
In the result of the splice:
$(widgetFile "homepage")
To see what the splice expanded to, use -ddump-splices
In a stmt of a 'do' block: $(widgetFile "homepage")
In the second argument of `($)', namely
`do { aDomId <- newIdent;
setTitle "Welcome To Yesod!";
$(widgetFile "homepage") }'
有没有办法在其他处理程序/模板暴露LoginR? (2)我最终想定制登录页面的外观和感觉,所以我试图按照这里的说明(也认为这可能会解决上述问题,因为我声明自己的处理程序在范围内):http://hackological.com/blog/using-twitter-to-authenticate-in-yesod/。基本上我修改Foundation.hs的authRoute声明如下
authRoute _ = Just LoginPanelR
,然后加入航线:
/login LoginPanelR GET
和Home.hs
getLoginPanelR :: Handler RepHtml
getLoginPanelR = defaultLayout $(widgetFile "login")
添加了处理程序我也创建了相应的包含链接中提供的内容的login.hamlet文件。然后我得到以下错误:
Foundation.hs:100:32:
Couldn't match type `App' with `Auth'
Expected type: Route Auth
Actual type: Route App
In the first argument of `AuthR', namely `LoginPanelR'
In the second argument of `($)', namely `AuthR LoginPanelR'
In the expression: Just $ AuthR LoginPanelR
请问我是否知道我做错了什么?
谢谢!
非常感谢!它现在有效。我期待更多地了解Yesod。当我绊倒你可能会看到更多的问题:)顺便说一句,不知道是否有人向你提到这件事,昨天(6月11日)yesodweb.com断断续续 - 无法连接,但使用浏览器的服务器是它响应去ping。 – Ecognium