by ddevault · 4y ago · 0 comments
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 ;)