3 ms·
Right, I'm just unsure how valuable those guarantees really are. Especially if I'm extracting an Int out of the type to interface with other code.
by b_e_n_t_o_n 1y ago
Right, I'm just unsure how valuable those guarantees really are. Especially if I'm extracting an Int out of the type to interface with other code.
- the_af 1y ago> Especially if I'm extracting an Int out of the type to interface with other code. Why would you do this? As soon as you go "outside" the type you lose typechecker guarantees. The whole point of the article is showing where the compiler can tell you when you're writing code that fails to consider some cases, and how use of `newtype` loses some of these guarantees.
- b_e_n_t_o_n 1y agoI don't think I'm gonna find a library that supports my OneToFive type.
- the_af 1y agoYour type comes with its own library, and the compiler makes sure you're not misusing it by failing to consider a possible case. If you need to use your OneToFive someplace that actually wants an integer, that happens at the boundary. Everything else is safer.