Instantiate abstraction body during inference#3128
Instantiate abstraction body during inference#3128LiamGoodacre merged 1 commit intopurescript:masterfrom LiamGoodacre:fix/inferred-constrained-codomain
Conversation
|
This was what I had thought of as a means of fixing it also, I just didn't work on it long enough (> 15 minutes 😉) to figure out how to get it done. So yeah, seems like a good approach to me! |
|
Fixed the shadowing issue by not checking the type of the TypedValue when we need to re-infer. |
|
Should we add the example from the issue as a test case too? |
|
Hmm, if I use |
|
I don't need to re-infer, I just need to check the expression against the new type. |
| -- if we shifted some quantifiers/constraints then we'll need to check against the new type | ||
| expr' <- if null qs && null cs | ||
| then return expr | ||
| else check expr ty' |
There was a problem hiding this comment.
Can you explain why we need to check again here? It definitely seems odd to me to have to traverse the same terms twice.
| withBindingGroupVisible $ bindLocalVariables [(arg, ty, Defined)] $ do | ||
| body@(TypedValue _ _ bodyTy) <- infer' ret | ||
| return $ TypedValue True (Abs (VarBinder arg) body) $ function ty bodyTy | ||
| let (qs, cs, ty') = moveQuantifiersToFrontOverFunction (function ty bodyTy) |
There was a problem hiding this comment.
Can you not just instantiate the type of the body here?
There was a problem hiding this comment.
Yes, that makes more sense. 😸
|
Thanks! Looks good, but could you test it with some existing packages as well, please? |
|
I've checked that the following packages compile: Tried to check more than this but the removal of Sometime this week I will run the tests of various modules to get a better assurance that things aren't broken. |
|
I think profunctor-lenses is a pretty good test for this, if that worked, I doubt there's anything that will be rejected now that previously did work! Nicely done. |
|
I've checked that the following packages' tests pass: |
|
👍 Thanks for testing. I say let's merge then. |
|
Nice, now I can revive my typeclass representation PR... for the 3rd attempt at it 😄 Thanks Liam! |
Fixes #3125
Currently there is an issue with shadowed type vars in the shifted
forall- see my comment on #3125.Does this seem like a good approach?