Tôi đang thử Yesod
các ví dụ về sách được ghi trên trang web Yesod. Một trong các ví dụ là dành cho Chat application embedded in Wiki. Khi tôi thử nó trong ghci (tải Chat
mô-đun từ Wiki.hs
chứa Wiki mã ví dụ), tôi nhận được báo lỗi dưới đây cho Chat.hs:Lỗi biên dịch khi thử một số ví dụ về 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) [])),
....]'
Tôi không phải là rất quen thuộc với các thư viện Yesod được nêu ra. Vì vậy, tôi stumped bởi các lỗi trên - Tôi đã nhìn thấy lỗi này trong ví dụ khác Yesod quá nơi toWidget
chức năng được gọi là. Vì vậy, nó có vẻ liên quan đến chức năng toWidget
. Tôi sẽ đánh giá cao sự giúp đỡ trong việc sửa lỗi trên.
Tôi đang sử dụng ghc 7.6.1
với yesod 1.1.4.1
.
Cập nhật:
Cố định sau đây gợi ý Hammar của. Tôi đã thực hiện hai thay đổi trong Chat.hs
.
tuyên bố nhập khẩu Add cho rawJS:
import Text.Julius (rawJS)
Theo dõi xuống tất cả các trường hợp của # {} khối trong
julius whamlet
trongChat.hs
, và thay thế chúng với{# rawJS ...}
var output = document.getElementById("#{rawJS output}");
var input = document.getElementById("#{rawJS input}");
cảm ơn bạn, @hammar. Đó chính là vấn đề. Đã sửa lỗi ngay sau khi tôi theo dõi từng khối # {} bên trong julius whamlet và thay thế nó bằng rawJS. – Sal