4 ms·
Hot take: it's possible to have a strict language where tags don't have to start and end in the same template. For example, make linear types Html, HtmlOpen, H
by henrydark 3y ago
Hot take: it's possible to have a strict language where tags don't have to start and end in the same template.
For example, make linear types Html, HtmlOpen, HtmlBody, and HtmlClosed, with the addition rules (which could be functions or what have you)
HtmlOpen + HtmlBody = HtmlOpen
HtmlBody + HtmlBody = HtmlBody
HtmlBody + HtmlClosed = HtmlClosed
HtmlOpen + HtmlClosed = Html
and only Html has whatever it takes to be valid output.
A separate point is that string templating is simply a local maximum.
- reuben364 3y agoReminds me of Edward Kmett's talks on monoidal parsing in which he has Dyck languages as an example. I'm confused about the need for "linear types", unless you mean a monoid. I'm not sure of a use case where you would want a open fragment of html or a closed one other than to a have a hole, that is something like f : HtmlBody -> HtmlBody f x = someOpenFragment + x + someClosedFragment
- henrydark 3y agoThe example in the reference in the piece is to have a header and a footer, where header would be open and footer closed. As for linear types, I mean that somewhere the type system won't allow progress if you have an open type that wasn't converted to some final state. This is strictly necessary.
- reuben364 3y agoAh, you don't need linear types for that. Linear types will prevent you from duplicating or discarding values, but all you need is to only allow "final state" values to be used in your API. Also a reminder that I should read articles before commenting.
- henrydark 3y agoSorry, auto correct malfunction, I meant "isn't strictly necessary"