# \`blaze-html-qq\`

**URL:** https://discourse.haskell.org/t/blaze-html-qq/7824
**Category:** Show and Tell
**Created:** [October 8, 2023, 4:38pm UTC](https://discourse.haskell.org/t/blaze-html-qq/7824 "2023-10-08T16:38:42Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![ocramz](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/ocramz/32/3713_2.png) [@ocramz](https://discourse.haskell.org/u/ocramz)
#### Post date: [October 8, 2023, 4:38pm UTC](https://discourse.haskell.org/t/blaze-html-qq/7824/1 "2023-10-08T16:38:42Z")

</div>

Hi there!

With this library you can parse inline HTML at compile time and produce `MarkupM` terms for `blaze-markup` and `blaze-html`. I imagine this can play nicely with server-side web frameworks such as HTMX and `scotty` (cc @piq9117 ^^).

This proved to be more challenging than expected but it does in fact work nicely.

I’d appreciate if someone with TH experience could chime in with ways to clean up the recursive production of a Q Exp term; auto-deriving Lift for the blaze types does not work.

> **[GitHub - ocramz/blaze-html-qq: Quasiquoters for blaze-html](https://github.com/ocramz/blaze-html-qq)**
>
> Quasiquoters for blaze-html. Contribute to ocramz/blaze-html-qq development by creating an account on GitHub.

Let me know your thoughts on this!

---

<div class="post-metadata">

### Author: ![ocramz](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/ocramz/32/3713_2.png) [@ocramz](https://discourse.haskell.org/u/ocramz)
#### Post date: [October 8, 2023, 8:52pm UTC](https://discourse.haskell.org/t/blaze-html-qq/7824/3 "2023-10-08T20:52:16Z")

</div>

ah, I didn’t know shakespeare uses blaze. Thanks! Well, my new library is a very simplified version of shakespeare you could say.

---

<div class="post-metadata">

### Author: ![Liamzy](https://avatars.discourse-cdn.com/v4/letter/l/50afbb/32.png) [@Liamzy](https://discourse.haskell.org/u/Liamzy)
#### Post date: [October 9, 2023, 4:47am UTC](https://discourse.haskell.org/t/blaze-html-qq/7824/4 "2023-10-09T04:47:10Z")

</div>

And from your description, it’s not necessarily a bad thing. Shakespeare is highly associated with Yesod, and from its description, it’s less discoverable.

If you’re calling your library a simplified version of Shakespeare, then, besides trying to provide a core, simplified functionality, you can also try to focus on documentation, as well as making it accessible to newer / lesser-skilled users.

Even if, ultimately, you and others might decide that this is not good enough to publish on Hackage, it’s good practice on the documentation front.

---

<div class="post-metadata">

### Author: ![danidiaz](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/danidiaz/32/92_2.png) [@danidiaz](https://discourse.haskell.org/u/danidiaz)
#### Post date: [October 9, 2023, 7:28pm UTC](https://discourse.haskell.org/t/blaze-html-qq/7824/5 "2023-10-09T19:28:34Z")

</div>

Can Haskell values be interpolated?

---

<div class="post-metadata">

### Author: ![ocramz](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/ocramz/32/3713_2.png) [@ocramz](https://discourse.haskell.org/u/ocramz)
#### Post date: [October 9, 2023, 7:38pm UTC](https://discourse.haskell.org/t/blaze-html-qq/7824/6 "2023-10-09T19:38:10Z")

</div>

It appears not, but I’m still not clear on the reason. I couldn’t find ways to customize this behaviour. Do you have any pointers?

---

<div class="post-metadata">

### Author: ![silky](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/silky/32/3555_2.png) [@silky](https://discourse.haskell.org/u/silky)
#### Post date: [October 10, 2023, 11:16am UTC](https://discourse.haskell.org/t/blaze-html-qq/7824/7 "2023-10-10T11:16:19Z")

</div>

If it helps, this is the entrypoint to where shakespeare does it - [https://hackage.haskell.org/package/shakespeare-2.1.0.1/docs/src/Text.Hamlet.html#shamlet](https://hackage.haskell.org/package/shakespeare-2.1.0.1/docs/src/Text.Hamlet.html#shamlet) ; maybe glancing here - [https://hackage.haskell.org/package/shakespeare-2.1.0.1/docs/src/Text.Hamlet.Parse.html#local-6989586621679434103](https://hackage.haskell.org/package/shakespeare-2.1.0.1/docs/src/Text.Hamlet.Parse.html#local-6989586621679434103) - but it’s a bit more complicated than that, because I suppose somewhere they look up those variables in the present scope.

---

<div class="post-metadata">

### Author: ![mpscholten](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/mpscholten/32/1441_2.png) [@mpscholten](https://discourse.haskell.org/u/mpscholten)
#### Post date: [October 10, 2023, 8:49pm UTC](https://discourse.haskell.org/t/blaze-html-qq/7824/8 "2023-10-10T20:49:07Z")

</div>

You might also find some inspiration for the interpolation code in ihp-hsx (which is the standalone package of the IHP JSX-like quasiquoter. It’s actually also based on blaze). [ihp-hsx: JSX-like but for Haskell](https://hackage.haskell.org/package/ihp-hsx-1.1.0)

It uses the GHC parser to parse the expressions between {} and then converts that to the TH data structures. We took the idea from the PyF library

---

<div class="post-metadata">

### Author: ![ocramz](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/ocramz/32/3713_2.png) [@ocramz](https://discourse.haskell.org/u/ocramz)
#### Post date: [October 11, 2023, 7:29am UTC](https://discourse.haskell.org/t/blaze-html-qq/7824/9 "2023-10-11T07:29:51Z")

</div>

Thank you @silky and @mpscholten ! I agree having function-like templates would make the library more flexible on the Haskell side, but one would lose the 1:1 correspondence with HTML, which is also handy when building up web views.  
I think ultimately this is a matter of taste and “product” vision rather than a “why not” technical decision, which is why it makes sense when integrating tightly with a framework such as Yesod or IHP and less so with a general-purpose library, in my view.

---

<div class="post-metadata">

### Author: ![silky](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/silky/32/3555_2.png) [@silky](https://discourse.haskell.org/u/silky)
#### Post date: [October 11, 2023, 7:58am UTC](https://discourse.haskell.org/t/blaze-html-qq/7824/10 "2023-10-11T07:58:04Z")

</div>

Makes sense @ocramz ; but do let me clarify one minor point - shakespeare is not quite married to yesod; I use it happily in a servant environment in combination with [servant-blaze](https://hackage.haskell.org/package/servant-blaze).
