1
我想在html页面中发布一个curl命令的结果, 在haskell中使用yesod框架。 这是我的代码至今:如何使用yesod在html页面上显示卷曲结果?
{-# LANGUAGE TypeFamilies, QuasiQuotes, MultiParamTypeClasses,
TemplateHaskell, OverloadedStrings #-}
import Yesod
import Network.Curl
import Text.Blaze hiding (toMarkup)
data HelloWorld = HelloWorld
mkYesod "HelloWorld" [parseRoutes|
/HomeR GET
|]
url = "http://www.google.com/"
opts = [CurlFollowLocation True]
res=withCurlDo $ do
curlGet url opts
return()
instance ToMarkup (IO a) where
toMarkup a = a
instance Yesod HelloWorld
getHomeR :: Handler RepHtml
getHomeR = defaultLayout [whamlet|#{toMarkup res}|]
main :: IO()
main = warpDebug 3000 HelloWorld
此代码启动服务器警告
Warning: No explicit method nor default method for `Text.Blaze.toMarkup'
In the instance declaration for `ToMarkup (IO a)'
和指向网页浏览器
http://localhost:3000
它给“内部服务器错误“作为HTML页面沿着上述警告消息。
我对Haskell和Yesod相当陌生......有人可以帮忙吗?
谢谢卢克......这非常有帮助! – sudoking 2013-03-13 06:29:10