El tutorial de blazehtml y otras publicaciones de blog dejan muy claro cómo hacer funcionar los literales de cadena. Lo tengo. Pero, ¿cómo obtengo cadenas (cadenas de bytes, Data.Text, etc. también funcionarían) en general en los atributos/contenido de los elementos. Blazehtml se ve genial, pero parece bastante inútil sin eso. = P¿cómo se obtienen cadenas (no literales de cadena) en atributos blazehtml/contenido de elementos?
aquí está un ejemplo de salida y el código para mostrar el problema exacto:
{-# 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
La función 'stringValue' ahora es obsoleto. En su lugar, use 'Text.Blaze.toValue :: a -> AttributeValue' –