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.

Let me know your thoughts on this!


Out of curiosity, I think shakespeare (from the Yesod ecosystem) is also based on blaze-html. What would be the advantages/differences over it ?


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


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.

1 Like

Can Haskell values be interpolated?

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?

If it helps, this is the entrypoint to where shakespeare does it - https://hackage.haskell.org/package/shakespeare- ; maybe glancing here - https://hackage.haskell.org/package/shakespeare- - but it’s a bit more complicated than that, because I suppose somewhere they look up those variables in the present scope.


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

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


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.

1 Like

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.