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

Solve unsolved class constraints during whnf #61

Merged
merged 1 commit into from
Oct 31, 2017

Conversation

ollef
Copy link
Owner

@ollef ollef commented Oct 31, 2017

This requires some changes to the normalisation machinery and to the
elaborator.

  • The whnf function is now parameterised by how it should handle
    unsolved class constraints. When typechecking, this parameter is the
    class instance elaborator.
  • The class instance elaborator is now parameterised by what it should
    do with constraints it still didn't manage to solve. When normalising,
    we want to keep the constraints as the UnsolvedConstraint global,
    since it allows the type of the constraint to contain bound variables.
    When generalising, we want to (like before) make the constraints Exist
    metavars, such that they are picked up as free vars that can be
    generalised.

Fixes #48.

The elaboration during normalisation will not take into account local
constraints (e.g. stemming from MyClass a => constraints in a type
signature), but I believe this is not necessary since those constraints
are still unknown and will not reduce further anyway. So I think it's OK
to leave those for the full elaboration pass. (I might be wrong
though...)

This requires some changes to the normalisation machinery and to the
elaborator.

* The whnf function is now parameterised by how it should handle
unsolved class constraints. When typechecking, this parameter is the
class instance elaborator.
* The class instance elaborator is now parameterised by what it should
do with constraints it still didn't manage to solve. When normalising,
we want to keep the constraints as the `UnsolvedConstraint` global,
since it allows the type of the constraint to contain bound variables.
When generalising, we want to (like before) make the constraints `Exist`
metavars, such that they are picked up as free vars that can be
generalised.

Fixes #48.

The elaboration during normalisation will not take into account local
constraints (e.g. stemming from `MyClass a =>` constraints in a type
signature), but I believe this is not necessary since those constraints
are still unknown and will not reduce further anyway. So I think it's OK
to leave those for the full elaboration pass. (I might be wrong
though...)
@ollef ollef merged commit b4968e8 into master Oct 31, 2017
@ollef ollef deleted the NormaliseUnsolvedConstraints branch October 31, 2017 18:30
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.

1 participant