我正在尝试Yesod
Yesod网页上记录的示例示例。其中一个例子是Chat application embedded in Wiki。当我尝试在ghci中(加载从Wiki.hs
Chat
模块,其中包含维基示例代码),我得到下面的错误Chat.hs:尝试一些Yesod示例时编译错误
Chat.hs:122:34:
Could not deduce (Text.Julius.ToJavascript Text)
arising from a use of `Text.Julius.toJavascript'
from the context (YesodChat master)
bound by the type signature for
chatWidget :: YesodChat master =>
(Route Chat -> Route master) -> GWidget sub master()
at Chat.hs:(81,15)-(83,35)
Possible fix:
add an instance declaration for (Text.Julius.ToJavascript Text)
In the first argument of `Text.Julius.Javascript', namely
`Text.Julius.toJavascript output'
In the expression:
Text.Julius.Javascript (Text.Julius.toJavascript output)
In the first argument of `Data.Monoid.mconcat', namely
`[Text.Julius.Javascript
((Data.Text.Lazy.Builder.fromText . Text.Shakespeare.pack')
"\
\// Set up the receiving end\
\var output = document.getElementById(\""),
Text.Julius.Javascript (Text.Julius.toJavascript output),
Text.Julius.Javascript
((Data.Text.Lazy.Builder.fromText . Text.Shakespeare.pack')
"\");\
\var src = new EventSource(\""),
Text.Julius.Javascript
(Data.Text.Lazy.Builder.fromText
(_render_a3Yr (toMaster ReceiveR) [])),
....]'
我不是很熟悉耶索德库呢。所以,我被上述错误难住了 - 我在其他的Yesod例子中也看到了这个错误,其中toWidget
函数被调用。所以,这似乎与toWidget
函数有关。我将不胜感激帮助解决上述错误。
我正在使用ghc 7.6.1
和yesod 1.1.4.1
。
更新:
固定以下哈马的建议。我在Chat.hs
中做了两处修改。对于rawJS
添加import语句:
import Text.Julius (rawJS)
追查所有的#{}块内
julius whamlet
在Chat.hs
情况,并与{# rawJS ...}
替换它们var output = document.getElementById("#{rawJS output}");
var input = document.getElementById("#{rawJS input}");
谢谢你,@hammar。这正是问题所在。现在在我追踪了julius whamlet中的每个#{}块后,立即修复,并用rawJS替换它。 – Sal