-
Notifications
You must be signed in to change notification settings - Fork 14
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
Improve local reification and desugaring with respect to standalone kind signatures #227
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This migrates various substitution functions from `singletons-th` to `th-desugar` as part of an effort to eventually implement a fix for #223. Unlike the existing functions in `Language.Haskell.TH.Subst`, the functions in `Language.Haskell.TH.Desugar.Subst.Capturing` do _not_ avoid capture when substituting into `forall` types. This means that these functions can be pure instead of monadic.
This patch migrates two functions from `singletons-th` over to `th-desugar`, which will be useful in implementing `matchUpSAKWithDecl` as part of #223.
This patch migrates the following functions from `singletons-th` to `th-desugar`: * `matchUpSAKWithDecl`, which makes up the type variable binders from a standalone kind signature with the corresponding type variable binders from the type-level declaration header. * The `ForAllTyFlag` data type, a generalization of `Specificity` and `BndrVis`. (`matchUpSAKWithDecl` returns `[TyVarBndr ForAllTyFlag]`.) * `tvbForAllTyFlagsToSpecs` and `tvbForAllTyFlagsToBndrVis` functions, which allow converting the results of calling `matchUpSAKWithDecl` to `[TyVarBndrSpec]` or `[TyVarBndrVis]`, respectively. Also add counterparts to the functions above that work over `DTyVarBndr`s instead of `TyVarBndr`s. Fixes #223.
…ind signatures Previously, `th-desugar` would not take standalone kind signatures into account when locally reifying a class method (#220). Similarly, it would not take them into account when locally reifying or desugaring a data constructor (#199). This patch accomplishes this, mainly by using the `matchUpSAKWithDecl` function (during local reification) and the `dMatchUpSAKWithDecl` function (during desugaring) to match up kind information from the standalone kind signature to the parent declaration's type variable binders. Fixes #199. Fixes #220.
RyanGlScott
added a commit
to goldfirere/singletons
that referenced
this pull request
Jul 12, 2024
As part of a fix for goldfirere/th-desugar#223, goldfirere/th-desugar#227 adds its own version of `singletons-th`'s `matchUpSAKWithDecl` function (now called `dMatchUpSAKWithDecl` on the `th-desugar` side). This commit completes the migration by removing `singletons-th`'s version of `matchUpSAKWithDecl` and instead using the version offered by `th-desugar`.
RyanGlScott
added a commit
to goldfirere/singletons
that referenced
this pull request
Jul 12, 2024
As part of a fix for goldfirere/th-desugar#199 and goldfirere/th-desugar#220, goldfirere/th-desugar#227 improves `th-desugar`'s ability to locally reify and desugar precise types for Haskell98-style data constructors and class methods. This has a couple of knock-on effects for `singletons`: * The type of `dsCon` has changes to accept `DTyVarBndrSpec`s instead of `DTyVarBndrUnit`s, so we must adapt the call sites in `singletons-th` accordingly. * Some of the test cases in `singletons-base` need to have their expected output updated to account for the improved kind information and specificity information flowing down from standalone kind signatures.
RyanGlScott
added a commit
to goldfirere/singletons
that referenced
this pull request
Jul 12, 2024
As part of a fix for goldfirere/th-desugar#223, goldfirere/th-desugar#227 adds its own version of `singletons-th`'s `matchUpSAKWithDecl` function (now called `dMatchUpSAKWithDecl` on the `th-desugar` side). This commit completes the migration by removing `singletons-th`'s version of `matchUpSAKWithDecl` and instead using the version offered by `th-desugar`.
RyanGlScott
added a commit
to goldfirere/singletons
that referenced
this pull request
Jul 12, 2024
As part of a fix for goldfirere/th-desugar#199 and goldfirere/th-desugar#220, goldfirere/th-desugar#227 improves `th-desugar`'s ability to locally reify and desugar precise types for Haskell98-style data constructors and class methods. This has a couple of knock-on effects for `singletons`: * The type of `dsCon` has changes to accept `DTyVarBndrSpec`s instead of `DTyVarBndrUnit`s, so we must adapt the call sites in `singletons-th` accordingly. * Some of the test cases in `singletons-base` need to have their expected output updated to account for the improved kind information and specificity information flowing down from standalone kind signatures.
RyanGlScott
added a commit
to goldfirere/singletons
that referenced
this pull request
Jul 13, 2024
As part of a fix for goldfirere/th-desugar#223, goldfirere/th-desugar#227 adds its own version of `singletons-th`'s `matchUpSAKWithDecl` function (now called `dMatchUpSAKWithDecl` on the `th-desugar` side). This commit completes the migration by removing `singletons-th`'s version of `matchUpSAKWithDecl` and instead using the version offered by `th-desugar`.
RyanGlScott
added a commit
to goldfirere/singletons
that referenced
this pull request
Jul 13, 2024
As part of a fix for goldfirere/th-desugar#199 and goldfirere/th-desugar#220, goldfirere/th-desugar#227 improves `th-desugar`'s ability to locally reify and desugar precise types for Haskell98-style data constructors and class methods. This has a couple of knock-on effects for `singletons`: * The type of `dsCon` has changes to accept `DTyVarBndrSpec`s instead of `DTyVarBndrUnit`s, so we must adapt the call sites in `singletons-th` accordingly. * Some of the test cases in `singletons-base` need to have their expected output updated to account for the improved kind information and specificity information flowing down from standalone kind signatures.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Previously,
th-desugar
would not take standalone kind signatures into account when locally reifying a class method (#220). Similarly, it would not take them into account when locally reifying or desugaring a data constructor (#199). This patch accomplishes this, mainly by using thematchUpSAKWithDecl
function (during local reification) and thedMatchUpSAKWithDecl
function (during desugaring) to match up kind information from the standalone kind signature to the parent declaration's type variable binders.Fixes #199. Fixes #220.
This PR is split up into a number of commits, as several commits are required in order to migrate
matchUpSAKWithDecl
/dMatchUpSAKWithDecl
(along with the functionality needed to define them) fromsingletons-th
over toth-desugar
. As such, this PR also fixes #223.