| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
ParensInType is removed as part of operator desugaring (removeParens). You are probably missing a case when traversing types for the deriving via declaration. |
Sorry, something went wrong.
|
Oh thank you, I added the guilty case 🙇 Also I fixed my error messages and moved most of the deriving via checks into the type checker because I was duplicating a lot of work to infer kinds. |
Sorry, something went wrong.
| 'then' { SourceToken _ (TokLowerName [] "then") } | ||
| 'true' { SourceToken _ (TokLowerName [] "true") } | ||
| 'type' { SourceToken _ (TokLowerName [] "type") } | ||
| 'via' { SourceToken _ (TokLowerName [] "via") } |
There was a problem hiding this comment.
Since this is a contextual keyword, you will need to make sure to add it ident, qualIdent, and label.
Sorry, something went wrong.
There was a problem hiding this comment.
Good catch! Sorry about that, I added a few test cases to cover this.
Sorry, something went wrong.
|
I managed to ensure the via kind unifies with the kind of the type for which the instance is derived! Elaborating the kinds didn’t work but inferring them after binding all free variables to fresh kinds (like it is done when checking instances declarations) does 🎉 |
Sorry, something went wrong.
| , solverDeferErrors = False | ||
| } | ||
| void . flip runStateT M.empty . runWriterT $ | ||
| entails solverOptions constraint M.empty [] |
There was a problem hiding this comment.
Does this throw away the unsolved constraints?
Sorry, something went wrong.
There was a problem hiding this comment.
Oh, but that's fine because of the current SolverOptions, so the solver won't emit unsolved constraints and instead just fail, right? I guess that means we can't write something like
data T
derive via (...) instance blah :: Coercible X Y => Cls Ti.e. defer Coercible constraints in the instance head, but that's not a big loss, and maybe something that can be solved later?
Sorry, something went wrong.
There was a problem hiding this comment.
The solver indeed fails when typechecking the instance declaration if the generated constraint can’t be solved but it doesn’t try to solve the instance context, so you can write such instance.
Sorry, something went wrong.
| gSimple (MissingNewtypeSuperclassInstance cl1 cl2 ts) = MissingNewtypeSuperclassInstance cl1 cl2 <$> traverse f ts | ||
| gSimple (UnverifiableSuperclassInstance cl1 cl2 ts) = UnverifiableSuperclassInstance cl1 cl2 <$> traverse f ts | ||
| gSimple (InvalidViaType cl ts viaTy) = InvalidViaType cl <$> traverse f ts <*> f viaTy | ||
| gSimple (InvalidViaKind cl ts viaTy viaKind expectedKind) = InvalidViaKind cl <$> traverse f ts <*> f viaTy <*> f viaKind <*> f expectedKind |
There was a problem hiding this comment.
Should f be called on kinds here? There’s no case for the KindsDoNotUnify error for instance so maybe it shouldn’t 🤔
Sorry, something went wrong.
There was a problem hiding this comment.
If there are cases that are missing it's probably an oversight.
Sorry, something went wrong.
There was a problem hiding this comment.
The following SimpleErrorMessage constructors hold SourceTypes but aren’t matched:
Should I add cases for them in this PR? Matching every constructor explicitly would be verbose but could help to prevent this in the future.
Sorry, something went wrong.
|
One thing to consider with this syntax is #1120. If we allowed forall for instances, the via clause would be outside of the binder. Should we discuss making via a proper reserved word and put it at the end of the instance? Obviously that ticket isn't a done deal, but I think it's something other maintainers are keen on, so some bike-shedding might be appropriate. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
It looks like it works but there’s a few things I need help with:
For instance Data.Functor.Compose.Compose has such a polymorphic kind:
meaning that elaborating the kind of Compose (Either e) Maybe fails when elaborating the application of Compose to Either e. Should I approach this differently?
Also I took the liberty to rename MissingNewtypeSuperclassInstance to MissingSuperclassInstance since this error is thrown for both newtype and via instances, removed the mention of derived superclass instance from its message (since any instance actually qualify) and replaced the InvalidNewtypeInstance error thrown when trying to derive a newtype instance for a nullary type class by a new CannotDeriveNullaryTypeClassInstance error (which is also thrown for via instances).
Close #3302.