3 ms·
Yeah I think this becomes more true the closer your type system gets to "formal verification" type systems. It's essentially trying to prove some fact, and a si
by IshKebab 2y ago
Yeah I think this becomes more true the closer your type system gets to "formal verification" type systems. It's essentially trying to prove some fact, and a single mistake anywhere means it will say no. The error messages also get worse the further along that scale you go (Prolog is infamous).
Not really unique to Rust though; I imagine you would have the same experience with e.g. Lean. I have a similar experience with a niche language I use that has dependent types. Kind of a puzzle almost.
It is more work, but you get lots of rewards in return (including less work overall in the long term). Ask me how much time I've spent debugging segfaults in C++ and Rust...
- deleted 2y ago[deleted]
- ykonstant 2y agoLean is far more punishing even for simple imperative code. The following is rejected: /- Return the array of forward differences between consecutive elements of the input. Return the empty array if the input is empty or a singleton. -/ def diffs (numbers : Array Int) : Array Int := Id.run do if size_ok : numbers.size > 1 then let mut diffs := Array.mkEmpty (numbers.size - 1) for index_range : i in [0:numbers.size - 2] do diffs := diffs.push (numbers[i+1] - numbers[i]) return diffs else return #[]
- binary132 2y agoThat’s not what OP is discussing. OP is discussing corner cases in Rust’s typesystem that would be sound if the typesystem were more sophisticated, but are rejected because Rust’s type analysis is insufficiently specific and rejects blanket classes of problems that have possible valid solutions, but would need deeper flow analysis, etc.