3 ms·
Sometimes you'll read something and think "I'm not taking the bait".
by muglug 3y ago
Sometimes you'll read something and think "I'm not taking the bait".
- phkahler 3y ago>> Sometimes you'll read something and think "I'm not taking the bait". Like when I read about "auto" in C++. It still bugs me when I see it...
- yazzku 3y agoIt's not even factual. > In Rust and Haskell you have to at least annotate the parameter types and return type of functions. Type inference is only for variable bindings inside the function body. This is false for Haskell. Can't speak for Rust.
- deleted 3y ago[deleted]
- masklinn 3y agoRust does require explicitly writing out the signature of top-level functions. I believe it was a conscious decision to limit de cascading of type errors from global type inference, the base algorithm was capable of it.
- vacuity 3y agoYes, particularly due to the design decision that Rust code should strive to be explicit in intention and mechanism.
- hyperman1 3y agoIn rust, you are required to annotate at least the interface. In Haskell, if I remember it well, it is allowed but not required. Even in Rust, I tend to specify types at variable bindings if the type gets overly complex, just to push errors closer to their cause. A nice feature of Rust is you can specify partial types, wih underscores for the still-to-infer part. E.g. let x:Vec<_>=someexpression; is a vector of something, but you don't know what exactly.
- codetrotter 3y ago> you can specify partial types, wih underscores for the still-to-infer part Yup. I love that. And it even lets you say things like for example: let res: Result<Vec<_>, _> = someexpression;
- Tainnor 3y agoit's technically false for Haskell, but is considered mostly good practice. It would be true for Idris.
- russellbeattie 3y agoAt least it wasn't titled, "Type Inference Considered Harmful". That one always infuriates me.