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

Tactics support for using given constraints #534

Merged
merged 14 commits into from
Oct 25, 2020
Merged

Conversation

isovector
Copy link
Collaborator

This PR allows tactics to use methods from given constraints, meaning it can solve holes like this:

showMe :: Show a => a -> String
showMe = _

It will not, however, discover instances. So this one won't solve:

showMe :: Int -> String
showMe = _

There's quite a lot of finicky details going on in order to support this. The primary challenge is that our types are running after the typechecker has finished, meaning it's already solved the constraints and inlined their evidence. Our solution is to look up the written polymorphic type and unify it with the final, typechecked type. We can use the polymorphic type to find the theta context, and instantiate every class method in the theta.

In addition, this PR fixes a subtle bug in our unification code, which could cause skolems to unify in some circumstances.

Furthermore, it adds a tie-breaker to the scoring metric to prefer shorter programs.

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

Successfully merging this pull request may close these issues.

2 participants