|
MLs require a lot of ceremony modelling simple record types. What we want to express here is an object with a map of properties (name to type): string Type map
For the OOP minded: Map<string, Type>
And also compose those: type Foo = { "_foo", int }
type Bar = { "_bar", string }
type FooBar = mergeMaps Foo Bar
But at compile-time, of course.Have any languages achieved this? I know TypeScript can do some of these things, but it's clunky. |
Here's three recent papers on extensible records:
* https://arxiv.org/pdf/2108.06296 * https://arxiv.org/pdf/2404.00338 * https://dl.acm.org/doi/pdf/10.1145/3571224
I'm not claiming these are definitive in any sense, but they are useful guides into the literature if any reader wants to learn more. (If you are not used to reading programming language papers, the introduction, related work, and conclusions are usually the most useful. All the greek in the middle can usually be skipped unless you are trying to implement it.)