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

Correctly unify typeclass constraints when inferring types #1

Open
billpmurphy opened this issue Jul 28, 2015 · 2 comments
Open

Correctly unify typeclass constraints when inferring types #1

billpmurphy opened this issue Jul 28, 2015 · 2 comments
Labels

Comments

@billpmurphy
Copy link
Owner

When a TypeVariable with typeclass constraints are unified with a TypeOperator, the type system (i.e., unify in hindley_milner.py) does not check to see if the TypeOperator is actually a member of the required typeclasses. As a result of this, some TypeErrors related to typeclass membership will not be raised until function-call time (as opposed to function-compose time).

For example, consider show (of the Show typeclass). When show is composed with id, the typeclass constraints will be unified and the composed function will have the correct constrained type. If you compose show with a function with a concrete (TypeVariable) output type which is not a member of Show, the type inference system will not check the constraint and raise a TypeError until the composed function is actually called.

@tonyfloatersu
Copy link

tonyfloatersu commented Sep 14, 2018

The solution might lies in this place since you didn't copy the constraints to the new TypeVariable.

The origin version of this HM type system python implement did not take constraints into acocunt.

@tonyfloatersu
Copy link

tonyfloatersu commented Sep 14, 2018

BTW you can try to add an option for Arrow in the fresh function since you might encounter the function with sig (int -> int) be copyed into (-> int int), which looks terrible...

Actually not just Arrow entry, you might need to add Tuple and List as well...

p.s. I do appreciate this awesome project, but it seems to be dead for quite a while... I feel sorry about it.

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

No branches or pull requests

2 participants