News for hackers. Stuff that matters.
Re:Unusual basis types in programming languages by tj800x on Thursday January 18, 2024 @03:15PM (#39047005)
Somewhat related: I'm surprised we don't see NonZero numbers (NzInts, NzNats, and NzReals, etc). This would seem to avoid a lot of division by zero problems at the type level. I realize this might "back up" checking for zeros into the origin of denominator values, but that seems like it would be an improvement to me.
Re:Unusual basis types in programming languages by itishappy on Friday January 19, 2024 @01:35PM (#39059240)
In the same vein, having a dedicated type for natural (or even Peano) numbers can be quite nice. I've seen some clever use-cases in Haskell and Rust such as statically enforcing bounds checks. Can't have a negative length list!