Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Global type inference #186

Open
nponeccop opened this issue Apr 15, 2021 · 3 comments
Open

Global type inference #186

nponeccop opened this issue Apr 15, 2021 · 3 comments

Comments

@nponeccop
Copy link
Collaborator

nponeccop commented Apr 15, 2021

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
Copy link
Owner

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

@nponeccop
Copy link
Collaborator Author

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:

  • Types are inferred in more contexts than in typical mainstream language (C#, C++, TypeScript) - e.g. function argument types aren't typically inferred.
  • Generic types are inferred as well.
  • Haskell 2000 essentially has complete type inference - you can always omit type specification, well, except the corner cases covered by type defaults, such as IsString when it's inherently ambigous, and by MonomorphismRestriction.

@Gabriella439
Copy link
Owner

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants