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

Generalise macro type-checking #296

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft

Generalise macro type-checking #296

wants to merge 2 commits into from

Conversation

sheaf
Copy link
Collaborator

@sheaf sheaf commented Nov 20, 2024

This commit generalises macro type-checking, making class constraints more general by allowing what GHC calls FlexibleContexts and FlexibleInstances.

Key changes:

  • A special monad for solving, TcSolveM. This monad keeps track of a work list and a set of inert (= fully processed) constraints.

  • Solving a constraint using a top-level instance may now add additional constraints to the work list.

  • Instances are keyed using a TrieMap, similar to GHC's RoughMap, which avoids traversing all instances when doing instance matching.

@sheaf sheaf force-pushed the flexible-tc-macro branch 2 times, most recently from ea85225 to 05b181d Compare November 20, 2024 14:13
This commit generalises macro type-checking, making class constraints
more general by allowing what GHC calls FlexibleContexts and
FlexibleInstances.

Key changes:

  - A special monad for solving, TcSolveM.
    This monad keeps track of a work list and a set of
    inert (= fully processed) constraints.

  - Solving a constraint using a top-level instance may now add
    additional constraints to the work list.

  - Instances are keyed using a TrieMap, similar to GHC's RoughMap,
    which avoids traversing all instances when doing instance matching.
@sheaf sheaf force-pushed the flexible-tc-macro branch 3 times, most recently from 8dd1908 to 90eef83 Compare November 21, 2024 14:07
The solver didn't handle equalities properly, as it didn't account for
the result of unification. Now, we try to unify, and if the unifier
makes no progress we make the constraint into an inert constraint.
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