Live data from Hacker News

Type Inference Was a Mistake

borretti.me

131–133 of 133 posts

Re: Type Inference Was a Mistake

#131

Type inference has usability problems (2019): https://austinhenley.com/blog/typeinference.html

> Imagine you're told to calculate 3+9+15+18+5.

Too hard. I need to see the types:

  ((((3::Int)+(9::Int)::Int)+(15::Int)::Int)+(18::Int)::Int)+(5::Int)::Int
Is that even harder to read?

> My response? Go refactor your hideous code.

Re: Type Inference Was a Mistake

#132

“I don’t want to infer types from my code. I’d rather infer the code from the types.” Ditto. The world where data and it’s type is the SSOT means you can trivially validate every bit of code that touches it.

> I don’t want to infer types from my code. I’d rather infer the code from the types.

I use type inference for this: the compiler looks at the existing types and then infers the type of the code I haven't yet written and tells me. I then write code based on the type given to me by the compiler.

Re: Type Inference Was a Mistake

#133
post #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.

> This SOUNDS like “types are bad”

No, this sounds like:

* Type Inference Was a Mistake

* Type Inference Makes Code Less Readable

* Type Inference is a Footgun

* Type Inference Wastes Academic Effort

These are incompatible with:

> Keep inference

Post reply on HN