On Sunday, 18 September 2022 at 20:28:58 UTC, FeepingCreature wrote:>
Alright, since I've ran out of critical issues on my TODO, here's Neat!
Can you show a little bit of your sum types? They can be implemented in four ways:
- Stupid union (like
unionin C, C++, and D)
- Type union or soft discriminated union (
- Indexed union or hard discriminated union (
For 2., you effectively ask: Which types are in? Order and repetition don’t matter.
And 3. is effectively an algebraic type with unary constructors that are referred to by index (instead of by name).
There are even more options like
string+int, but int+int is not allowed, i.e. you can always uniquely ask “Does it contain an
int?” Without ambiguity about which
What is your take on qualifiers? Is
int+const(int) allowed and/or the same as
Do your sum types nest or are they flat? As an example, D’s alias sequences are flat:
AliasSeq!(a, AliasSeq!(b, c), d) =
AliasSeq!(a, b, c, d). A sum type implementation can make
int+char+string+double or keep the nesting. As alias sequences show, flattening is not that bad and if not desired, can be mitigated using wrappers.
Does it support the empty sum? It would naturally be a bottom type.
Does a unary sum exist? It would naturally be equivalent to the only type argument.
You had to make these decisions (even if unaware of the options). What did you decide for Neat?