Live data from Hacker News

Type Inference Was a Mistake

borretti.me

1–10 of 133 posts

Re: Type Inference Was a Mistake

#3
post #2

Sometimes 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

#6
post #3
post #2

Sometimes 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.

[deleted]

Re: Type Inference Was a Mistake

#8
post #3
post #2

Sometimes 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.

Rust 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.

Re: Type Inference Was a Mistake

#9
This SOUNDS like “types are bad”. The author’s message (towards the end of the article) is “I don’t want to infer types from my code. I’d rather infer the code from the types. Types are the spec…”

Yes. 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.

What about when writing a function with polymorphic recursion, rank-N types, or the monomorphism restriction?

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.

Post reply on HN