For the Hamlet template mechanism, I understand that the template is parsed at compile time, resulting in source code that contains calls to blaze-html combinators (and possibly other expressions because of interpolation). So the points (subtrees) where interpolation happens are known at compile-time.
At run-time, we need to compute the interpolated value (of course), and "plug it" in the tree, that is, apply the html combinators. All of them? Actually some of these applications could be evaluated at compile-time (those that have no interpolation below them). Does this happen?
It's been a while since I worked on the code, so don't take this as authoratative (like Daniel mentioned, -ddump-simpl
is a good call here). But I don't believe we're using the blaze-html combinators, just the data type. Hamlet itself concatenates strings as much as possible at compile time to avoid that cost at runtime. I know when I last benchmarked (which granted was years ago), that optimization did pay off pretty well.