The increasingly supported Web Components v1 API allows very flexible use of the DOM by declaring custom tags and defining their behavior, among other things. However, its use in production as of 2019 requires polyfill scripts and I’m shy about adding those to my production builds without careful consideration. In this post, I explore the older and simpler way to achieve similar results with backwards and forwards compatible strategies.
One key element of making impossible states impossible in OCaml is to wrap broad types into narrower ones. Here’s a strategy I use to achieve this with minimal boilerplate.
I’m a huge fan of using existing standards whenever possible, even in a private project where I’ll have to write a partial implementation myself, to ease future unforeseen integrations. That said, the simplicity and other immediate benefits of S-expressions are too good to pass up.