blazehtml教程和其他博客文章非常清楚如何使字符串文字工作.我有那个.但是,如何将字符串(字节串,Data.Text等也可以工作)通常用于元素的属性/内容.Blazehtml看起来很棒,但如果没有它,它似乎毫无用处.= P
这里是示例输出和代码来显示确切的问题:
{-# LANGUAGE OverloadedStrings #-}
import Prelude
import qualified Prelude as P
import Text.Blaze.Html5
import Text.Blaze.Html5.Attributes
import qualified Text.Blaze.Html5 as H
import qualified Text.Blaze.Html5.Attributes as A
makeLink dest cont = renderHtml $ a ! src dest $ cont
Run Code Online (Sandbox Code Playgroud)
*Main> let foo = "foo"
*Main> let bar = "bar"
*Main> makeLink foo bar
:1:9:
Couldn't match expected type `AttributeValue'
against inferred type `[Char]'
In the first argument of `makeLink', namely `foo'
In the expression: makeLink foo bar
In the definition of `it': it = makeLink foo bar
teh*_*ter 11
在文档的这一页中,我们找到了必要的功能:http://hackage.haskell.org/packages/archive/blaze-html/0.1.2/doc/html/Text-Blaze.html.
它们是stringValue :: String - > AttributeValue和string :: String - > Html a.问题解决了!
| 归档时间: |
|
| 查看次数: |
945 次 |
| 最近记录: |