News for hackers. Stuff that matters.
Re:What would it take to add refinement types to Rust? by williamdclt on Wednesday December 25, 2024 @06:13AM (#42508216)
I’ve seen “month” being implemented in typescript as a big sum type ‘1 | 2 | 3 | … | 12’ :) probably ranges could just be syntactical sugar on top of that, but I suppose it probably causes big inefficiencies for the compiler
Re:What would it take to add refinement types to Rust? by int_19h on Wednesday December 25, 2024 @10:18PM (#42512900)
It can be syntactic sugar in terms of how it's defined, but the implementation can still be smart and use a compact representation where possible (this is basically RLE).

Similarly, if you have tuples (or structs with anon fields etc) in the language, you could unify those with arrays such that struct { int; int; } is the same as int[2].