There are sum types (tagged unions), but product types (tuples) were a late addition and we still don't have support for tuple unpacking or pattern matching on them.
Tuple unpacking is something that's been put off for very long but looks like it is going to finally happen soon. Pattern matching on types other than tagged unions hasn't been completely ruled out yet, but is also not guaranteed to happen.
https://harelang.org/tutorials/introduction/#tagged-unions-i...
They are also covered in section 6.5.18 of the Hare specification:
https://harelang.org/specification.pdf
Would be curious to hear your thoughts on how they compare given your (presumed) background in functional programming.
type foo = (A int | B int)
Which from my cursory reading does not seem to be possible? type a = int;
type b = int;
type c = (a | b);
Which seems to be what you're angling for here? I also suspect that you're approaching this from a Rust- or Zig-like background where enums and tagged unions are closely related; this is not so in Hare.The example you linked did not really make it clear from my point of view because one of the points is that it will collapse if there are multiples of a specific type. But your way seems to make it possible.
> Would be curious to hear your thoughts on how they compare given your (presumed) background in functional programming.
I'm just a student with an interest in programming languages and very little knowledge and experience, so I don't think I'll be able to provide any significant insight ;)