-
Notifications
You must be signed in to change notification settings - Fork 16
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
Unification in Typeclass Resolution #44
Comments
@re-xyr Imho instance search and implicit inference are different anyway, so I'll prefer using another construct |
I have another problem: If we have a function |
Maybe we should seriously consider adding most general unifiers... |
I thought about what does it mean when an instance matches a problem (i.e. reduces the problem into zero or more subgoals). The type of the instance may contain [bound variables, free variables] (TODO: can it contain metavariables? I think we should prohibit this). The problem may contain [free variables, metavariables]. Note: here free variables includes references to defs. We say the instance matches the problem iff we can find a most general unifier that may contain both bound variables and metavariables, but not free variables.
|
How can the type of an instance to contain metavars? |
Like if someone deliberately leaves holes in the type of their instance. |
Then how are these instances tycked? |
I agree. It is useful anyway |
Are you interested in implementing it? |
Maybe we can also implement RTT, making our type theory to some extent extensional... |
Edge case alert:
|
Then the instance should raise a type error saying that unsolved meta at location |
Yes. |
|
Because meta should be solved within the definition? btw, this is why I posted https://twitter.com/fun_ext/status/1401468891474268162 |
I think so. |
I think its unrelated to most general unifiers but this weekend maybe |
I suggest asking in AK's discord server. Have you joined it yet? |
Ik but I'm very looking forward to it |
No. Could you invite me? |
|
I'm afraid of speaking in front of strange ppl. How should I ask a question? |
@re-xyr Just post in #general |
I suggest just add this single restriction: No Unsolved Meta In Instance Type |
@re-xyr Yeah |
But another problem: Should restriction be checked after checking the head or the body? If the head, then it won't be possible to write this perfectly reasonable instance
If the body, then how should we typecheck
? |
So maybe not "No Unsolved Meta In Instance Type", but "Ignore Instances With Unsolved Metas"? |
@re-xyr IMO this meta should be solved.. |
Basically we can accept only these two kinds of mappings: [meta in problem -> term in instance type, bound variable in instance type -> term in meta]. Maybe we can instead check if the final most general unifier only contains these two kinds of mappings and not worry about whether metas are present in instance types. |
Say in type class resolution, we meet the following instance
and we have the resolution problem
F X Y
. In the description of the tabled typeclass resolution paper, it will generate two subgoals on this instance:F X ?M
andF ?M Y
.However the
?M
does not behave exactly like a metavariable. Namely, it can have multipletemporary[worse, may be not temporary because both solutions may be applicable to the remaining subgoal] solutions: if we have instancesF X Z1
andF X Z2
, then?M
equates to both in the resolution process.Should we change how our metavariable works? Or should we use another kind of syntactic construct for this purpose?
The text was updated successfully, but these errors were encountered: