-
Notifications
You must be signed in to change notification settings - Fork 35
Polymorphic typechecking doesn't work #7
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
Comments
So, just to make sure we are on the same page: The bug shown in your example is that the output is of type I hope I did not give the impression in the README that Hask is doing type inference on the function body--that is essentially impossible in Python. Nor does it really make sense to do this--in your example, for some For example, there is really no way that Hask can or should detect this behavior at function-creation-time, even though it causes a runtime error: @sig(H/ "a" >> "b" >> "a")
def const1(x, y):
return x + 1
const1("b", 1) What Hask is doing is inferring types within the type signature and when functions are composed, and checking the types when arguments are supplied and when the function is evaluated. |
Indeed, the example shows not one, but two bugs. (I first meant to post two examples -- hence 1 in If what you're doing is separately unifying |
If you look under the hood at hindley_milner.py, it does have a real implementation of HM (i.e., if you create expressions in the internal type language, which is basically just lambda calculus, it will infer the most general type; there are some examples of this in tests.py). But as you pointed out, Hask does try to unify arguments as soon as it receives them, and does not use inference on the body of functions, which is not HM. |
It looks like hask always trusts type signatures and doesn't check them.
E.g.
runs successfully.
If my understanding is correct, perhaps you should highlight this fact in the readme and not claim "Full Hindley-Milner type system that will typecheck any function decorated with a Hask type signature".
The text was updated successfully, but these errors were encountered: