Learning Koka 2022-08-11

By Max Woerner Chase

I'm going to stick to the HTML stuff for now, rather than switching with the structuring concurrency.

I have a feeling that I'm doing something kind of imprecise with my mental models of this tag rendering stuff, so let's see what happens if I try to lay down some details.

Tag(
  "html",
  [],
  Just(
    (
      "",
      [
        (Tag("head", [], Just(("", []))), ""),
        (Tag("body", [], Just(("", []))), ""),
      ]
    )
  )
)

Which should turn into

<html><head></head><body></body></html>

Obviously, the Koka code is not how stuff should be written out manually...

And to tweak the output a bit...

Tag(
  "html",
  [],
  Just(
    (
      "",
      [
        (Tag("head", [], Just(("\n", []))), ""),
        (Tag("body", [], Just(("\n", []))), ""),
      ]
    )
  )
)

Which should produce

<html>
    <head>
    </head>
    <body>
    </body>
</html>

How it gets there doesn't feel straightforward to me. Like, maybe there can be a list of lines, where each line is a list of elements, and once the line includes a line break, it gets split up into a bunch of lines?

So there's then another representation like

[
  [
    StartTag("html", []),
    StartTag("head", []),
    EndTag("head"),
    StartTag("body", []),
    EndTag("body"),
    EndTag("html"),
  ],
]

I've drafted out basic code for representing this stuff, but I should figure out how to represent stuff like "tags that don't reflow their content in a templating context".

I'll have to think about that some, maybe switch gears again later. For now, I'm tired.

Good night.