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

Properly reject higher-rank types during promotion/singling #406

Merged
merged 4 commits into from
Sep 4, 2019

Conversation

RyanGlScott
Copy link
Collaborator

singletons can't handle higher-rank types. You might think that these sorts of types would naturally be rejected when promoting or singling them, but that actually turns out not to be the case! (See #401 for examples of higher-rank types that squeeze through the cracks.)

Luckily, the additional machinery that th-desuguar adds in goldfirere/th-desugar#125 makes it much easier to detect these. Instead of using unravelDType to decompose a function type (which permits all sorts of higher-rank gubbins), we use a restricted version called unravelVanillaDType, which throws an error if anything higher-rank is detected. See Note [Vanilla-type validity checking during promotion] in D.S.Promote.Type for a full explanation of what a "vanilla" type is.

Fixes #401.

`singletons` can't handle higher-rank types. You might think that
these sorts of types would naturally be rejected when promoting or
singling them, but that actually turns out not to be the case!
(See #401 for examples of higher-rank types that squeeze through the
cracks.)

Luckily, the additional machinery that `th-desuguar` adds in
goldfirere/th-desugar#125 makes it much easier to detect these.
Instead of using `unravelDType` to decompose a function type (which
permits all sorts of higher-rank gubbins), we use a restricted
version called `unravelVanillaDType`, which throws an error if
anything higher-rank is detected. See
`Note [Vanilla-type validity checking during promotion]` in
`D.S.Promote.Type` for a full explanation of what a "vanilla" type
is.

Fixes #401.
Copy link
Owner

@goldfirere goldfirere left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good -- a few small suggestions.

CHANGES.md Outdated Show resolved Hide resolved
src/Data/Singletons/Promote/Type.hs Outdated Show resolved Hide resolved
src/Data/Singletons/Util.hs Show resolved Hide resolved
@goldfirere
Copy link
Owner

Ship it!

@RyanGlScott RyanGlScott merged commit ee19ecc into master Sep 4, 2019
@RyanGlScott RyanGlScott deleted the th-desugar-T113 branch September 4, 2019 15:56
RyanGlScott added a commit that referenced this pull request Nov 2, 2019
There was one place where #406 forgot to check for higher-rank types:
the types of data constructors. Easily fixed.
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.

Figure out a policy for rank-n types
2 participants