Are union/sum types another "basis"? Some languages include syntax for them at the level of structs, others require they be painfully hacked together out of libraries and template metaprogramming (std::variant, though bare unions exist without carrying a tag).
I also thought this was a major omission. After using languages with well-supported sum types (mainly Swift and Elm), I find it painful to go back to languages that lack native support.
Covering numeric types more in depth could be interesting. It seems to surprise most people when they run into '0123' for octal or '123f' (or is that 'f123'?) for a float, '0xdeadbeef' for hex, or 'b123' for binary (is that right...? you see it so rarely I'm not sure without looking up some examples). And I'm sure there's more: surely people have come up with notations for quarternions, complex numbers, and more.
Rust also has hash sets (implemented internally with a hashmap) and B-Tree sets (implemented internally with a B-Tree map). They aren't really basis though, but in Rust almost nothing is.
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.
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!
12 comments
[ 3.4 ms ] story [ 41.7 ms ] threadhttp://www.rebol.com/r3/docs/datatypes.html