Hacker News new | ask | show | jobs
by Athas 3367 days ago
I am intrigued by this snippet from the README:

    type messages 'x = 'x | Fetch pid 'x
This appears to define a sum type where one of the variants is left with an implicit constructor. How do you pattern match on that? How do you do type inference?
1 comments

That's a good question and the short answer is that we're deliberately breaking decidability to allow people to use types that are relatively in line with what we're used to in Erlang (I get into this a bit in the talk linked above). There's a reasonable argument to be made that we should knock this off of course but I'm generally biased in favour of making interoperation with the ecosystem simpler :)

We should actually clean up that example you pointed out, matching on the `Fetch` constructor first. What we're really trying to support is unions like:

    type number = int | float
There's a yet un-had argument about the utility of this as well of course and we may want to remove the ability to do this entirely. The way we type this is by actually using type-checking guard functions like `is_integer` to convey information to the typer at compile time.