I wish we didn't need bounds checking; the problem could be solved with dependently typed languages. Unfortunately Rust just panics when you access out of bounds, and doesn't warn you at compile time. Rust isn't really all that impressive.
I wish we didn't need bounds checking; the problem could be solved with dependently typed languages. Unfortunately Rust just panics when you access out of bounds, and doesn't warn you at compile time. Rust isn't really all that impressive.
I know nothing about Rust, but you might find Oleg Kiselyov's: "Eliminating Array Bound Checking through Non-Dependent Types" interesting.
http://okmij.org/ftp/Haskell/eliminating-array-bound-check.l...
You may also like:
http://okmij.org/ftp/Haskell/number-parameterized-types.pdf
http://okmij.org/ftp/Computation/resource-aware-prog/tfp.pdf
I don't think Rust can ever replicate the Haskell implementation identically (if we had HRTB over types), as type parametrism is gone (see: specialization RFC). However, lifetime parametrism serves a similar role in Rust, and lifetimes are closer to a concept of "instance" than types.