I’ve been building a web language with Haskell-like syntax and a PHP-like execution model server/client separation in the same file. It’s not complete but it’s functional. Built it mostly for fun rather than to solve any specific problem. Leaving it here in case anyone finds it interesting.
Looks Cool!
I was wondering, how hard would it be to cut out the PHP-style parsing of HTML interleaved with code into some standalone reusable functionality? I assume people would love to plug in various custom other ad-hoc DSLs into this scheme.
(I guess there’s a lot of gotchas, mainly syntax collisions with the magic brackets, but perhaps there’s some unexplored design space there.)
That’s an interesting direction I hadn’t considered. Interpolating is technically separable from Haskell evaluation; it’s really just a matter of parsing the boundaries between HTML and embedded expressions. With Megaparsec, you could probably abstract it into a generic interface with its own built-in evaluator. I’m not sure how clean it would be in practice, but it’s worth exploring. Would you be interested in something like that?
Out of curiosity, do you expect this to ever become production ready?
Fun to build, but yes — production ready is the goal.
Yeah I thought something structured, like the HTML ADT from Lucid with the extra “language” mixed in that. (Or perhaps the language AST intermixed with Lucid structure?)
I actually built a small QuasiQuotes library for the HTML parsing — partly to avoid the Lucid dependency, partly to keep the syntax closer to actual HTML. Though it could probably be adapted to work with Lucid as well.