2
我正在通過blaze-html教程開展工作。我只想要一個簡單的Hello World頁面。如何從火焰中獲取html - 打印到文件
{-# LANGUAGE OverloadedStrings #-}
import Control.Monad (forM_)
import Text.Blaze.Html5
import Text.Blaze.Html5.Attributes
import qualified Text.Blaze.Html5 as H
import qualified Text.Blaze.Html5.Attributes as A
import Text.Blaze.Html.Renderer.Text
notes :: Html
notes = docTypeHtml $ do
H.head $ do
H.title "John´ s Page"
body $ do
p "Hello World!"
它在哪裏?我如何獲得我的HTML?我可以將它打印到終端或文件嗎?那將是一個很好的開始。
<html>
<head><title>John's Page</title></head>
<body><p>Hello World!</p></body>
</html>
而且所有的導入語句真的有必要嗎?我只是想讓它工作。
我嘗試使用renderHTML
功能打印,但我只是得到一個錯誤信息:
main = (renderHtml notes) >>= putStrLn
notes.hs:21:9:
Couldn't match expected type `IO String'
with actual type `Data.Text.Internal.Lazy.Text'
In the return type of a call of `renderHtml'
In the first argument of `(>>=)', namely `(renderHtml notes)'
In the expression: (renderHtml notes) >>= putStrLn