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

Bugfix type signature lenses / code actions for pattern synonyms. #1952

Merged
merged 5 commits into from Jun 28, 2021

Conversation

peterwicksstringfield
Copy link
Contributor

@peterwicksstringfield peterwicksstringfield commented Jun 20, 2021

Purposed fix that closes #1951. Half expecting to trip over a ghc api incompatibility. We will see.

Use a better method for getting the type. The old method didn't work for
unidirectional synonyms:
  pattern Some a <- Just a
and gave the wrong type for synonyms with provided constraints:
  data T1 a where"
    MkT1 :: (Show b) => a -> b -> T1 a"
  pattern MkT1' :: (Eq a, Num a) => Show b => b -> T1 a
  pattern MkT1' b = MkT1 42 b
@peterwicksstringfield
Copy link
Contributor Author

peterwicksstringfield commented Jun 20, 2021

There we go, that's the sort of thing I was expecting, ghc 9 difference:

ghcide                           > /root/build/ghcide/src/Development/IDE/Plugin/TypeLenses.hs:294:91: error:
ghcide                           >     • Couldn't match type ‘Scaled Type’ with ‘Type’
ghcide                           >       Expected: [Type]
ghcide                           >         Actual: [Scaled Type]
ghcide                           >     • In the fifth argument of ‘mkPatSyn’, namely ‘orig_args’
ghcide                           >       In the expression:
ghcide                           >         mkPatSyn
ghcide                           >           name declared_infix ([], req_theta) ([], prov_theta) orig_args
ghcide                           >           orig_res_ty matcher builder field_labels
ghcide                           >       In an equation for ‘pWithoutTypeVariables’:
ghcide                           >           pWithoutTypeVariables
ghcide                           >             = mkPatSyn
ghcide                           >                 name declared_infix ([], req_theta) ([], prov_theta) orig_args
ghcide                           >                 orig_res_ty matcher builder field_labels
ghcide                           >     |
ghcide                           > 294 |     pWithoutTypeVariables = mkPatSyn name declared_infix ([], req_theta) ([], prov_theta) orig_args orig_res_ty matcher builder field_labels
ghcide                           >     |      

I'll fix this tomorrow afternoon probably. EDIT: Fixed.

Copy link
Collaborator

@berberman berberman left a comment

Choose a reason for hiding this comment

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

LGTM, thank you for the fix!

The multiplicities returned by patSynSig on the orig_args value are
uninteresting. patSynSig is literally just calling (map unrestricted). There is
no information there for us to care about.
@peterwicksstringfield
Copy link
Contributor Author

I kicked off a merge from master. Is this ready to merge once that's done?

Copy link
Member

@jneira jneira left a comment

Choose a reason for hiding this comment

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

Sure, thanks for the bugfix

@jneira jneira added the merge me Label to trigger pull request merge label Jun 28, 2021
@mergify mergify bot merged commit e48e02a into haskell:master Jun 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merge me Label to trigger pull request merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

type signature code lens required vs provided constraints
3 participants