unseemly
unseemly copied to clipboard
Implement enum subtyping (maybe)
Currently, following TAPL, when an enum value is constructed, it needs a type annotation to know what the "rest" of the arms are. (In practice, real languages look up the enum type from the choice name.) Instead, I think we may want to say that, e.g. +[Some 5]+ has the type enum { +[Some Int]+ }, which is a subtype of enum { +[Some Int]+ +[None]+ }.
This could be a minor convenience to the programmer, but the big thing that this gets us is that, when we are constructing a match in a macro, it'll probably be reasonable to do exhaustiveness checking because we'll have types that correspond to "partial" enums.
Implicit in the above is that pattens will be required to be irrefutable at their types. At the moment, that isn’t a big change, but it does seem to cut off any possibility of, say, patterns containing expressions (for exact matches) or arbitrary conditions, both of which are useful.
One possibility would be to have a separate IrrefutablePat; not sure how to make that work in practice, though, particularly because a type-safe irrefutability-enforcing catchall-free match should be implementable as a macro.