2010-07-22 5 views
8

Samouczek dotyczący blazehtml i innych postów na blogu bardzo wyraźnie pokazuje, jak napisać literały łańcuchowe. Mam to. Ale w jaki sposób uzyskać ciągi (bytestrings, Data.Text, itp. Też by działało.) W ogóle do atrybutów/zawartości elementów. Blazehtml wygląda świetnie, ale bez tego wydaje się całkiem bezużyteczny. = Pjak uzyskać ciągi znaków (nie literały łańcuchowe) w atrybutach blazehtml/zawartości elementu?

oto wyjście próbki i kod, aby pokazać dokładnie problem:


{-# 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 
 
*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 

Odpowiedz

Powiązane problemy