Gabriella439 / post-rfc

Blog post previews in need of peer review
Creative Commons Attribution 4.0 International
2.19k stars 171 forks source link

Global type inference #186

Open nponeccop opened 3 years ago

nponeccop commented 3 years ago

The document mentions "global type inference" several times, but it isn't technically true - Haskell doesn't have a global type inference. Quite opposite, the inference tries to be as local as possible, e.g. in case of Hindley-Milner principal types.

I guess we could use https://en.wikipedia.org/wiki/Lie-to-children sparingly, but we need a better explanation of how type inference is different from auto types in other languages. E.g. two main differences is that neither generic types nor argument types are normally inferred in "normal" languages.

Just calling it "global" or "bidirectional" doesn't convey anything, especially because it's neither global nor bidirectional.

Gabriella439 commented 3 years ago

@nponeccop: Would calling Haskell "based on Hindley-Milner type inference" be accurate enough?

nponeccop commented 3 years ago

I think something like "first-class type inference" would remain loosely understandable by laypeople not familiar with Haskell and/or Hindley-Milner languages, but it wouldn't be misleading. And I think in Type Driven Development we could explain what does it mean precisely:

Gabriella439 commented 3 years ago

@nponeccop: Do you mean to say "best in class type inference"? When I think "first-class" I usually understand that to mean that it is something that can be manipulated within the language (e.g. first class functions), but Haskell's type inference cannot be passed as a function argument or stored within a list/record