-
Notifications
You must be signed in to change notification settings - Fork 483
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
[Builtins] Add detection of applied type variables to the elaboration machinery #4648
[Builtins] Add detection of applied type variables to the elaboration machinery #4648
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Blind approving, I'm not sure I have the brain space to learn about the type errors stuff more right now 😅
You're breaking my heart Michael, I've rewritten that damn thing four times from scratch before becoming convinced it was the simplest way of handling the most general case. |
I didn't say it wasn't the simplest possible ;) |
-- | Throw an error telling the user not to apply type variables to anything. | ||
type ThrowNoAppliedVars :: (GHC.Type -> GHC.Type) -> GHC.Constraint | ||
type family ThrowNoAppliedVars hole where | ||
-- In the Rep context higher-kinded type variables are allowed, but need to be applied via |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps add a See Note [Rep vs Type context]
here in case someone finds the "Rep/Type context" terminology unfamiliar.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, done.
'Text " applied via regular type application" ':$$: | ||
'Text "To fix this error instantiate all higher-kinded type variables" | ||
|
||
instance TypeError NoRegularlyAppliedHkVarsMsg => Functor (Opaque val) where |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's nice to remove these specific instances. I assume you can do something similar to the TypeError NoConstraintsErrMsg => Eq (Opaque val rep)
instance and similar ones?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, unfortunately. We can barf on any applied type variable, but we can't barf on any variable appearing in the argument position as it's perfectly fine to have an argument whose type is a type variable (as in IfThenElse
). It's really about not allowing any constraints and for that the best we can do is hardcode some of them.
a22e01d
to
79f3c58
Compare
…to effectfully/builtins/add-detection-of-higher-kinded-vars
79f3c58
to
177e942
Compare
This:
Type
contextRep
andType
contexts and gives the user a more specific error message due to being context-awareI've tested it manually, gonna commit some example error message in a subsequent PR (I need a bit of additional machinery for that, hence a different PR).