マイケルが言うように、「ハムレット自体は、実行時のコストを回避するために、コンパイル時に可能な限り文字列を連結します。」
本の例では、
main = putStrLn $ renderHtml [shamlet|
<p>Hello, my name is #{name person} and I am #{show $ age person}.
<p>
Let's do some funny stuff with my name: #
<b>#{sort $ map toLower (name person)}
<p>Oh, and in 5 years I'll be #{show ((+) 5 (age person))} years old.
|]
where
person = Person "Michael" 26
-ddump-simpl
これが含まれています:
(>>
@ Text.Blaze.Internal.MarkupM
Text.Blaze.Internal.$fMonadMarkupM
@ ()
@ ()
(id
@ (Text.Blaze.Internal.MarkupM ())
(. @ Data.Text.Internal.Text
@ Text.Blaze.Internal.Markup
@ String
Text.Blaze.Internal.preEscapedText
Data.Text.pack
(GHC.CString.unpackCString#
".</p>\n\
\<p>Let's do some funny stuff with my name: <b>"#)))
実際、これは HTML の構文ツリーではありません (最後の行 - 文字列には終了タグと次の開始タグが含まれています)。
このハムレットの機能はもっと宣伝されるべきです!