Type Inference Was a Mistake
borretti.me
Type Inference Was a Mistake
1–10 of 133 posts
Re: Type Inference Was a Mistake
#2Re: Type Inference Was a Mistake
#3Sometimes you'll read something and think "I'm not taking the bait".
> 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.
Re: Type Inference Was a Mistake
#4In Rust you do, but in Haskell you don't.
Re: Type Inference Was a Mistake
#5Sometimes 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...
Re: Type Inference Was a Mistake
#6Sometimes you'll read something and think "I'm not taking the bait".
It'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.
Re: Type Inference Was a Mistake
#7Re: Type Inference Was a Mistake
#8Sometimes you'll read something and think "I'm not taking the bait".
It'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.
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.
Re: Type Inference Was a Mistake
#9Yes. Always annotate types. Keep inference, it tells you when your annotations are inconsistent with tour code.
Re: Type Inference Was a Mistake
#10> In Rust and Haskell you have to at least annotate the parameter types and return type of functions. In Rust you do, but in Haskell you don't.
There are plenty of examples where a type declaration is required to get functionality, especially when we consider what GHC offers as being "Haskell".
I agree the author could be more clear about this—that Haskell and GHC only sometimes require type annotations in certain circumstances.