What I Want from a Type System (2016)
I&#x27;m working on one [1] and doing the inference now, which is kicking my ass TBH, so some thoughts:<p>&gt; 1) Full type inference.<p>Really, while writing and hacking, you want it, but ideally the system should be able to fill in your types for you. Note, though, that there&#x27;s a tradeoff: the more overloading and other conveniences, the less complete the inference can be.<p>In the system I&#x27;m working on, it&#x27;s intended to deploy a library + documentation, so all types would be annotated in the artifact generated regardless of whether they are in the source.<p>&gt; 2). Value types in structures would need to be nominal, not structural.<p>My answer to this is we want cheap sum types. In Tenet, a sum type can be constructed without any declaration by writing tag~expr. This implicitly defines Union[tag~WhateverExprTypeIs].<p>Since unions implicitly combine, if I have one branch return meters~55 another can return error~&quot;something broke&quot; and the return type overall is implicitly Union[meters~Integer, error~String].<p>The idea of declaring that, e.g. meters~X and centimeters~Y are interchangeable representations of the same value is something I&#x27;m thinking about; it&#x27;s getting at a facility for encapsulation.<p>&gt; 3) Collections of [product types] would need to be inclusively typed, not exclusive.<p>So, if we have syntax for retrieving an attribute `x.a + x.b` and we know + takes integers, we can deduce an assertion that x is some product type with two integer attributes a and b. I call that an open tuple, as opposed to a closed tuple.<p>But all product types must be closed (exclusive) in order to construct them, obviously, and for non-dynamic languages, it seems like you&#x27;re liable to have code size explosion (multiple copies of functions to support each type used) if you allow polymorphism this way.<p>&gt; 4) ... it would be important to have all these structural members be namespaced as well.<p>I&#x27;m curious what people think the best namespace schemes are, because most of them seem like a lot of complexity for what they do. But...<p>&gt; 5) Now I would still need basic set logic for these types<p>It won&#x27;t make the first cut, but the basic operations would be sum and diff (for sum types), times and project (for product types) and a renaming facility with globbing seems like it might answer #4 just fine.<p>[1]: <a href="https:&#x2F;&#x2F;tenet-lang.org&#x2F;types.html#tenets-approach" rel="nofollow">https:&#x2F;&#x2F;tenet-lang.org&#x2F;types.html#tenets-approach</a>