Learning Koka 2022-08-10
I thought about stuff to do with Koka, and I ended up deciding to try to focus on one subsystem from the hypothetical CGI idea: just generating HTML.
The basic thing I'm interested in trying to do, is to make the generated HTML indent nicely. If you ask around online, people will tell you this is "not important" and such, but I'm looking for something that interests me, rather than that addresses any burning need.
I'm thinking some kind of library of functions that lets you write all of this as code. Have functions for each tag. So, what we need to know about how this stuff all works?
Well, there's the doctype thing. Some tags can only appear in specific contexts, which it might make sense to express in the type system. For now, I'll just think about that in terms of the <html>, <head>, and <body> tags, since those are simple.
Maybe try to separately address "this is how to convert this tag object to a string" and "this is how tag objects are allowed to relate to each other".
Like, a generic representation of "HTML tags, but ignoring all semantics"... That looks something like:
- a tag name
- an alist of attribute-value pairs
- maybe<> a structure that represents the tag contents, which can be, say, maybe<> a string, followed by a vector or list of tag-text pairs.
I believe a few tags would need special-casing (I'm thinking <pre> and <script> at least), but the majority should be able to work from just that.
Anyway, I let this get late. I'll actually try to code stuff later.
Good night.