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

Allow import all constructors #2782

Merged
merged 4 commits into from
Mar 19, 2022

Conversation

July541
Copy link
Collaborator

@July541 July541 commented Mar 15, 2022

This is for #2734

Brief intro:

With

Module A where
data Foo = Foo | Bar

it will suggest import Foo(..) now, like import A(Foo(..)) and Add Foo(..) to the import list of A.


Note:
Support Now!
This doesn't work for record fields, ideally, we should support this.

Example:

data Foo = Bar {a :: Int}

if we have f = a, we should also have import A(Foo(..)). Maybe we can extend

data IdentInfo = IdentInfo
{ name :: !OccName
, rendered :: Text
, parent :: !(Maybe Text)
, isDatacon :: !Bool
, moduleNameText :: !Text
}

with a field to indicate a's data type if a is a record field.

@July541 July541 requested a review from pepeiborra as a code owner March 15, 2022 15:58
@July541
Copy link
Collaborator Author

July541 commented Mar 15, 2022

With data A = B | C,

import A (A(B))
f = C

it will cause import A (A(B, ..) if we import all constructors. I'll check it later.

@pepeiborra
Copy link
Collaborator

This is a good idea, thanks for working on it!

@pepeiborra
Copy link
Collaborator

if we have f = a, we should also have import A(Foo(..)). Maybe we can extend

data IdentInfo = IdentInfo
{ name :: !OccName
, rendered :: Text
, parent :: !(Maybe Text)
, isDatacon :: !Bool
, moduleNameText :: !Text
}

with a field to indicate a's data type if a is a record field.

Did you consider checking if isJust parent ?

@July541 July541 force-pushed the all-constructors-import branch from 1c9c1b1 to 77def21 Compare March 19, 2022 06:00
Copy link
Collaborator

@pepeiborra pepeiborra left a comment

Choose a reason for hiding this comment

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

Fantastic work, thank you @July541 !

@pepeiborra pepeiborra merged commit 2221371 into haskell:master Mar 19, 2022
@July541 July541 deleted the all-constructors-import branch March 19, 2022 11:43
July541 added a commit to July541/haskell-language-server that referenced this pull request Mar 30, 2022
* Import all constructors

* Rewrite the test

* Exact print wildcard

* Rerun circleci
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants