[Haskell-cafe] Generating valid html

Jon Fairbairn jon.fairbairn at cl.cam.ac.uk
Thu Nov 13 11:03:44 UTC 2014


Wojtek Narczyński <wojtek at power.com.pl> writes:

> On 13.11.2014 02:07, Christopher Reichert wrote:
>>
>> I'm not sure if it fits all your criteria but BlazeHtml might interest you.
>>
>> https://hackage.haskell.org/package/blaze-html
>>
> My question is how to capture (at least some of) the HTML
> validity rules in Haskell types, or classes, or families, or
> whatever.

I have a library that does pretty much all of that. For your
entertainment I’ve put a bundle of it here:
http://scrap.bookofsand.co.uk/HTMLs.tar.gz, it’s not caballized
so you may have to ask me how to build it if gmake doesn’t work.
I haven’t tried it with anything newer than ghc 7.6.3

It’s semi-mechanically derived from the definition of xhtml 1.0
with reference to the description of html 4. Since the formal
documents are not normative, it wasn’t a mechanical translation.
I couldn’t do the same for html5 because there is no standard.

The problem with it (why I haven’t released it) is that because
all the checks are done in the type system, the error messages
that result from attempting to make bad html can be difficult to
comprehend; I sometimes end up interpreting a type error as
“there’s a mistake” and looking at the code for mistakes without
trying to work out what the type error means.

-- 
Jón Fairbairn                                 Jon.Fairbairn at cl.cam.ac.uk




More information about the Haskell-Cafe mailing list